Skip to content

Commit

Permalink
Show time elapsed on current dir of running jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
xrchz committed Nov 16, 2017
1 parent bd2a591 commit 202649e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
6 changes: 3 additions & 3 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TODO: Show more information on directories in progress
- Could display the time spent so far (i.e., now - start time)
- Could display the average time spent on this directory in other running/stopped jobs
TODO: Show expected time required for a directory in progress
Can be calculated as the average time for this directory in other
stopped/running jobs

TODO: Add interface to stop jobs. Rethink job categorisation.
Should the job page have a link for cancelling that job?
Expand Down
2 changes: 2 additions & 0 deletions apiLib.sml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ fun read_job_type inp =
else "master"
end

val max_dir_length = 50

datatype status = Pending | Success | Failure | Aborted

fun read_status inp =
Expand Down
25 changes: 19 additions & 6 deletions serverLib.sml
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ structure HTML = struct
"for (var i = 0; i < ls.length; i++) {",
"if (ls[i].getAttribute('class') == 'ago') {",
"ls[i].innerHTML = ' [' + moment(ls[i].getAttribute('datetime')).fromNow() + ']';}",
"else if (ls[i].getAttribute('class') == 'since') {",
"ls[i].innerHTML = '[elapsed: ' + moment(ls[i].getAttribute('datetime')).fromNow(true) + ']';}",
"else if (all) {",
"ls[i].innerHTML = moment(ls[i].getAttribute('datetime')).format('",
pretty_date_moment,"');}}}"]
Expand Down Expand Up @@ -776,20 +778,31 @@ in
format_rusage (Substring.string rest),
"\n"]
end handle Option => escape s
fun elapsed_time (acc as (dir_part::time_part::rest)) =
let in let
val prefix = " Starting "
val dir = extract_prefix_trimr prefix dir_part
(* val pad = CharVector.tabulate(max_dir_length - String.size dir,(fn _ => #" ")) *)
val (l,r) = Substring.splitAt (Substring.full time_part,6)
val line = String.concat [
time_part, prefix, dir, " ",
Substring.string l, "class='since' ", Substring.string r, "\n" ]
in
line :: rest
end handle Option => acc | Subscript => acc end
| elapsed_time acc = acc
fun loop acc =
let
val line = read_line()
in
let
val (date,rest) = ReadJSON.bare_read_date (Substring.full line)
val line =
String.concat
[time date,
format_log_line (Substring.string rest)]
val acc = time date :: acc
val acc = format_log_line (Substring.string rest) :: acc
in
loop (line::acc)
loop acc
end handle Option => escape (TextIO.inputAll inp) :: acc
end handle Option => acc
end handle Option => elapsed_time acc
in
String.concat(List.rev (loop acc)) before
TextIO.closeIn inp
Expand Down
1 change: 0 additions & 1 deletion worker.sml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ fun upload id f =
local
val resume_file = "resume"
val time_options = String.concat["--format='%e %M' --output='",timing_file,"'"]
val max_dir_length = 50
fun pad dir =
let
val z = String.size dir
Expand Down

0 comments on commit 202649e

Please sign in to comment.