1 function newTaskState() {
2 return {"complete_count": 0,
9 function addToLogViewer(logViewer, lines, taskState) {
10 var re = /((\d\d\d\d)-(\d\d)-(\d\d))_((\d\d):(\d\d):(\d\d)) ([a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{15}) (\d+) (\d+)? (.*)/;
11 for (var a in lines) {
12 var v = lines[a].match(re);
15 var ts = new Date(Date.UTC(v[2], v[3], v[4], v[6], v[7], v[8]));
18 if (typeof v[11] === 'undefined') {
29 if (!taskState.hasOwnProperty(v11)) {
31 taskState.task_count += 1;
34 if (/^stderr /.test(message)) {
35 message = message.substr(7);
36 if (/^crunchstat: /.test(message)) {
38 message = message.substr(12);
39 } else if (/^srun: /.test(message) || /^slurmd/.test(message)) {
40 type = "task-dispatch";
46 if (m = /^success in (\d+) second/.exec(message)) {
47 taskState[v11].outcome = "success";
48 taskState[v11].runtime = Number(m[1]);
49 taskState.complete_count += 1;
50 console.log(taskState[v11].runtime);
52 else if (m = /^failure \(\#\d+, (temporary|permanent)\) after (\d+) second/.exec(message)) {
53 taskState[v11].outcome = "failure";
54 taskState[v11].runtime = Number(m[2]);
55 taskState.failure_count += 1;
56 if (m[1] == "permanent") {
57 taskState.incomplete_count += 1;
59 console.log(taskState[v11].runtime);
61 else if (m = /^child \d+ started on ([^.]*)\.(\d+)/.exec(message)) {
62 taskState[v11].node = m[1];
63 taskState[v11].slot = m[2];
64 if (taskState.nodes.indexOf(m[1], 0) == -1) {
65 taskState.nodes.push(m[1]);
67 for (var i in logViewer.items) {
69 var val = logViewer.items[i].values();
70 if (val.taskid === v11) {
73 logViewer.items[i].values(val);
78 type = "task-dispatch";
80 node = taskState[v11].node;
81 slot = taskState[v11].slot;
87 id: logViewer.items.length,
89 timestamp: ts.toLocaleDateString() + " " + ts.toLocaleTimeString(),
98 console.log("Did not parse: " + lines[a]);
104 function sortById(a, b, opt) {
108 if (a["id"] > b["id"]) {
111 if (a["id"] < b["id"]) {
117 function sortByTask(a, b, opt) {
121 if (aa["taskid"] === "" && bb["taskid"] !== "") {
124 if (aa["taskid"] !== "" && bb["taskid"] === "") {
128 if (aa["taskid"] !== "" && bb["taskid"] !== "") {
129 if (aa["taskid"] > bb["taskid"]) {
132 if (aa["taskid"] < bb["taskid"]) {
137 return sortById(a, b, opt);
140 function sortByNode(a, b, opt) {
144 if (aa["node"] === "" && bb["node"] !== "") {
147 if (aa["node"] !== "" && bb["node"] === "") {
151 if (aa["node"] !== "" && bb["node"] !== "") {
152 if (aa["node"] > bb["node"]) {
155 if (aa["node"] < bb["node"]) {
160 if (aa["slot"] !== "" && bb["slot"] !== "") {
161 if (aa["slot"] > bb["slot"]) {
164 if (aa["slot"] < bb["slot"]) {
169 return sortById(a, b, opt);
173 function dumbPluralize(n, s, p) {
174 if (typeof p === 'undefined') {
177 if (n == 0 || n > 1) {
178 return n + " " + (s + p);
184 function generateJobOverview(id, logViewer, taskState) {
187 var first = logViewer.items[1];
188 var last = logViewer.items[logViewer.items.length-1];
192 html += "Started at " + first.values().timestamp;
194 var duration = (last.values().ts.getTime() - first.values().ts.getTime()) / 1000;
200 if (duration >= 3600) {
201 hours = Math.floor(duration / 3600);
202 duration -= (hours * 3600);
204 if (duration >= 60) {
205 minutes = Math.floor(duration / 60);
206 duration -= (minutes * 60);
210 var tcount = taskState.task_count;
212 html += ". Ran " + dumbPluralize(tcount, " task") + " over ";
214 html += dumbPluralize(hours, " hour");
217 html += " " + dumbPluralize(minutes, " minute");
220 html += " " + dumbPluralize(seconds, " second");
223 html += " using " + dumbPluralize(taskState.nodes.length, " node");
225 html += ". " + dumbPluralize(taskState.complete_count, "task") + " completed";
226 html += ", " + dumbPluralize(taskState.incomplete_count, "task") + " incomplete";
227 html += " (" + dumbPluralize(taskState.failure_count, " failure") + ")";
229 html += ". Finished at " + last.values().timestamp + ".";