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;
83 if (/^status: /.test(message)) {
85 message = message.substr(8);
92 id: logViewer.items.length,
94 timestamp: ts.toLocaleDateString() + " " + ts.toLocaleTimeString(),
103 console.log("Did not parse: " + lines[a]);
109 function sortById(a, b, opt) {
113 if (a["id"] > b["id"]) {
116 if (a["id"] < b["id"]) {
122 function sortByTask(a, b, opt) {
126 if (aa["taskid"] === "" && bb["taskid"] !== "") {
129 if (aa["taskid"] !== "" && bb["taskid"] === "") {
133 if (aa["taskid"] !== "" && bb["taskid"] !== "") {
134 if (aa["taskid"] > bb["taskid"]) {
137 if (aa["taskid"] < bb["taskid"]) {
142 return sortById(a, b, opt);
145 function sortByNode(a, b, opt) {
149 if (aa["node"] === "" && bb["node"] !== "") {
152 if (aa["node"] !== "" && bb["node"] === "") {
156 if (aa["node"] !== "" && bb["node"] !== "") {
157 if (aa["node"] > bb["node"]) {
160 if (aa["node"] < bb["node"]) {
165 if (aa["slot"] !== "" && bb["slot"] !== "") {
166 if (aa["slot"] > bb["slot"]) {
169 if (aa["slot"] < bb["slot"]) {
174 return sortById(a, b, opt);
178 function dumbPluralize(n, s, p) {
179 if (typeof p === 'undefined') {
182 if (n == 0 || n > 1) {
183 return n + " " + (s + p);
189 function generateJobOverview(id, logViewer, taskState) {
192 var first = logViewer.items[1];
193 var last = logViewer.items[logViewer.items.length-1];
197 html += "Started at " + first.values().timestamp;
199 var duration = (last.values().ts.getTime() - first.values().ts.getTime()) / 1000;
205 if (duration >= 3600) {
206 hours = Math.floor(duration / 3600);
207 duration -= (hours * 3600);
209 if (duration >= 60) {
210 minutes = Math.floor(duration / 60);
211 duration -= (minutes * 60);
215 var tcount = taskState.task_count;
217 html += ". " + dumbPluralize(tcount, " task") + " run over ";
219 html += dumbPluralize(hours, " hour");
222 html += " " + dumbPluralize(minutes, " minute");
225 html += " " + dumbPluralize(seconds, " second");
228 html += " using " + dumbPluralize(taskState.nodes.length, " node");
230 html += ". " + dumbPluralize(taskState.complete_count, "task") + " complete";
231 html += ", " + dumbPluralize(taskState.incomplete_count, "task") + " incomplete";
232 html += " (" + dumbPluralize(taskState.failure_count, " failure") + ")";
234 html += ". Finished at " + last.values().timestamp;