Skip to content

Commit c3526f9

Browse files
committed
Tweak terminology: stop -> finish
1 parent 0becbe3 commit c3526f9

File tree

5 files changed

+42
-44
lines changed

5 files changed

+42
-44
lines changed

TODO

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
TODO: Rename "stop" terminology to "finish".
2-
31
TODO: Wait after the refresh API is hit before querying for changes on GitHub.
42
It seems like it takes a while (probably ~1min is fine) for mergable pull
53
requests to show up. (Or investigate why this is happening.) Note: the API

apiLib.sml

+12-12
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,29 @@ Reference:
4646
returns "Uploaded"
4747
fails (409) if a file called <name> already exists for <id>
4848
49-
stop id:
50-
mark job <id> as stopped
51-
returns "Stopped"
49+
finish id:
50+
mark job <id> as finished
51+
returns "Finished"
5252
sends email with output
5353
fails (409) if <id> is not currently running
5454
5555
abort id:
5656
mark job <id> as aborted
5757
returns "Aborted"
58-
fails (409) if <id> is not currently stopped
58+
fails (409) if <id> is not currently finished
5959
6060
all failures return text starting with "Error:"
6161
6262
Jobs move (right only) between these states:
6363
64-
waiting, running, stopped, aborted
64+
waiting, running, finished, aborted
6565
6666
waiting = ready to be run, waiting for a worker
6767
running = claimed to be running by a worker
68-
stopped = finished either with success or failure
68+
finished = finished either with success or failure
6969
aborted = the worker did not finish properly
7070
71-
When the waiting queue is refreshed, the commits of running or stopped jobs are
71+
When the waiting queue is refreshed, the commits of running or finished jobs are
7272
not considered to need running again, whereas the commits of aborted jobs are
7373
(as long as they are still the latest commits).
7474
@@ -101,14 +101,14 @@ datatype post_api =
101101
| Append of id * line (* not including newline *)
102102
| Log of id * string * int
103103
| Upload of id * string * int
104-
| Stop of id
104+
| Finish of id
105105
| Abort of id
106106
datatype api = G of get_api | P of post_api
107107

108108
fun post_response Refresh = "Refreshed\n"
109109
| post_response (Claim _) = "Claimed\n"
110110
| post_response (Append _) = "Appended\n"
111-
| post_response (Stop _) = "Stopped\n"
111+
| post_response (Finish _) = "Finished\n"
112112
| post_response (Abort _) = "Aborted\n"
113113
| post_response (Log _) = "Logged\n"
114114
| post_response (Upload _) = "Uploaded\n"
@@ -142,14 +142,14 @@ fun api_to_string (G Waiting) = "/waiting"
142142
| api_to_string (G (Job id)) = String.concat["/job/",Int.toString id]
143143
| api_to_string (P (Claim (id,_))) = String.concat["/claim/",Int.toString id]
144144
| api_to_string (P (Append (id,_))) = String.concat["/append/",Int.toString id]
145-
| api_to_string (P (Stop id)) = String.concat["/stop/",Int.toString id]
145+
| api_to_string (P (Finish id)) = String.concat["/finish/",Int.toString id]
146146
| api_to_string (P (Abort id)) = String.concat["/abort/",Int.toString id]
147147

148148
fun post_curl_args (Append (_,line)) = ["--data-urlencode",String.concat["line=",line]]
149149
| post_curl_args (Claim (_,name)) = ["--data-urlencode",String.concat["name=",name]]
150150
| post_curl_args (Log (_,file,_)) = ["--data-binary",String.concat["@",file]]
151151
| post_curl_args (Upload (_,file,_)) = ["--data",String.concat["name=",List.last(#arcs(OS.Path.fromString file))],"--data-binary",String.concat["@",file]]
152-
| post_curl_args (Stop _) = ["--data",""]
152+
| post_curl_args (Finish _) = ["--data",""]
153153
| post_curl_args (Abort _) = ["--data",""]
154154
| post_curl_args (Refresh) = ["--data",""]
155155

@@ -209,7 +209,7 @@ fun post_from_string s len =
209209
(fn id => Option.map (fn (name,l) => Upload(id,name,l))
210210
(Option.mapPartial read_name len))
211211
(id_from_string n)
212-
| ["stop",n] => Option.map Stop (id_from_string n)
212+
| ["finish",n] => Option.map Finish (id_from_string n)
213213
| ["abort",n] => Option.map Abort (id_from_string n)
214214
| _ => NONE)
215215

server.sml

+13-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ It also provides a hook for refreshing the queues:
66
If there are new jobs on GitHub, they will be added as waiting.
77
If there are stale jobs, they will be removed.
88
9-
Each job is on exactly one list: waiting, running, stopped, aborted.
9+
Each job is on exactly one list: waiting, running, finished, aborted.
1010
If a job changes list, it can only move to the right.
1111
1212
The waiting queue is refreshed as follows:
@@ -15,7 +15,7 @@ The waiting queue is refreshed as follows:
1515
2. Get the current snapshots from GitHub (see below)
1616
3. Filter out from the snapshots:
1717
- any with the same CakeML head commit as a running job
18-
- any with the same snapshot (head+base+HOL commits) as a stopped job
18+
- any with the same snapshot (head+base+HOL commits) as a finished job
1919
4. Add the remaining snapshots to the waiting jobs list
2020
2121
The running queue may be refreshed by removing timed out jobs. (Not implemented yet.)
@@ -105,18 +105,18 @@ fun upload (id,name,len) =
105105
(* TODO: update link on downloads page on CakeML main site? *)
106106
end
107107

108-
fun stop id =
108+
fun finish id =
109109
let
110110
val f = Int.toString id
111111
val old = OS.Path.concat("running",f)
112-
val new = OS.Path.concat("stopped",f)
112+
val new = OS.Path.concat("finished",f)
113113
val fd = acquire_lock ()
114114
val () =
115115
if OS.FileSys.access(old,[OS.FileSys.A_READ]) then
116116
if OS.FileSys.access(new,[OS.FileSys.A_READ]) then
117-
cgi_die 500 ["job ",f, " is both running and stopped"]
117+
cgi_die 500 ["job ",f, " is both running and finished"]
118118
else OS.FileSys.rename{old = old, new = new}
119-
else cgi_die 409 ["job ",f," is not running: cannot stop"]
119+
else cgi_die 409 ["job ",f," is not running: cannot finish"]
120120
val inp = TextIO.openIn new
121121
val sha = get_head_sha (read_bare_snapshot inp)
122122
val status = read_status inp
@@ -134,15 +134,15 @@ fun stop id =
134134
fun abort id =
135135
let
136136
val f = Int.toString id
137-
val old = OS.Path.concat("stopped",f)
137+
val old = OS.Path.concat("finished",f)
138138
val new = OS.Path.concat("aborted",f)
139139
val fd = acquire_lock ()
140140
in
141141
if OS.FileSys.access(old,[OS.FileSys.A_READ]) then
142142
if OS.FileSys.access(new,[OS.FileSys.A_READ]) then
143-
cgi_die 500 ["job ",f, " is both stopped and aborted"]
143+
cgi_die 500 ["job ",f, " is both finished and aborted"]
144144
else (OS.FileSys.rename{old = old, new = new}; Posix.IO.close fd)
145-
else cgi_die 409 ["job ",f," is not stopped: cannot abort"]
145+
else cgi_die 409 ["job ",f," is not finished: cannot abort"]
146146
end
147147

148148
fun refresh () =
@@ -152,10 +152,10 @@ fun refresh () =
152152
val () = clear_list "waiting"
153153
(* TODO: stop timed out jobs *)
154154
val running_ids = running()
155-
val stopped_ids = stopped()
155+
val finished_ids = finished()
156156
val snapshots = filter_out (same_head "running") running_ids snapshots
157-
val snapshots = filter_out (same_snapshot "stopped") stopped_ids snapshots
158-
val avoid_ids = running_ids @ stopped_ids @ aborted()
157+
val snapshots = filter_out (same_snapshot "finished") finished_ids snapshots
158+
val avoid_ids = running_ids @ finished_ids @ aborted()
159159
val () = if List.null snapshots then ()
160160
else ignore (List.foldl (add_waiting avoid_ids) 1 snapshots)
161161
in Posix.IO.close fd end
@@ -210,7 +210,7 @@ in
210210
| (P (Append x)) => append x
211211
| (P (Log x)) => log x
212212
| (P (Upload x)) => upload x
213-
| (P (Stop x)) => stop x
213+
| (P (Finish x)) => finish x
214214
| (P (Abort x)) => abort x
215215
in
216216
write_text_response 200 response

serverLib.sml

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
to ensure this.
1111
1212
Job lists are implemented as directories:
13-
waiting, running, stopped, aborted
13+
waiting, running, finished, aborted
1414
1515
Jobs are implemented as files with their id as filename.
1616
@@ -165,7 +165,7 @@ fun print_job out (j:job) =
165165
in () end
166166

167167
val artefacts_dir = "artefacts"
168-
val queue_dirs = ["waiting","running","stopped","aborted"]
168+
val queue_dirs = ["waiting","running","finished","aborted"]
169169

170170
local
171171
open OS.FileSys
@@ -228,10 +228,10 @@ end
228228

229229
val waiting = List.rev o read_list "waiting"
230230
val running = read_list "running"
231-
val stopped = read_list "stopped"
231+
val finished = read_list "finished"
232232
val aborted = read_list "aborted"
233233

234-
val queue_funs = [waiting,running,stopped,aborted]
234+
val queue_funs = [waiting,running,finished,aborted]
235235

236236
fun queue_of_job f =
237237
let
@@ -636,7 +636,7 @@ in
636636
val typ = read_job_type inp
637637
handle IO.Io _ => cgi_die 500 ["cannot open ",f]
638638
| Option => cgi_die 500 [f," has invalid file format"]
639-
val format_type = if q = "stopped" then span (status_attrs (read_status inp)) else String.concat
639+
val format_type = if q = "finished" then span (status_attrs (read_status inp)) else String.concat
640640
val last_date = if q = "running" then read_last_date inp else NONE
641641
val () = TextIO.closeIn inp
642642
val ago_string =
@@ -788,7 +788,7 @@ in
788788
val (l,r) = Substring.splitAt (Substring.full time_part,6)
789789
val files =
790790
List.map (fn id => OS.Path.concat("running",Int.toString id)) (running()) @
791-
List.map (fn id => OS.Path.concat("stopped",Int.toString id)) (stopped())
791+
List.map (fn id => OS.Path.concat("finished",Int.toString id)) (finished())
792792
val (t,fs) = timings_of_dir dir files
793793
val average = if List.null fs then [] else [" ",duration(Int.quot(t,List.length fs))]
794794
val line = String.concat [

worker.sml

+11-11
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ fun usage_string name = String.concat[
2929
" exit (even without --no-loop).\n",
3030
" --upload id : Assume this worker has just finished job <id> and upload its build\n",
3131
" artefacts (usually automatic after master succeeds), then exit.\n",
32-
" --stop id : Stop job <id>, then exit.\n",
33-
" --abort id : Mark job <id> as having aborted, i.e., stopped without a proper\n",
32+
" --finish id : Mark job <id> as finished, then exit.\n",
33+
" --abort id : Mark job <id> as having aborted, i.e., finished without a proper\n",
3434
" success or failure, then exit.\n",
3535
" --refresh : Refresh the server's waiting queue from GitHub then exit.\n"];
3636

@@ -63,7 +63,7 @@ fun usage_string name = String.concat[
6363
On failure:
6464
1. Append "FAILED: building HOL"
6565
2. Log the captured output
66-
3. Stop the job
66+
3. Finish the job
6767
5. Set up cakeml working directory according to the job snapshot
6868
6. For each directory in the CakeML build sequence
6969
1. Append "Starting <dir>"
@@ -73,10 +73,10 @@ fun usage_string name = String.concat[
7373
On failure:
7474
1. Append "FAILED: <dir>"
7575
2. Log the captured output
76-
3. Stop the job
76+
3. Finish the job
7777
3. Append "Finished <dir>: <time> <memory>"
7878
7. Append "SUCCESS"
79-
8. Stop the job
79+
8. Finish the job
8080
*)
8181

8282
fun warn ls = (
@@ -282,7 +282,7 @@ in
282282
val () = if built then () else
283283
(API.post (Append (id, "FAILED: building HOL"));
284284
API.post (Log(id,capture_file,0));
285-
API.post (Stop id))
285+
API.post (Finish id))
286286
in
287287
built
288288
end
@@ -361,7 +361,7 @@ in
361361
else
362362
(API.post (Append(id,String.concat["FAILED: ",dir]));
363363
API.post (Log(id,capture_file,0));
364-
API.post (Stop id);
364+
API.post (Finish id);
365365
false)
366366
end
367367
val success = loop skip
@@ -370,7 +370,7 @@ in
370370
if success then
371371
let in
372372
API.post (Append(id,"SUCCESS"));
373-
API.post (Stop id)
373+
API.post (Finish id)
374374
end
375375
else ()
376376
in
@@ -488,9 +488,9 @@ fun main () =
488488
val () = arg_job_action "--abort" args (fn jid => fn id => (
489489
diag ["Marking job ", jid, " as aborted."];
490490
API.post (Abort id)))
491-
val () = arg_job_action "--stop" args (fn jid => fn id => (
492-
diag ["Marking job ", jid, " as stopped."];
493-
API.post (Stop id)))
491+
val () = arg_job_action "--finish" args (fn jid => fn id => (
492+
diag ["Marking job ", jid, " as finished."];
493+
API.post (Finish id)))
494494
val () = arg_job_action "--upload" args (fn jid => fn id => (
495495
diag ["Uploading artefacts for job ",jid,"."];
496496
upload_artefacts (mk_CAKEMLDIR jid) id))

0 commit comments

Comments
 (0)