@rubensworks/process-sparql-benchmark-results 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.md +285 -0
  3. package/bin/psbr +2 -0
  4. package/bin/psbr.d.ts +2 -0
  5. package/bin/psbr.js +6 -0
  6. package/bin/psbr.js.map +1 -0
  7. package/index.d.ts +3 -0
  8. package/index.js +16 -0
  9. package/index.js.map +1 -0
  10. package/index.ts +3 -0
  11. package/lib/TemplateUtils.d.ts +1 -0
  12. package/lib/TemplateUtils.js +35 -0
  13. package/lib/TemplateUtils.js.map +1 -0
  14. package/lib/cli/CliHelpers.d.ts +5 -0
  15. package/lib/cli/CliHelpers.js +87 -0
  16. package/lib/cli/CliHelpers.js.map +1 -0
  17. package/lib/cli/CliRunner.d.ts +1 -0
  18. package/lib/cli/CliRunner.js +24 -0
  19. package/lib/cli/CliRunner.js.map +1 -0
  20. package/lib/cli/ErrorHandled.d.ts +8 -0
  21. package/lib/cli/ErrorHandled.js +15 -0
  22. package/lib/cli/ErrorHandled.js.map +1 -0
  23. package/lib/cli/ITaskContext.d.ts +10 -0
  24. package/lib/cli/ITaskContext.js +3 -0
  25. package/lib/cli/ITaskContext.js.map +1 -0
  26. package/lib/cli/commands/CommandCsv.d.ts +4 -0
  27. package/lib/cli/commands/CommandCsv.js +10 -0
  28. package/lib/cli/commands/CommandCsv.js.map +1 -0
  29. package/lib/cli/commands/CommandStats.d.ts +4 -0
  30. package/lib/cli/commands/CommandStats.js +10 -0
  31. package/lib/cli/commands/CommandStats.js.map +1 -0
  32. package/lib/cli/commands/CommandTex.d.ts +4 -0
  33. package/lib/cli/commands/CommandTex.js +10 -0
  34. package/lib/cli/commands/CommandTex.js.map +1 -0
  35. package/lib/cli/commands/csv/CommandQuery.d.ts +5 -0
  36. package/lib/cli/commands/csv/CommandQuery.js +120 -0
  37. package/lib/cli/commands/csv/CommandQuery.js.map +1 -0
  38. package/lib/cli/commands/csv/CommandSummary.d.ts +5 -0
  39. package/lib/cli/commands/csv/CommandSummary.js +246 -0
  40. package/lib/cli/commands/csv/CommandSummary.js.map +1 -0
  41. package/lib/cli/commands/csv/CommandWins.d.ts +5 -0
  42. package/lib/cli/commands/csv/CommandWins.js +151 -0
  43. package/lib/cli/commands/csv/CommandWins.js.map +1 -0
  44. package/lib/cli/commands/csv/ITableSerializer.d.ts +9 -0
  45. package/lib/cli/commands/csv/ITableSerializer.js +3 -0
  46. package/lib/cli/commands/csv/ITableSerializer.js.map +1 -0
  47. package/lib/cli/commands/csv/TableSerializerCsv.d.ts +10 -0
  48. package/lib/cli/commands/csv/TableSerializerCsv.js +19 -0
  49. package/lib/cli/commands/csv/TableSerializerCsv.js.map +1 -0
  50. package/lib/cli/commands/csv/TableSerializerMarkdown.d.ts +18 -0
  51. package/lib/cli/commands/csv/TableSerializerMarkdown.js +34 -0
  52. package/lib/cli/commands/csv/TableSerializerMarkdown.js.map +1 -0
  53. package/lib/cli/commands/stats/CommandDocker.d.ts +7 -0
  54. package/lib/cli/commands/stats/CommandDocker.js +79 -0
  55. package/lib/cli/commands/stats/CommandDocker.js.map +1 -0
  56. package/lib/cli/commands/tex/CommandQuery.d.ts +5 -0
  57. package/lib/cli/commands/tex/CommandQuery.js +253 -0
  58. package/lib/cli/commands/tex/CommandQuery.js.map +1 -0
  59. package/lib/cli/commands/tex/CommandQueryTimes.d.ts +5 -0
  60. package/lib/cli/commands/tex/CommandQueryTimes.js +153 -0
  61. package/lib/cli/commands/tex/CommandQueryTimes.js.map +1 -0
  62. package/lib/cli/commands/tex/TexUtils.d.ts +34 -0
  63. package/lib/cli/commands/tex/TexUtils.js +149 -0
  64. package/lib/cli/commands/tex/TexUtils.js.map +1 -0
  65. package/lib/correctness/CorrectnessCheckerQueries.d.ts +6 -0
  66. package/lib/correctness/CorrectnessCheckerQueries.js +13 -0
  67. package/lib/correctness/CorrectnessCheckerQueries.js.map +1 -0
  68. package/lib/correctness/CorrectnessCheckerUtils.d.ts +2 -0
  69. package/lib/correctness/CorrectnessCheckerUtils.js +14 -0
  70. package/lib/correctness/CorrectnessCheckerUtils.js.map +1 -0
  71. package/lib/correctness/ICorrectnessChecker.d.ts +3 -0
  72. package/lib/correctness/ICorrectnessChecker.js +3 -0
  73. package/lib/correctness/ICorrectnessChecker.js.map +1 -0
  74. package/lib/templates/tex/plot_query_data.tex +94 -0
  75. package/lib/templates/tex/plot_query_times.tex +75 -0
  76. package/package.json +100 -0
package/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2021–now Ruben Taelman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,285 @@
1
+ # Process SPARQL Benchmark Results
2
+
3
+ [![Build status](https://github.com/rubensworks/process-sparql-benchmark-results.js/workflows/CI/badge.svg)](https://github.com/rubensworks/process-sparql-benchmark-results.js/actions?query=workflow%3ACI)
4
+ [![Coverage Status](https://coveralls.io/repos/github/rubensworks/process-sparql-benchmark-results.js/badge.svg?branch=master)](https://coveralls.io/github/rubensworks/process-sparql-benchmark-results.js?branch=master)
5
+ [![npm version](https://badge.fury.io/js/@rubensworks/sparql-benchmark-runner.svg)](https://www.npmjs.com/package/@rubensworks/sparql-benchmark-runner)
6
+
7
+ This package contains a set of tools to post-process query results from SPARQL benchmarks.
8
+
9
+ Be aware that this is primarily intended for my personal usage.
10
+ So I may be making some assumptions here and there that may not be valuable for everyone.
11
+ Furthermore, code in this package is minimally tested, and breaking changes may occur at any time.
12
+
13
+ Most of these tools work on output produced by [jbr](https://github.com/rubensworks/jbr.js) experiments.
14
+
15
+ ## 1. Installation
16
+
17
+ ```bash
18
+ $ npm install -g @rubensworks/sparql-benchmark-runner
19
+ ```
20
+
21
+ or
22
+
23
+ ```bash
24
+ $ yarn global add @rubensworks/sparql-benchmark-runner
25
+ ```
26
+
27
+ ## 2. Usage
28
+
29
+ After installing this package, the `psbr` CLI tool will become available,
30
+ which consists of a number of sub-commands,
31
+ as explained hereafter.
32
+
33
+ **Full usage**:
34
+ ```text
35
+ psbr <command>
36
+
37
+ Commands:
38
+ psbr csv Creates CSV files
39
+ psbr stats Derive statistics from experiments
40
+ psbr tex Creates a LaTeX TikZ plot file
41
+
42
+ Options:
43
+ --version Show version number [boolean]
44
+ --cwd The current working directory [string] [default: .]
45
+ -v, --verbose If more logging output should be generated [boolean]
46
+ --help Show help
47
+ ```
48
+
49
+ ### 2.1. Create LaTeX TikZ plot files
50
+
51
+ Subcommands of `psbr tex` can create LaTeX TikZ files.
52
+
53
+ #### 2.1.1. Query execution times
54
+
55
+ By invoking `psbr tex query` with any number of experiment directories,
56
+ the `plot_queries_data.tex` and `plot_queries_data.csv` files will be created.
57
+ This TeX files contains a `TikZ` figure, which can be used to generate a vector plot from the CSV data.
58
+
59
+ By default, it will look for the `query-times.csv` file within each experiment directory.
60
+ This file is expected to look as follows:
61
+ ```text
62
+ name;id;results;time;timestamps
63
+ interactive-short-4;0;0;4;
64
+ interactive-short-4;1;0;1;
65
+ interactive-short-5;0;0;0;
66
+ interactive-short-5;1;0;0;
67
+ ```
68
+
69
+ **SVG output**:
70
+
71
+ Optionally, an SVG file can also be created using the `--svg` flag.
72
+
73
+ **Override labels**:
74
+
75
+ If you want to override the labels of experiments or queries, you can do this as follows:
76
+ ```bash
77
+ $ psbr tex query combination_* --overrideCombinationLabels 'a,b,c,d' --overrideQueryLabels 'Q1,Q2'
78
+ ```
79
+
80
+ **Full usage**:
81
+ ```text
82
+ psbr tex query <experiment-dir...>
83
+
84
+ Plot the query execution times from the given experiments
85
+
86
+ Options:
87
+ --version Show version number [boolean]
88
+ --cwd The current working directory
89
+ [string] [default: .]
90
+ -v, --verbose If more logging output should be generated
91
+ [boolean]
92
+ --help Show help [boolean]
93
+ -q, --queryRegex Regex for queries to include (before any
94
+ label overrides). Examples: '^C', '^[^C]',
95
+ ... [string]
96
+ -n, --name Custom output file name
97
+ [string] [default: "plot_queries_data"]
98
+ -c, --color Color scheme name from colorbrewer2.org
99
+ [string]
100
+ --maxY The upper limit of the Y-axis. Defaults to
101
+ maximum Y value [number]
102
+ --legend If a legend should be included
103
+ [boolean] [default: true]
104
+ --legendPos The legend position X,Y (anchor north-east)
105
+ [string] [default: "1.0,1.0"]
106
+ --logY If the Y-Axis must have a log scale
107
+ [boolean] [default: false]
108
+ --inputName Custom input file name per experiment
109
+ [string] [default: "query-times.csv"]
110
+ --inputDelimiter Delimiter for the input CSV file
111
+ [string] [default: ";"]
112
+ --overrideCombinationLabels Comma-separated list of combination labels to
113
+ use [string]
114
+ --overrideQueryLabels Comma-separated list of query labels to use
115
+ [string]
116
+ --svg If the tex file should be converted to svg
117
+ via the tex2svg command
118
+ [boolean] [default: false]
119
+ ```
120
+
121
+ #### 2.1.2. Query result arrival times
122
+
123
+ This command will create a vectorial CSV-based (LaTeX/TiKZ) plot that compares compares the query result arrival times over all given experiments.
124
+ This is useful for comparing the impact of different approaches on query result arrival times.
125
+
126
+ By invoking `psbr tex queryTimes` with any number of experiment directories,
127
+ the `query_times.tex` and `query_times.csv` files will be created.
128
+ This TeX files contains a `TikZ` figure, which can be used to generate a vector plot from the CSV data.
129
+
130
+ By default, it will look for the `query-times.csv` file within each experiment directory.
131
+ This file is expected to look as follows:
132
+ ```text
133
+ name;id;results;time;timestamps
134
+ interactive-short-4;0;0;4;
135
+ interactive-short-4;1;0;1;
136
+ interactive-short-5;0;0;0;
137
+ interactive-short-5;1;0;0;
138
+ ```
139
+
140
+ Optionally, another index of the query can be selected by suffixing the query name with `.index`, such as `psbr tex queryTimes L2.3`.
141
+
142
+ **Full usage**:
143
+ ```text
144
+ psbr tex queryTimes <query> <experiment-dir...>
145
+
146
+ Plot the query result arrival times from the given experiments
147
+
148
+ Options:
149
+ --version Show version number [boolean]
150
+ --cwd The current working directory
151
+ [string] [default: .]
152
+ -v, --verbose If more logging output should be generated
153
+ [boolean]
154
+ --help Show help [boolean]
155
+ -n, --name Custom output file name
156
+ [string] [default: "query_times"]
157
+ -c, --color Color scheme name from colorbrewer2.org
158
+ [string]
159
+ --maxY The upper limit of the Y-axis. Defaults to
160
+ maximum Y value [number]
161
+ --legend If a legend should be included
162
+ [boolean] [default: true]
163
+ --legendPos The legend position X,Y (anchor north-east)
164
+ [string] [default: "1.0,1.0"]
165
+ --logY If the Y-Axis must have a log scale
166
+ [boolean] [default: false]
167
+ --inputName Custom input file name per experiment
168
+ [string] [default: "query-times.csv"]
169
+ --inputDelimiter Delimiter for the input CSV file
170
+ [string] [default: ";"]
171
+ --overrideCombinationLabels Comma-separated list of combination labels to
172
+ use [string]
173
+ --svg If the tex file should be converted to svg
174
+ via the tex2svg command
175
+ [boolean] [default: false]
176
+ ```
177
+
178
+ ### 2.2. Create CSV files
179
+
180
+ Subcommands of `psbr csv` can create CSV files.
181
+
182
+ #### 2.2.1. Summarize query execution times
183
+
184
+ By invoking `psbr csv query` with any number of experiment directories,
185
+ the `data_all.csv` file will be created.
186
+
187
+ By default, it will look for the `query-times.csv` file within each experiment directory.
188
+ This file is expected to look as follows:
189
+ ```text
190
+ name;id;results;time;timestamps
191
+ interactive-short-4;0;0;4;
192
+ interactive-short-4;1;0;1;
193
+ interactive-short-5;0;0;0;
194
+ interactive-short-5;1;0;0;
195
+ ```
196
+
197
+ Concretely, it will output the `data_all.csv` that looks as follows:
198
+ ```csv
199
+ combination;time
200
+ output/combination_0;10963
201
+ output/combination_0;10849
202
+ output/combination_0;11912
203
+ output/combination_1;16320
204
+ output/combination_1;12389
205
+ output/combination_1;11944
206
+ ```
207
+
208
+ You can for example use this data to calculate the statistical different between two combinations in R as follows:
209
+ ```R
210
+ data <- read.csv('./data_all.csv', sep = ';')
211
+
212
+ # Calculate means
213
+ aggregate(data$time, list(data$combination), median)
214
+
215
+ # Compare means with Kruskal-Wallis test (nonparametric, if non-normal distribution)
216
+ kruskal.test(time ~ combination, data = data[which(data$combination=='output/combination_0' | data$combination=='output/combination_1'),])
217
+ # If p < 0.05, combinations have no difference with a significance of 95%.
218
+ # If p > 0.05, combinations are different with a significance of 95%.
219
+ ```
220
+
221
+ **Full usage**:
222
+
223
+ ```text
224
+ psbr csv query <experiment-dir...>
225
+
226
+ Summarize all query execution times from the given experiments
227
+
228
+ Options:
229
+ --version Show version number [boolean]
230
+ --cwd The current working directory [string] [default: .]
231
+ -v, --verbose If more logging output should be generated [boolean]
232
+ --help Show help [boolean]
233
+ -q, --queryRegex Regex for queries to include (before any label
234
+ overrides). Examples: '^C', '^[^C]', ... [string]
235
+ -n, --name Custom output file name
236
+ [string] [default: "data_all.csv"]
237
+ --inputName Custom input file name per experiment
238
+ [string] [default: "query-times.csv"]
239
+ --inputDelimiter Delimiter for the input CSV file [string] [default: ";"]
240
+ ```
241
+
242
+ ### 2.3. Derive statistics
243
+
244
+ Subcommands of `psbr stats` can derive statistics.
245
+
246
+ #### 2.3.1. Summarize Docker stats
247
+
248
+ By invoking `psbr stats docker` with a Docker experimental result file,
249
+ a summary of all its contents will be created.
250
+
251
+ For instance, if a Docker-based experiment may produce a file such as `stats-server.csv`,
252
+ which is expected to look as follows:
253
+ ```text
254
+ cpu_percentage,memory,memory_percentage,received,transmitted
255
+ 0.012520939947780679,122277888,5.856675939622464,882,0
256
+ 0,122228736,5.8543217336372875,882,0
257
+ ```
258
+
259
+ Based on this, the following summary will be printed
260
+ ```csv
261
+ CPU: 0.01 %
262
+ Memory relative: 116.59 MB
263
+ Memory absolute: 5.86 %
264
+ Received: 0.00 MB
265
+ Transmitted: 0.00 MB
266
+ ```
267
+
268
+ **Full usage**:
269
+
270
+ ```text
271
+ psbr stats docker <docker-csv-file>
272
+
273
+ Show the stats of an Docker CSV file from an experiment
274
+
275
+ Options:
276
+ --version Show version number [boolean]
277
+ --cwd The current working directory [string] [default: .]
278
+ -v, --verbose If more logging output should be generated [boolean]
279
+ --help Show help [boolean]
280
+ -d, --digits The precision of output numbers [number] [default: 2]
281
+ ```
282
+
283
+ ## License
284
+ This code is copyrighted by [Ghent University – imec](http://idlab.ugent.be/)
285
+ and released under the [MIT license](http://opensource.org/licenses/MIT).
package/bin/psbr ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('./psbr.js')
package/bin/psbr.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/bin/psbr.js ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const CliRunner_1 = require("../lib/cli/CliRunner");
5
+ CliRunner_1.runCli(process.cwd(), process.argv);
6
+ //# sourceMappingURL=psbr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"psbr.js","sourceRoot":"","sources":["psbr.ts"],"names":[],"mappings":";;;AACA,oDAA8C;AAC9C,kBAAM,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { runCli } from '../lib/cli/CliRunner';\nrunCli(process.cwd(), process.argv);\n"]}
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './lib/cli/CliHelpers';
2
+ export * from './lib/cli/CliRunner';
3
+ export * from './lib/cli/ITaskContext';
package/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./lib/cli/CliHelpers"), exports);
14
+ __exportStar(require("./lib/cli/CliRunner"), exports);
15
+ __exportStar(require("./lib/cli/ITaskContext"), exports);
16
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAqC;AACrC,sDAAoC;AACpC,yDAAuC","sourcesContent":["export * from './lib/cli/CliHelpers';\nexport * from './lib/cli/CliRunner';\nexport * from './lib/cli/ITaskContext';\n"]}
package/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './lib/cli/CliHelpers';
2
+ export * from './lib/cli/CliRunner';
3
+ export * from './lib/cli/ITaskContext';
@@ -0,0 +1 @@
1
+ export declare function instantiateTemplate(templatePath: string, outPath: string, values: Record<string, string | number>, modifier?: (contents: string) => string): Promise<void>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.instantiateTemplate = void 0;
23
+ const fs = __importStar(require("fs-extra"));
24
+ async function instantiateTemplate(templatePath, outPath, values, modifier) {
25
+ let contents = await fs.readFile(templatePath, 'utf8');
26
+ for (const [key, value] of Object.entries(values)) {
27
+ contents = contents.replace(new RegExp(`%${key}%`, 'gu'), typeof value === 'string' ? value : `${value}`);
28
+ }
29
+ if (modifier) {
30
+ contents = modifier(contents);
31
+ }
32
+ await fs.writeFile(outPath, contents);
33
+ }
34
+ exports.instantiateTemplate = instantiateTemplate;
35
+ //# sourceMappingURL=TemplateUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemplateUtils.js","sourceRoot":"","sources":["TemplateUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAExB,KAAK,UAAU,mBAAmB,CACvC,YAAoB,EACpB,OAAe,EACf,MAAuC,EACvC,QAAuC;IAEvC,IAAI,QAAQ,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACvD,KAAK,MAAM,CAAE,GAAG,EAAE,KAAK,CAAE,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACnD,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,GAAG,EAAE,IAAI,CAAC,EACtD,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;KACnD;IACD,IAAI,QAAQ,EAAE;QACZ,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;KAC/B;IACD,MAAM,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC;AAfD,kDAeC","sourcesContent":["import * as fs from 'fs-extra';\n\nexport async function instantiateTemplate(\n templatePath: string,\n outPath: string,\n values: Record<string, string | number>,\n modifier?: (contents: string) => string,\n): Promise<void> {\n let contents = await fs.readFile(templatePath, 'utf8');\n for (const [ key, value ] of Object.entries(values)) {\n contents = contents.replace(new RegExp(`%${key}%`, 'gu'),\n typeof value === 'string' ? value : `${value}`);\n }\n if (modifier) {\n contents = modifier(contents);\n }\n await fs.writeFile(outPath, contents);\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { Logger } from 'winston';
2
+ import type { ITaskContext } from './ITaskContext';
3
+ export declare function wrapCommandHandler(argv: Record<string, any>, handler: (context: ITaskContext) => Promise<void>): Promise<void>;
4
+ export declare function wrapVisualProgress<T>(label: string, handler: () => Promise<T>): Promise<T>;
5
+ export declare function createCliLogger(logLevel: string): Logger;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.createCliLogger = exports.wrapVisualProgress = exports.wrapCommandHandler = void 0;
26
+ const path_1 = __importDefault(require("path"));
27
+ const util = __importStar(require("util"));
28
+ const ora_1 = __importDefault(require("ora"));
29
+ const winston_1 = require("winston");
30
+ async function wrapCommandHandler(argv, handler) {
31
+ const startTime = process.hrtime();
32
+ // Create context
33
+ const context = {
34
+ cwd: argv.cwd,
35
+ verbose: argv.verbose,
36
+ logger: createCliLogger(argv.verbose ? 'verbose' : 'info'),
37
+ templatesRoot: path_1.default.join(__dirname, '..', 'templates'),
38
+ };
39
+ // Run handler
40
+ let completed = false;
41
+ try {
42
+ await handler(context);
43
+ completed = true;
44
+ }
45
+ catch (error) {
46
+ if ('handled' in error) {
47
+ context.logger.error(`${error.message}`);
48
+ }
49
+ else {
50
+ context.logger.error(`${util.format(error)}`);
51
+ }
52
+ }
53
+ finally {
54
+ const endTime = process.hrtime(startTime);
55
+ const seconds = (endTime[0] + endTime[1] / 1000000000).toFixed(2);
56
+ if (completed) {
57
+ context.logger.info(`✨ Done in ${seconds}s`);
58
+ }
59
+ else {
60
+ context.logger.info(`🚨 Errored in ${seconds}s`);
61
+ // eslint-disable-next-line unicorn/no-process-exit
62
+ process.exit(1);
63
+ }
64
+ }
65
+ }
66
+ exports.wrapCommandHandler = wrapCommandHandler;
67
+ async function wrapVisualProgress(label, handler) {
68
+ const spinner = ora_1.default(label).start();
69
+ try {
70
+ return await handler();
71
+ }
72
+ finally {
73
+ spinner.stop();
74
+ }
75
+ }
76
+ exports.wrapVisualProgress = wrapVisualProgress;
77
+ function createCliLogger(logLevel) {
78
+ return winston_1.createLogger({
79
+ level: logLevel,
80
+ format: winston_1.format.combine(winston_1.format.colorize({ all: true, colors: { info: 'white' } }), winston_1.format.timestamp(), winston_1.format.printf(({ message }) => `${message}`)),
81
+ transports: [new winston_1.transports.Console({
82
+ stderrLevels: ['error', 'warn', 'info', 'verbose', 'debug', 'silly'],
83
+ })],
84
+ });
85
+ }
86
+ exports.createCliLogger = createCliLogger;
87
+ //# sourceMappingURL=CliHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliHelpers.js","sourceRoot":"","sources":["CliHelpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,2CAA6B;AAC7B,8CAAsB;AAEtB,qCAA2D;AAGpD,KAAK,UAAU,kBAAkB,CACtC,IAAyB,EACzB,OAAiD;IAEjD,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAEnC,iBAAiB;IACjB,MAAM,OAAO,GAAiB;QAC5B,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;QAC1D,aAAa,EAAE,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC;KACvD,CAAC;IAEF,cAAc;IACd,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAI;QACF,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QACvB,SAAS,GAAG,IAAI,CAAC;KAClB;IAAC,OAAO,KAAc,EAAE;QACvB,IAAI,SAAS,IAAY,KAAM,EAAE;YAC/B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAW,KAAM,CAAC,OAAO,EAAE,CAAC,CAAC;SACnD;aAAM;YACL,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;SAC/C;KACF;YAAS;QACR,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC1C,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,UAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACrE,IAAI,SAAS,EAAE;YACb,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,OAAO,GAAG,CAAC,CAAC;SAC9C;aAAM;YACL,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,OAAO,GAAG,CAAC,CAAC;YACjD,mDAAmD;YACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;KACF;AACH,CAAC;AApCD,gDAoCC;AAEM,KAAK,UAAU,kBAAkB,CAAI,KAAa,EAAE,OAAyB;IAClF,MAAM,OAAO,GAAG,aAAG,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;IACnC,IAAI;QACF,OAAO,MAAM,OAAO,EAAE,CAAC;KACxB;YAAS;QACR,OAAO,CAAC,IAAI,EAAE,CAAC;KAChB;AACH,CAAC;AAPD,gDAOC;AAED,SAAgB,eAAe,CAAC,QAAgB;IAC9C,OAAO,sBAAY,CAAC;QAClB,KAAK,EAAE,QAAQ;QACf,MAAM,EAAE,gBAAM,CAAC,OAAO,CACpB,gBAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAC,CAAC,EACxD,gBAAM,CAAC,SAAS,EAAE,EAClB,gBAAM,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,EAAuB,EAAU,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,CAC1E;QACD,UAAU,EAAE,CAAE,IAAI,oBAAU,CAAC,OAAO,CAAC;gBACnC,YAAY,EAAE,CAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAE;aACvE,CAAC,CAAE;KACL,CAAC,CAAC;AACL,CAAC;AAZD,0CAYC","sourcesContent":["import Path from 'path';\nimport * as util from 'util';\nimport ora from 'ora';\nimport type { Logger } from 'winston';\nimport { createLogger, format, transports } from 'winston';\nimport type { ITaskContext } from './ITaskContext';\n\nexport async function wrapCommandHandler(\n argv: Record<string, any>,\n handler: (context: ITaskContext) => Promise<void>,\n): Promise<void> {\n const startTime = process.hrtime();\n\n // Create context\n const context: ITaskContext = {\n cwd: argv.cwd,\n verbose: argv.verbose,\n logger: createCliLogger(argv.verbose ? 'verbose' : 'info'),\n templatesRoot: Path.join(__dirname, '..', 'templates'),\n };\n\n // Run handler\n let completed = false;\n try {\n await handler(context);\n completed = true;\n } catch (error: unknown) {\n if ('handled' in (<Error>error)) {\n context.logger.error(`${(<Error>error).message}`);\n } else {\n context.logger.error(`${util.format(error)}`);\n }\n } finally {\n const endTime = process.hrtime(startTime);\n const seconds = (endTime[0] + endTime[1] / 1_000_000_000).toFixed(2);\n if (completed) {\n context.logger.info(`✨ Done in ${seconds}s`);\n } else {\n context.logger.info(`🚨 Errored in ${seconds}s`);\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(1);\n }\n }\n}\n\nexport async function wrapVisualProgress<T>(label: string, handler: () => Promise<T>): Promise<T> {\n const spinner = ora(label).start();\n try {\n return await handler();\n } finally {\n spinner.stop();\n }\n}\n\nexport function createCliLogger(logLevel: string): Logger {\n return createLogger({\n level: logLevel,\n format: format.combine(\n format.colorize({ all: true, colors: { info: 'white' }}),\n format.timestamp(),\n format.printf(({ message }: Record<string, any>): string => `${message}`),\n ),\n transports: [ new transports.Console({\n stderrLevels: [ 'error', 'warn', 'info', 'verbose', 'debug', 'silly' ],\n }) ],\n });\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare function runCli(cwd: string, argv: string[]): void;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.runCli = void 0;
7
+ const yargs_1 = __importDefault(require("yargs"));
8
+ const helpers_1 = require("yargs/helpers");
9
+ function runCli(cwd, argv) {
10
+ const { argv: params } = yargs_1.default(helpers_1.hideBin(argv))
11
+ .options({
12
+ cwd: { type: 'string', default: cwd, describe: 'The current working directory', defaultDescription: '.' },
13
+ verbose: {
14
+ type: 'boolean',
15
+ alias: 'v',
16
+ describe: 'If more logging output should be generated',
17
+ },
18
+ })
19
+ .commandDir('commands')
20
+ .demandCommand()
21
+ .help();
22
+ }
23
+ exports.runCli = runCli;
24
+ //# sourceMappingURL=CliRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliRunner.js","sourceRoot":"","sources":["CliRunner.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,2CAAwC;AAExC,SAAgB,MAAM,CAAC,GAAW,EAAE,IAAc;IAChD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,eAAK,CAAC,iBAAO,CAAC,IAAI,CAAC,CAAC;SAC1C,OAAO,CAAC;QACP,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,GAAG,EAAE;QACzG,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,GAAG;YACV,QAAQ,EAAE,4CAA4C;SACvD;KACF,CAAC;SACD,UAAU,CAAC,UAAU,CAAC;SACtB,aAAa,EAAE;SACf,IAAI,EAAE,CAAC;AACZ,CAAC;AAbD,wBAaC","sourcesContent":["import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nexport function runCli(cwd: string, argv: string[]): void {\n const { argv: params } = yargs(hideBin(argv))\n .options({\n cwd: { type: 'string', default: cwd, describe: 'The current working directory', defaultDescription: '.' },\n verbose: {\n type: 'boolean',\n alias: 'v',\n describe: 'If more logging output should be generated',\n },\n })\n .commandDir('commands')\n .demandCommand()\n .help();\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * An error that should be considered a non-programming error,
3
+ * which can be handled by simply printing the message on the CLI.
4
+ */
5
+ export declare class ErrorHandled extends Error {
6
+ readonly handled = true;
7
+ constructor(message: string);
8
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorHandled = void 0;
4
+ /**
5
+ * An error that should be considered a non-programming error,
6
+ * which can be handled by simply printing the message on the CLI.
7
+ */
8
+ class ErrorHandled extends Error {
9
+ constructor(message) {
10
+ super(message);
11
+ this.handled = true;
12
+ }
13
+ }
14
+ exports.ErrorHandled = ErrorHandled;
15
+ //# sourceMappingURL=ErrorHandled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorHandled.js","sourceRoot":"","sources":["ErrorHandled.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,MAAa,YAAa,SAAQ,KAAK;IAGrC,YAAmB,OAAe;QAChC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHD,YAAO,GAAG,IAAI,CAAC;IAI/B,CAAC;CACF;AAND,oCAMC","sourcesContent":["/**\n * An error that should be considered a non-programming error,\n * which can be handled by simply printing the message on the CLI.\n */\nexport class ErrorHandled extends Error {\n public readonly handled = true;\n\n public constructor(message: string) {\n super(message);\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { Logger } from 'winston';
2
+ /**
3
+ * Common data when running a task.
4
+ */
5
+ export interface ITaskContext {
6
+ cwd: string;
7
+ verbose: boolean;
8
+ logger: Logger;
9
+ templatesRoot: string;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ITaskContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ITaskContext.js","sourceRoot":"","sources":["ITaskContext.ts"],"names":[],"mappings":"","sourcesContent":["import type { Logger } from 'winston';\n/**\n * Common data when running a task.\n */\nexport interface ITaskContext {\n cwd: string;\n verbose: boolean;\n logger: Logger;\n templatesRoot: string;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { Argv } from 'yargs';
2
+ export declare const command = "csv";
3
+ export declare const desc = "Creates CSV files";
4
+ export declare const builder: (yargs: Argv<any>) => Argv<any>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builder = exports.desc = exports.command = void 0;
4
+ exports.command = 'csv';
5
+ exports.desc = 'Creates CSV files';
6
+ const builder = (yargs) => yargs
7
+ .commandDir('csv')
8
+ .demandCommand();
9
+ exports.builder = builder;
10
+ //# sourceMappingURL=CommandCsv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandCsv.js","sourceRoot":"","sources":["CommandCsv.ts"],"names":[],"mappings":";;;AAEa,QAAA,OAAO,GAAG,KAAK,CAAC;AAChB,QAAA,IAAI,GAAG,mBAAmB,CAAC;AACjC,MAAM,OAAO,GAAG,CAAC,KAAgB,EAAa,EAAE,CACrD,KAAK;KACF,UAAU,CAAC,KAAK,CAAC;KACjB,aAAa,EAAE,CAAC;AAHR,QAAA,OAAO,WAGC","sourcesContent":["import type { Argv } from 'yargs';\n\nexport const command = 'csv';\nexport const desc = 'Creates CSV files';\nexport const builder = (yargs: Argv<any>): Argv<any> =>\n yargs\n .commandDir('csv')\n .demandCommand();\n"]}
@@ -0,0 +1,4 @@
1
+ import type { Argv } from 'yargs';
2
+ export declare const command = "stats";
3
+ export declare const desc = "Derive statistics from experiments";
4
+ export declare const builder: (yargs: Argv<any>) => Argv<any>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builder = exports.desc = exports.command = void 0;
4
+ exports.command = 'stats';
5
+ exports.desc = 'Derive statistics from experiments';
6
+ const builder = (yargs) => yargs
7
+ .commandDir('stats')
8
+ .demandCommand();
9
+ exports.builder = builder;
10
+ //# sourceMappingURL=CommandStats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandStats.js","sourceRoot":"","sources":["CommandStats.ts"],"names":[],"mappings":";;;AAEa,QAAA,OAAO,GAAG,OAAO,CAAC;AAClB,QAAA,IAAI,GAAG,oCAAoC,CAAC;AAClD,MAAM,OAAO,GAAG,CAAC,KAAgB,EAAa,EAAE,CACrD,KAAK;KACF,UAAU,CAAC,OAAO,CAAC;KACnB,aAAa,EAAE,CAAC;AAHR,QAAA,OAAO,WAGC","sourcesContent":["import type { Argv } from 'yargs';\n\nexport const command = 'stats';\nexport const desc = 'Derive statistics from experiments';\nexport const builder = (yargs: Argv<any>): Argv<any> =>\n yargs\n .commandDir('stats')\n .demandCommand();\n"]}
@@ -0,0 +1,4 @@
1
+ import type { Argv } from 'yargs';
2
+ export declare const command = "tex";
3
+ export declare const desc = "Creates a LaTeX TikZ plot file";
4
+ export declare const builder: (yargs: Argv<any>) => Argv<any>;