-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhflow-info
executable file
·67 lines (53 loc) · 1.96 KB
/
hflow-info
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env node
var fs = require('fs'),
docopt = require('docopt').docopt;
var doc = "\
hflow-info: print information about a workflow\n\
Usage:\n\
hflow-info <workflow.json path> [--print] [-p <metis_partition_file>] [-f <file_dir>]\n\
[--add-input-flags]\n\
hflow-info -h|--help\n\
\
Options:\n\
-h --help Prints this\n\
--print Print output workflow json (to stderr)\n\
-p <partition_file> Add partitioning info based on partitioning file generated by metis\n\
-f <file_dir> Add information about worklow files which are stored in <file_dir>\n\
--add-input-flags Mark workflow inputs (in `signals' array) with `workflow_input: true` flag";
var opts = docopt(doc);
var sn = opts['--sn'];
var file = opts['<workflow.json path>'];
var partFile = opts['-p'];
var fileDir = opts['-f'];
var fileContents = fs.readFileSync(file);
var wf = JSON.parse(fileContents);
var partmap;
if (partFile) {
try {
let partfilecontent = fs.readFileSync(partFile, 'utf8');
partmap = partfilecontent.split("\n");
} catch(err) {
console.log("Error reading partition file", err);
}
}
wfinfo = require('./wfinfo.js')(wf, partmap, fileDir);
var procNames = {};
wf.processes.forEach(function(proc, idx) {
procNames[proc.name]=(procNames[proc.name] || 0)+1;
});
if (opts['--add-input-flags']) {
wf.ins.forEach(function(input) {
wf.signals[input].workflow_input = true;
});
}
if (opts['--print']) {
console.error(JSON.stringify(wfinfo.wfjson, null, 2));
}
console.log("workflow:", wf.name);
console.log("processes:", wf.processes.length);
Object.keys(procNames).forEach(p => (console.log(" " + p + ": " + procNames[p])));
console.log("signals:", wf.signals.length);
console.log("levels:", wfinfo.nLevels, "[" + wfinfo.levelCounts + "]");
if (wfinfo.partitioningPerPhase) {
console.log("partitioning (per graph level):", wfinfo.partitioningPerPhase);
}