-
Notifications
You must be signed in to change notification settings - Fork 0
/
runAllMeasures
executable file
·66 lines (55 loc) · 2.06 KB
/
runAllMeasures
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
#!/usr/bin/env node
/* eslint-disable no-console */
const { exec } = require('child_process');
const { promisify } = require('util');
const execAsync = promisify(exec);
const yargs = require('yargs');
const cliArgsSpec = {
state: { demand: true, type: 'string' },
year: {
demand: true,
type: 'number',
},
};
const {
argv: { state, year },
} = yargs
.strict()
.parserConfiguration({
'camel-case-expansion': false,
'flatten-duplicate-arrays': false,
})
.wrap(yargs.terminalWidth() / 1.618)
.option(cliArgsSpec);
// const debugFlags = `--head 3`;
const debugFlags = `--head 1`;
// const debugFlags = '';
(async () => {
try {
const runCmds = [
`./run --measures LOTTR TTTR PHED --state ${state} --year ${year} ${debugFlags}`,
`./run --measures PHED PHED_FREEFLOW TED TED_FREEFLOW EMISSIONS --phedNpmrdsDataSource TRUCK --phedFreeflowNpmrdsDataSource ALL TRUCK --tedNpmrdsDataSource ALL TRUCK --tedFreeflowNpmrdsDataSource ALL TRUCK --state ${state} --year ${year} ${debugFlags}`,
`./run --measures PTI TTI PERCENT_BINS_REPORTING SPEED_PERCENTILES FREEFLOW --outputCalculatorsRequiredMetadata false --outputHPMSRequiredTmcMetadata false --timeBinSize 5 --state ${state} --year ${year} ${debugFlags}`,
];
if (state.toLowerCase() === 'ny') {
runCmds.push(
`./run --measures PHED_RIS PHED_FREEFLOW_RIS TED_RIS TED_FREEFLOW_RIS EMISSIONS_RIS --phedRisNpmrdsDataSource ALL TRUCK --tedRisNpmrdsDataSource ALL TRUCK --phedFreeflowRisNpmrdsDataSource ALL TRUCK --tedFreeflowRisNpmrdsDataSource ALL TRUCK --state ${state} --year ${year} ${debugFlags}`,
);
}
const results = await Promise.all(
runCmds.map((cmd) => execAsync(cmd, { cwd: __dirname })),
);
results.forEach((res, i) => {
console.log('--- COMMAND ---');
console.log(runCmds[i]);
console.log('--- STDOUT ---');
console.log(res.stdout);
console.log('--- STDERR ---');
console.log(res.stderr);
console.log();
});
} catch (err) {
console.error(err);
console.error(err.stderr);
}
})();