@eagleoutice/flowr 2.10.10 → 2.11.0
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.
- package/README.md +37 -29
- package/cli/common/options.d.ts +2 -108
- package/cli/common/options.js +3 -27
- package/cli/common/scripts-info.d.ts +2 -123
- package/cli/common/scripts-info.js +0 -17
- package/cli/flowr-main-options.d.ts +5 -0
- package/cli/flowr-main-options.js +10 -0
- package/cli/flowr.js +1 -1
- package/cli/repl/print-version.d.ts +3 -1
- package/cli/repl/print-version.js +21 -2
- package/cli/repl/server/connection.d.ts +2 -0
- package/cli/repl/server/connection.js +40 -31
- package/cli/script-core/summarizer-core.js +13 -32
- package/cli/wiki.d.ts +2 -1
- package/cli/wiki.js +2 -0
- package/config.d.ts +13 -0
- package/config.js +8 -0
- package/control-flow/semantic-cfg-guided-visitor.js +1 -0
- package/core/steps/pipeline/default-pipelines.d.ts +146 -146
- package/data/pkgdb/pkgdb-latest.json.br +0 -0
- package/data/pkgdb/pkgdb-tiny.json.br +0 -0
- package/dataflow/environments/append.d.ts +1 -2
- package/dataflow/environments/append.js +3 -10
- package/dataflow/environments/apply-kill.d.ts +21 -0
- package/dataflow/environments/apply-kill.js +155 -0
- package/dataflow/environments/built-in-proc-name.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.js +2 -0
- package/dataflow/environments/built-in.d.ts +2 -0
- package/dataflow/environments/built-in.js +2 -0
- package/dataflow/environments/default-builtin-config.d.ts +63 -3
- package/dataflow/environments/default-builtin-config.js +40 -8
- package/dataflow/environments/environment.d.ts +49 -32
- package/dataflow/environments/environment.js +133 -18
- package/dataflow/environments/identifier.d.ts +10 -0
- package/dataflow/environments/identifier.js +23 -0
- package/dataflow/environments/overwrite.js +2 -10
- package/dataflow/environments/resolve-by-name.d.ts +1 -1
- package/dataflow/environments/resolve-by-name.js +10 -2
- package/dataflow/environments/scoping.d.ts +9 -2
- package/dataflow/environments/scoping.js +15 -2
- package/dataflow/extractor.js +23 -2
- package/dataflow/graph/df-helper.d.ts +8 -0
- package/dataflow/graph/df-helper.js +8 -0
- package/dataflow/graph/graph.d.ts +4 -1
- package/dataflow/graph/graph.js +5 -1
- package/dataflow/info.d.ts +26 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +7 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +9 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +30 -47
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +17 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +8 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +37 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +391 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +131 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +25 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +94 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +10 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +30 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +279 -0
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +17 -0
- package/documentation/data/faq/faqs.js +3 -0
- package/documentation/data/interface/doc-writing-code.js +4 -80
- package/documentation/doc-util/doc-structure.js +1 -2
- package/documentation/wiki-core.js +2 -1
- package/documentation/wiki-dataflow-graph.js +35 -1
- package/documentation/wiki-interface.js +3 -2
- package/documentation/wiki-linter.js +2 -0
- package/documentation/wiki-overview.js +1 -14
- package/documentation/wiki-package-database.d.ts +9 -0
- package/documentation/wiki-package-database.js +63 -0
- package/documentation/wiki-query.js +1 -0
- package/linter/linter-rules.d.ts +23 -0
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-path.js +2 -1
- package/linter/rules/undefined-symbol.d.ts +39 -0
- package/linter/rules/undefined-symbol.js +80 -0
- package/package.json +3 -4
- package/project/cache/flowr-analyzer-cache.d.ts +2 -0
- package/project/cache/flowr-analyzer-cache.js +9 -1
- package/project/context/flowr-analyzer-dependencies-context.d.ts +16 -8
- package/project/context/flowr-analyzer-dependencies-context.js +36 -4
- package/project/context/flowr-analyzer-environment-context.d.ts +2 -4
- package/project/context/flowr-analyzer-environment-context.js +3 -4
- package/project/context/flowr-analyzer-files-context.d.ts +1 -0
- package/project/context/flowr-file.d.ts +2 -0
- package/project/context/flowr-file.js +2 -0
- package/project/flowr-analyzer-builder.js +3 -0
- package/project/flowr-analyzer.d.ts +2 -1
- package/project/flowr-analyzer.js +3 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +13 -15
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +36 -13
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +27 -0
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +41 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +18 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +62 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +63 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +174 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +6 -0
- package/project/plugins/package-version-plugins/package.d.ts +3 -0
- package/project/plugins/package-version-plugins/package.js +12 -0
- package/project/plugins/package-version-plugins/pkgdb.d.ts +133 -0
- package/project/plugins/package-version-plugins/pkgdb.js +370 -0
- package/project/plugins/plugin-registry.d.ts +4 -1
- package/project/plugins/plugin-registry.js +7 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +8 -0
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -0
- package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +8 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +31 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +3 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +3 -2
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +1 -1
- package/queries/catalog/dependencies-query/function-info/other-path-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/other-path-functions.js +27 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -4
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +3 -1
- package/queries/catalog/linter-query/linter-query-executor.js +1 -0
- package/r-bridge/data/data.d.ts +2 -2
- package/r-bridge/data/data.js +2 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +13 -4
- package/search/search-executor/search-enrichers.d.ts +1 -1
- package/search/search-executor/search-enrichers.js +7 -4
- package/util/mermaid/mermaid.d.ts +4 -0
- package/util/mermaid/mermaid.js +8 -1
- package/util/version.js +10 -2
- package/cli/common/features.d.ts +0 -9
- package/cli/common/features.js +0 -35
- package/cli/script-core/statistics-core.d.ts +0 -6
- package/cli/script-core/statistics-core.js +0 -104
- package/cli/script-core/statistics-helper-core.d.ts +0 -6
- package/cli/script-core/statistics-helper-core.js +0 -86
- package/cli/statistics-app.d.ts +0 -11
- package/cli/statistics-app.js +0 -16
- package/cli/statistics-helper-app.d.ts +0 -11
- package/cli/statistics-helper-app.js +0 -14
- package/statistics/features/common-syntax-probability.d.ts +0 -38
- package/statistics/features/common-syntax-probability.js +0 -169
- package/statistics/features/feature.d.ts +0 -179
- package/statistics/features/feature.js +0 -38
- package/statistics/features/post-processing.d.ts +0 -18
- package/statistics/features/post-processing.js +0 -26
- package/statistics/features/supported/assignments/assignments.d.ts +0 -12
- package/statistics/features/supported/assignments/assignments.js +0 -56
- package/statistics/features/supported/assignments/post-process.d.ts +0 -6
- package/statistics/features/supported/assignments/post-process.js +0 -126
- package/statistics/features/supported/comments/comments.d.ts +0 -18
- package/statistics/features/supported/comments/comments.js +0 -143
- package/statistics/features/supported/comments/post-process.d.ts +0 -6
- package/statistics/features/supported/comments/post-process.js +0 -51
- package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
- package/statistics/features/supported/control-flow/control-flow.js +0 -69
- package/statistics/features/supported/control-flow/post-process.d.ts +0 -6
- package/statistics/features/supported/control-flow/post-process.js +0 -66
- package/statistics/features/supported/data-access/data-access.d.ts +0 -15
- package/statistics/features/supported/data-access/data-access.js +0 -122
- package/statistics/features/supported/data-access/post-process.d.ts +0 -6
- package/statistics/features/supported/data-access/post-process.js +0 -108
- package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -34
- package/statistics/features/supported/defined-functions/defined-functions.js +0 -145
- package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/defined-functions/post-process.js +0 -168
- package/statistics/features/supported/expression-list/post-process.d.ts +0 -6
- package/statistics/features/supported/expression-list/post-process.js +0 -45
- package/statistics/features/supported/expression-list/statistics-expression-list.d.ts +0 -9
- package/statistics/features/supported/expression-list/statistics-expression-list.js +0 -37
- package/statistics/features/supported/loops/loops.d.ts +0 -20
- package/statistics/features/supported/loops/loops.js +0 -81
- package/statistics/features/supported/loops/post-process.d.ts +0 -6
- package/statistics/features/supported/loops/post-process.js +0 -73
- package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/used-functions/post-process.js +0 -176
- package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
- package/statistics/features/supported/used-functions/used-functions.js +0 -99
- package/statistics/features/supported/used-packages/post-process.d.ts +0 -6
- package/statistics/features/supported/used-packages/post-process.js +0 -122
- package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
- package/statistics/features/supported/used-packages/used-packages.js +0 -140
- package/statistics/features/supported/values/post-process.d.ts +0 -6
- package/statistics/features/supported/values/post-process.js +0 -73
- package/statistics/features/supported/values/values.d.ts +0 -14
- package/statistics/features/supported/values/values.js +0 -111
- package/statistics/features/supported/variables/post-process.d.ts +0 -15
- package/statistics/features/supported/variables/post-process.js +0 -126
- package/statistics/features/supported/variables/variables.d.ts +0 -15
- package/statistics/features/supported/variables/variables.js +0 -62
- package/statistics/meta-statistics.d.ts +0 -32
- package/statistics/meta-statistics.js +0 -16
- package/statistics/output/file-provider.d.ts +0 -36
- package/statistics/output/file-provider.js +0 -96
- package/statistics/output/print-stats.d.ts +0 -29
- package/statistics/output/print-stats.js +0 -81
- package/statistics/output/statistics-file.d.ts +0 -36
- package/statistics/output/statistics-file.js +0 -68
- package/statistics/statistics.d.ts +0 -29
- package/statistics/statistics.js +0 -108
- package/statistics/summarizer/auto-detect.d.ts +0 -5
- package/statistics/summarizer/auto-detect.js +0 -34
- package/statistics/summarizer/first-phase/process.d.ts +0 -6
- package/statistics/summarizer/first-phase/process.js +0 -81
- package/statistics/summarizer/post-process/clusterer.d.ts +0 -25
- package/statistics/summarizer/post-process/clusterer.js +0 -40
- package/statistics/summarizer/post-process/file-based-count.d.ts +0 -16
- package/statistics/summarizer/post-process/file-based-count.js +0 -47
- package/statistics/summarizer/post-process/histogram.d.ts +0 -57
- package/statistics/summarizer/post-process/histogram.js +0 -126
- package/statistics/summarizer/post-process/post-process-output.d.ts +0 -14
- package/statistics/summarizer/post-process/post-process-output.js +0 -102
- package/statistics/summarizer/second-phase/process.d.ts +0 -15
- package/statistics/summarizer/second-phase/process.js +0 -118
- package/statistics/summarizer/summarizer.d.ts +0 -34
- package/statistics/summarizer/summarizer.js +0 -141
|
@@ -1,126 +0,0 @@
|
|
|
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.histogramsFromClusters = histogramsFromClusters;
|
|
7
|
-
exports.histogramFromNumbers = histogramFromNumbers;
|
|
8
|
-
exports.histograms2table = histograms2table;
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const bimap_1 = require("../../../util/collections/bimap");
|
|
11
|
-
const defaultmap_1 = require("../../../util/collections/defaultmap");
|
|
12
|
-
const assert_1 = require("../../../util/assert");
|
|
13
|
-
const summarizer_1 = require("../../../util/summarizer");
|
|
14
|
-
const arrays_1 = require("../../../util/collections/arrays");
|
|
15
|
-
/**
|
|
16
|
-
* Produces column-wise histogram-information based on a {@link ClusterReport}.
|
|
17
|
-
*
|
|
18
|
-
* Let's suppose you want histograms for the Assignments feature.
|
|
19
|
-
* By default, for each clustered value, a histogram is produced (can be configured by `filter`).
|
|
20
|
-
* @param report - The report to collect histogram information from
|
|
21
|
-
* @param binSize - Size of each bin (see {@link histogramFromNumbers} for details on why we do not specify the bin-count)
|
|
22
|
-
* @param relateValuesToNumberOfLines - If true, each value (like `<-` appeared in file 'x' exactly `N` times) will be divided by the number of lines in the file 'x'.
|
|
23
|
-
* @param filter - If given, only produce histograms for the given values
|
|
24
|
-
*/
|
|
25
|
-
function histogramsFromClusters(report, binSize, relateValuesToNumberOfLines, ...filter) {
|
|
26
|
-
const contexts = [...report.valueInfoMap.entries()];
|
|
27
|
-
const filenameFromId = new bimap_1.BiMap(report.contextIdMap.entries());
|
|
28
|
-
// first, we collect the number of appearances for each value
|
|
29
|
-
const valueCounts = new defaultmap_1.DefaultMap(() => []);
|
|
30
|
-
for (const id of report.contextIdMap.values()) {
|
|
31
|
-
// calculate the number of lines within the file given by the id
|
|
32
|
-
const filename = filenameFromId.getKey(id);
|
|
33
|
-
(0, assert_1.guard)(filename !== undefined, `filename for id ${id} is undefined`);
|
|
34
|
-
const numberOfLines = relateValuesToNumberOfLines ? fs_1.default.readFileSync(filename, 'utf-8').split('\n').length : 1;
|
|
35
|
-
for (const [value, counts] of contexts) {
|
|
36
|
-
valueCounts.get(value).push(counts.get(id) / numberOfLines);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return [...valueCounts.entries()].map(([name, counts]) => filter.length === 0 || filter.includes(name) ? histogramFromNumbers(name, binSize, counts) : undefined).filter(assert_1.isNotUndefined);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Produces a histogram from a list of numbers.
|
|
43
|
-
* Because we need to create several histograms of different datasets and want to compare them, we do not accept the
|
|
44
|
-
* number of bins desired and calculate the bin-size from the data (via `Math.ceil((max - min + 1) / bins)`).
|
|
45
|
-
* Instead, we require the bin-size to be given.
|
|
46
|
-
* There *always* will be an extra bin for the minimum value.
|
|
47
|
-
*/
|
|
48
|
-
function histogramFromNumbers(name, binSize, values) {
|
|
49
|
-
(0, assert_1.guard)(binSize > 0, `binSize must be greater than 0, but was ${binSize}`);
|
|
50
|
-
(0, assert_1.guard)(values.length > 0, 'values must not be empty');
|
|
51
|
-
const summarized = (0, summarizer_1.summarizeMeasurement)(values);
|
|
52
|
-
const numberOfBins = Math.ceil((summarized.max - summarized.min + 1) / binSize) + 1;
|
|
53
|
-
const histogram = new Array(numberOfBins).fill(0);
|
|
54
|
-
for (const v of values) {
|
|
55
|
-
const bin = v === summarized.min ? 0 : Math.floor((v - summarized.min) / binSize) + 1;
|
|
56
|
-
histogram[bin]++;
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
name: name,
|
|
60
|
-
bins: histogram,
|
|
61
|
-
binSize,
|
|
62
|
-
...summarized
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Takes an array of histograms created by {@link histogramFromNumbers} and produces a CSV table from it.
|
|
67
|
-
* They must have the same bin-size for this function to work.
|
|
68
|
-
*
|
|
69
|
-
* The table has the following columns:
|
|
70
|
-
* - `bin` - The corresponding bin number
|
|
71
|
-
* - `from` - The exclusive lower bound of the bin
|
|
72
|
-
* - `to` - The inclusive upper bound of the bin
|
|
73
|
-
* - a column with the name of each histogram, containing its count of values in the corresponding bin
|
|
74
|
-
* @param histograms - The histogram to convert (assumed to have the same ranges and bins)
|
|
75
|
-
* @param countAsDensity - If true, the count is divided by the total number of values (individually for each histogram, similar to pgfplots `hist/density` option)
|
|
76
|
-
*/
|
|
77
|
-
function histograms2table(histograms, countAsDensity = false) {
|
|
78
|
-
(0, assert_1.guard)(histograms.length > 0, 'there must be at least one histogram to convert to a table');
|
|
79
|
-
const mostBins = guardForLargestBinSize(histograms);
|
|
80
|
-
const header = ['bin', 'from', 'to', ...histograms.map(h => JSON.stringify(h.name))];
|
|
81
|
-
const sums = histograms.map(h => (0, arrays_1.arraySum)(h.bins));
|
|
82
|
-
const rows = [];
|
|
83
|
-
for (let binIndex = 0; binIndex < mostBins; binIndex++) {
|
|
84
|
-
const row = new Array(histograms.length + 3);
|
|
85
|
-
row[0] = String(binIndex);
|
|
86
|
-
if (binIndex === 0) {
|
|
87
|
-
row[1] = histograms[0].min.toFixed(3);
|
|
88
|
-
row[2] = histograms[0].min.toFixed(3);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
row[1] = String((binIndex - 1) * histograms[0].binSize + histograms[0].min);
|
|
92
|
-
row[2] = String((binIndex) * histograms[0].binSize + histograms[0].min);
|
|
93
|
-
}
|
|
94
|
-
// fill remaining columns
|
|
95
|
-
writeRoResultsForHistograms(histograms, binIndex, row, countAsDensity, sums);
|
|
96
|
-
rows.push(row);
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
header: header,
|
|
100
|
-
rows: rows
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function guardForLargestBinSize(histograms) {
|
|
104
|
-
const first = histograms[0];
|
|
105
|
-
let mostBins = first.bins.length;
|
|
106
|
-
for (let i = 1; i < histograms.length; i++) {
|
|
107
|
-
(0, assert_1.guard)(histograms[i].binSize === first.binSize, `histograms must have the same bin-size, but ${histograms[i].name} has ${histograms[i].binSize} instead of ${first.binSize}`);
|
|
108
|
-
if (histograms[i].bins.length > mostBins) {
|
|
109
|
-
mostBins = histograms[i].bins.length;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return mostBins;
|
|
113
|
-
}
|
|
114
|
-
function writeRoResultsForHistograms(histograms, binIndex, row, countAsDensity, sums) {
|
|
115
|
-
for (let j = 0; j < histograms.length; j++) {
|
|
116
|
-
const bins = histograms[j].bins;
|
|
117
|
-
// does not have to be performant...
|
|
118
|
-
if (binIndex >= bins.length) {
|
|
119
|
-
row[j + 3] = '0'; /* in a histogram, 0 is the best default value for bins that are not present -- no value appeared in the corresponding bin */
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
row[j + 3] = String(countAsDensity ? bins[binIndex] / sums[j] : bins[binIndex]);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
//# sourceMappingURL=histogram.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type ClusterReport } from './clusterer';
|
|
2
|
-
import { type FeatureSelection } from '../../features/feature';
|
|
3
|
-
/**
|
|
4
|
-
* Post process the collections in a given folder, reducing them in a memory preserving way.
|
|
5
|
-
* @param filepath - Path to the root file of the data collection like `statistics-out/top-2023-01-01-00-00-00/`
|
|
6
|
-
* @param features - Collection of features to post process, expects corresponding folders to exist
|
|
7
|
-
* @returns non-aggregated reports for each sub-key of each feature
|
|
8
|
-
*/
|
|
9
|
-
export declare function postProcessFeatureFolder(filepath: string, features: FeatureSelection): ClusterReport[];
|
|
10
|
-
/**
|
|
11
|
-
* Prints the report to the console, but limits the output to the `limit` entries with the highest counts.
|
|
12
|
-
* The names of these entries (like `->`) are returned, so they can be used to filter the following histograms.
|
|
13
|
-
*/
|
|
14
|
-
export declare function printClusterReport(report: ClusterReport, limit?: number): string[];
|
|
@@ -1,102 +0,0 @@
|
|
|
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.postProcessFeatureFolder = postProcessFeatureFolder;
|
|
7
|
-
exports.printClusterReport = printClusterReport;
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const clusterer_1 = require("./clusterer");
|
|
11
|
-
const log_1 = require("../../../util/log");
|
|
12
|
-
const defaultmap_1 = require("../../../util/collections/defaultmap");
|
|
13
|
-
const ansi_1 = require("../../../util/text/ansi");
|
|
14
|
-
const feature_1 = require("../../features/feature");
|
|
15
|
-
const decorate_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/decorate");
|
|
16
|
-
const file_provider_1 = require("../../output/file-provider");
|
|
17
|
-
const arrays_1 = require("../../../util/collections/arrays");
|
|
18
|
-
/**
|
|
19
|
-
* Post process the collections in a given folder, reducing them in a memory preserving way.
|
|
20
|
-
* @param filepath - Path to the root file of the data collection like `statistics-out/top-2023-01-01-00-00-00/`
|
|
21
|
-
* @param features - Collection of features to post process, expects corresponding folders to exist
|
|
22
|
-
* @returns non-aggregated reports for each sub-key of each feature
|
|
23
|
-
*/
|
|
24
|
-
function postProcessFeatureFolder(filepath, features) {
|
|
25
|
-
if (!fs_1.default.existsSync(filepath)) {
|
|
26
|
-
log_1.log.warn(`Folder for ${filepath} does not exist, skipping post processing`);
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
const results = [];
|
|
30
|
-
for (const feature of features) {
|
|
31
|
-
const result = processFeatureFolder(filepath, feature);
|
|
32
|
-
if (result.length > 0) {
|
|
33
|
-
results.push(...result);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return results;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Process a single feature folder like `Assignments/`
|
|
40
|
-
* @param filepath - Same as the input to {@link postProcessFeatureFolder}
|
|
41
|
-
* @param feature - The (single) feature to process
|
|
42
|
-
*/
|
|
43
|
-
function processFeatureFolder(filepath, feature) {
|
|
44
|
-
const featureInfo = feature_1.ALL_FEATURES[feature];
|
|
45
|
-
const targetPath = path_1.default.join(filepath, featureInfo.name);
|
|
46
|
-
if (!fs_1.default.existsSync(targetPath)) {
|
|
47
|
-
log_1.log.warn(`Folder for ${feature} does not exist at ${targetPath} skipping post processing of this feature`);
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
50
|
-
log_1.log.info(`Processing ${feature} at ${targetPath}`);
|
|
51
|
-
const contextIdMap = new defaultmap_1.DefaultMap((0, decorate_1.deterministicCountingIdGenerator)());
|
|
52
|
-
const featureSubKeys = Object.keys(featureInfo.initialValue);
|
|
53
|
-
const reports = [];
|
|
54
|
-
for (const subKey of featureSubKeys) {
|
|
55
|
-
const value = processFeatureSubKey(targetPath, subKey, contextIdMap);
|
|
56
|
-
if (value !== undefined) {
|
|
57
|
-
reports.push(value);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return reports;
|
|
61
|
-
}
|
|
62
|
-
function processFeatureSubKey(featurePath, subKey, contextIdMap) {
|
|
63
|
-
const targetPath = path_1.default.join(featurePath, `${subKey}${file_provider_1.defaultStatisticsFileSuffix}`);
|
|
64
|
-
if (!fs_1.default.existsSync(targetPath)) {
|
|
65
|
-
log_1.log.warn(`Folder for ${subKey} does not exist at ${targetPath} skipping post processing of this key`);
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
return (0, clusterer_1.clusterStatisticsOutput)(targetPath, contextIdMap);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Prints the report to the console, but limits the output to the `limit` entries with the highest counts.
|
|
72
|
-
* The names of these entries (like `->`) are returned, so they can be used to filter the following histograms.
|
|
73
|
-
*/
|
|
74
|
-
function printClusterReport(report, limit = 1000) {
|
|
75
|
-
console.log('\n\n\n');
|
|
76
|
-
console.log(report.filepath);
|
|
77
|
-
const shortStats = [...report.valueInfoMap.entries()].map(([name, values]) => {
|
|
78
|
-
return {
|
|
79
|
-
name,
|
|
80
|
-
count: (0, arrays_1.arraySum)([...values.values()]),
|
|
81
|
-
unique: values.size()
|
|
82
|
-
};
|
|
83
|
-
}).sort((a, b) => b.count - a.count).slice(0, limit);
|
|
84
|
-
const { longestName, longestCount, longestUnique } = shortStats.reduce((acc, { name, count, unique }) => {
|
|
85
|
-
return {
|
|
86
|
-
longestName: Math.max(acc.longestName, name.length),
|
|
87
|
-
longestCount: Math.max(acc.longestCount, count.toLocaleString().length),
|
|
88
|
-
longestUnique: Math.max(acc.longestUnique, unique.toLocaleString().length),
|
|
89
|
-
};
|
|
90
|
-
}, { longestName: 0, longestCount: 0, longestUnique: 0 });
|
|
91
|
-
for (const { name, count, unique } of shortStats) {
|
|
92
|
-
const strId = `${name}`.padEnd(longestName, ' ');
|
|
93
|
-
const strCount = count.toLocaleString().padStart(longestCount, ' ');
|
|
94
|
-
const strUnique = unique.toLocaleString().padStart(longestUnique, ' ');
|
|
95
|
-
const uniqueSuffix = `\t (${strUnique} ${ansi_1.formatter.format('unique', { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground })})`;
|
|
96
|
-
console.log(`\t${ansi_1.formatter.format(strId, { style: 1 /* FontStyles.Bold */ })}\t ${strCount} ` +
|
|
97
|
-
`${ansi_1.formatter.format('total', { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground })}`
|
|
98
|
-
+ (count !== unique ? uniqueSuffix : ''));
|
|
99
|
-
}
|
|
100
|
-
return shortStats.map(({ name }) => name);
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=post-process-output.js.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { StatisticsSummarizerConfiguration } from '../summarizer';
|
|
2
|
-
import { type CommonSummarizerConfiguration } from '../../../util/summarizer';
|
|
3
|
-
import { type FeatureStatisticsWithMeta } from '../../features/feature';
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
export declare function postProcessFeatures(config: StatisticsSummarizerConfiguration, filepath: string, outputPath: string, logger: (message: string) => void, metaFeatureInformation: Map<string, FeatureStatisticsWithMeta>): void;
|
|
8
|
-
/**
|
|
9
|
-
* Post process the collections in a given folder, retrieving the final summaries.
|
|
10
|
-
* @param logger - The logger to use for outputs
|
|
11
|
-
* @param filepath - Path to the root file of the data collection (contains all the archives)
|
|
12
|
-
* @param config - Configuration of the summarizer
|
|
13
|
-
* @param outputPath - The final outputPath to write the result to (may differ from the configured root folder)
|
|
14
|
-
*/
|
|
15
|
-
export declare function postProcessFeatureFolder(logger: CommonSummarizerConfiguration['logger'], filepath: string, config: StatisticsSummarizerConfiguration, outputPath: string): void;
|
|
@@ -1,118 +0,0 @@
|
|
|
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.postProcessFeatures = postProcessFeatures;
|
|
7
|
-
exports.postProcessFeatureFolder = postProcessFeatureFolder;
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const time_1 = require("../../../util/text/time");
|
|
11
|
-
const summarizer_1 = require("../../../util/summarizer");
|
|
12
|
-
const arrays_1 = require("../../../util/collections/arrays");
|
|
13
|
-
const files_1 = require("../../../util/files");
|
|
14
|
-
const assert_1 = require("../../../util/assert");
|
|
15
|
-
const feature_1 = require("../../features/feature");
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
function postProcessFeatures(config, filepath, outputPath, logger, metaFeatureInformation) {
|
|
20
|
-
for (const featureName of config.featuresToUse) {
|
|
21
|
-
const featureInfo = feature_1.ALL_FEATURES[featureName];
|
|
22
|
-
const targetPath = path_1.default.join(filepath, featureInfo.name);
|
|
23
|
-
const targetFeature = path_1.default.join(outputPath, featureInfo.name);
|
|
24
|
-
if (!featureInfo.postProcess) {
|
|
25
|
-
logger(` Skipping post processing of ${featureName} as no post processing behavior is defined`);
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
logger(` Post processing of ${featureName}...`);
|
|
29
|
-
if (!fs_1.default.existsSync(targetFeature)) {
|
|
30
|
-
fs_1.default.mkdirSync(targetFeature, { recursive: true });
|
|
31
|
-
}
|
|
32
|
-
if (global.gc) {
|
|
33
|
-
logger(` [${(0, time_1.date2string)(new Date())}] Running garbage collection (--expose-gc)`);
|
|
34
|
-
global.gc();
|
|
35
|
-
}
|
|
36
|
-
featureInfo.postProcess(targetPath, metaFeatureInformation, targetFeature, config);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function postProcessMeta(config, filepath, outputPath, logger, metaFeatureInformation) {
|
|
40
|
-
const fileStatisticsSummary = {
|
|
41
|
-
successfulParsed: [],
|
|
42
|
-
processingTimeMs: [],
|
|
43
|
-
failedRequests: [],
|
|
44
|
-
// min lengths of 1 etc. could come from different line endings
|
|
45
|
-
lines: [],
|
|
46
|
-
characters: [],
|
|
47
|
-
numberOfNormalizedNodes: []
|
|
48
|
-
};
|
|
49
|
-
if (!fs_1.default.existsSync(path_1.default.join(outputPath, 'meta'))) {
|
|
50
|
-
fs_1.default.mkdirSync(path_1.default.join(outputPath, 'meta'), { recursive: true });
|
|
51
|
-
}
|
|
52
|
-
const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'meta', 'stats.csv'));
|
|
53
|
-
out.write(`file,successfulParsed,${(0, summarizer_1.summarizedMeasurement2CsvHeader)('processing')},failedRequests,${(0, summarizer_1.summarizedMeasurement2CsvHeader)('line-length')},${(0, summarizer_1.summarizedMeasurement2CsvHeader)('lines')},${(0, summarizer_1.summarizedMeasurement2CsvHeader)('characters')},numberOfNormalizedNodes\n`);
|
|
54
|
-
for (const [file, info] of metaFeatureInformation) {
|
|
55
|
-
// we could retrieve these by summing later as well :thinking: however, this makes it more explicit
|
|
56
|
-
const characters = (0, arrays_1.arraySum)(info.stats.lines[0]);
|
|
57
|
-
out.write(`${JSON.stringify(file)},${info.stats.successfulParsed},${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(info.stats.processingTimeMs))},`
|
|
58
|
-
+ `${info.stats.failedRequests.length},${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(info.stats.lines[0]))},${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)([info.stats.lines[0].length]))},${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)([characters]))},${info.stats.numberOfNormalizedNodes[0]}\n`);
|
|
59
|
-
fileStatisticsSummary.successfulParsed.push(info.stats.successfulParsed);
|
|
60
|
-
fileStatisticsSummary.processingTimeMs.push(...info.stats.processingTimeMs);
|
|
61
|
-
fileStatisticsSummary.failedRequests.push(info.stats.failedRequests.length);
|
|
62
|
-
fileStatisticsSummary.lines.push(info.stats.lines[0]);
|
|
63
|
-
fileStatisticsSummary.characters.push(characters);
|
|
64
|
-
fileStatisticsSummary.numberOfNormalizedNodes.push(info.stats.numberOfNormalizedNodes[0]);
|
|
65
|
-
}
|
|
66
|
-
out.write(`all,${(0, arrays_1.arraySum)(fileStatisticsSummary.successfulParsed)},${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(fileStatisticsSummary.processingTimeMs))},`
|
|
67
|
-
+ `${(0, arrays_1.arraySum)(fileStatisticsSummary.failedRequests)},${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(fileStatisticsSummary.lines.flat()))},${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(fileStatisticsSummary.lines.map(l => l.length)))},${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(fileStatisticsSummary.characters))},${(0, arrays_1.arraySum)(fileStatisticsSummary.numberOfNormalizedNodes)}\n`);
|
|
68
|
-
out.close();
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Post process the collections in a given folder, retrieving the final summaries.
|
|
72
|
-
* @param logger - The logger to use for outputs
|
|
73
|
-
* @param filepath - Path to the root file of the data collection (contains all the archives)
|
|
74
|
-
* @param config - Configuration of the summarizer
|
|
75
|
-
* @param outputPath - The final outputPath to write the result to (may differ from the configured root folder)
|
|
76
|
-
*/
|
|
77
|
-
function postProcessFeatureFolder(logger, filepath, config, outputPath) {
|
|
78
|
-
if (!fs_1.default.existsSync(filepath)) {
|
|
79
|
-
logger(` Folder for ${filepath} does not exist, skipping post processing`);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (!fs_1.default.existsSync(outputPath)) {
|
|
83
|
-
fs_1.default.mkdirSync(outputPath, { recursive: true });
|
|
84
|
-
}
|
|
85
|
-
const metaFeatureInformation = extractMetaInformationFrom(logger, path_1.default.join(filepath, 'meta', 'features.txt'), path_1.default.join(filepath, 'meta', 'stats.txt'));
|
|
86
|
-
postProcessFeatures(config, filepath, outputPath, logger, metaFeatureInformation);
|
|
87
|
-
postProcessMeta(config, filepath, outputPath, logger, metaFeatureInformation);
|
|
88
|
-
}
|
|
89
|
-
function extractMetaInformationFrom(logger, metaFeaturesPath, metaStatsPath) {
|
|
90
|
-
const storage = new Map();
|
|
91
|
-
logger(` [${(0, time_1.date2string)(new Date())}] Collect feature statistics`);
|
|
92
|
-
(0, files_1.readLineByLineSync)(metaFeaturesPath, (line, lineNumber) => {
|
|
93
|
-
if (line.length === 0) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
if (lineNumber % 2_500 === 0) {
|
|
97
|
-
logger(` [${(0, time_1.date2string)(new Date())}] ${lineNumber} meta feature lines processed`);
|
|
98
|
-
}
|
|
99
|
-
const meta = JSON.parse(line.toString());
|
|
100
|
-
storage.set(meta.file, meta.content);
|
|
101
|
-
});
|
|
102
|
-
logger(` [${(0, time_1.date2string)(new Date())}] Collect meta statistics`);
|
|
103
|
-
(0, files_1.readLineByLineSync)(metaStatsPath, (line, lineNumber) => {
|
|
104
|
-
if (line.length === 0) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
if (lineNumber % 2_500 === 0) {
|
|
108
|
-
logger(` [${(0, time_1.date2string)(new Date())}] ${lineNumber} meta statistics lines processed`);
|
|
109
|
-
}
|
|
110
|
-
const meta = JSON.parse(line.toString());
|
|
111
|
-
const existing = storage.get(meta.file);
|
|
112
|
-
(0, assert_1.guard)(existing !== undefined, () => `Expected to find meta information for ${meta.file} in line ${lineNumber + 1} of ${metaFeaturesPath}`);
|
|
113
|
-
existing.stats = meta.content;
|
|
114
|
-
});
|
|
115
|
-
logger(` [${(0, time_1.date2string)(new Date())}] Done collecting meta information`);
|
|
116
|
-
return storage;
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=process.js.map
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type CommonSummarizerConfiguration, Summarizer } from '../../util/summarizer';
|
|
2
|
-
import type { FeatureSelection } from '../features/feature';
|
|
3
|
-
export interface StatisticsSummarizerConfiguration extends CommonSummarizerConfiguration {
|
|
4
|
-
/**
|
|
5
|
-
* The input path to read all zips from
|
|
6
|
-
*/
|
|
7
|
-
inputPath: string;
|
|
8
|
-
/**
|
|
9
|
-
* Features to extract the summaries for
|
|
10
|
-
*/
|
|
11
|
-
featuresToUse: FeatureSelection;
|
|
12
|
-
/**
|
|
13
|
-
* Path for the intermediate results of the preparation phase
|
|
14
|
-
*/
|
|
15
|
-
intermediateOutputPath: string;
|
|
16
|
-
/**
|
|
17
|
-
* Path for the final results of the summarization phase
|
|
18
|
-
*/
|
|
19
|
-
outputPath: string;
|
|
20
|
-
/**
|
|
21
|
-
* How many folders to skip to find the project root
|
|
22
|
-
*/
|
|
23
|
-
projectSkip: number;
|
|
24
|
-
}
|
|
25
|
-
export declare const statisticsFileNameRegex: RegExp;
|
|
26
|
-
export declare class StatisticsSummarizer extends Summarizer<unknown, StatisticsSummarizerConfiguration> {
|
|
27
|
-
constructor(config: StatisticsSummarizerConfiguration);
|
|
28
|
-
private removeIfExists;
|
|
29
|
-
/**
|
|
30
|
-
* The preparation phase essentially merges all files into one by just attaching lines together!
|
|
31
|
-
*/
|
|
32
|
-
preparationPhase(useTypeClassification: boolean): Promise<void>;
|
|
33
|
-
summarizePhase(): Promise<unknown>;
|
|
34
|
-
}
|
|
@@ -1,141 +0,0 @@
|
|
|
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.StatisticsSummarizer = exports.statisticsFileNameRegex = void 0;
|
|
7
|
-
const tar_1 = require("tar");
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const process_1 = require("./first-phase/process");
|
|
11
|
-
const process_2 = require("./second-phase/process");
|
|
12
|
-
const summarizer_1 = require("../../util/summarizer");
|
|
13
|
-
const strings_1 = require("../../util/text/strings");
|
|
14
|
-
const files_1 = require("../../util/files");
|
|
15
|
-
const time_1 = require("../../util/text/time");
|
|
16
|
-
const log_1 = require("../../util/log");
|
|
17
|
-
exports.statisticsFileNameRegex = /.*--.*\.tar\.gz$/;
|
|
18
|
-
/**
|
|
19
|
-
* The returned map contains the full path as key, mapping it to the complete contents.
|
|
20
|
-
*/
|
|
21
|
-
async function retrieveAllFilesInArchive(f) {
|
|
22
|
-
const filenames = new Map();
|
|
23
|
-
const promises = [];
|
|
24
|
-
(0, tar_1.list)({
|
|
25
|
-
file: f,
|
|
26
|
-
onentry: entry => {
|
|
27
|
-
if (entry.type === 'File') {
|
|
28
|
-
promises.push(entry.concat().then(content => {
|
|
29
|
-
filenames.set(entry.path, content.toString());
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
sync: true
|
|
34
|
-
});
|
|
35
|
-
await Promise.all(promises);
|
|
36
|
-
return filenames;
|
|
37
|
-
}
|
|
38
|
-
function identifyCommonPrefix(files) {
|
|
39
|
-
return (0, strings_1.longestCommonPrefix)([...files.keys()]);
|
|
40
|
-
}
|
|
41
|
-
/** returns the target path */
|
|
42
|
-
async function extractArchive(f) {
|
|
43
|
-
const files = await retrieveAllFilesInArchive(f);
|
|
44
|
-
const commonRoot = identifyCommonPrefix(files);
|
|
45
|
-
// post process until we find the '<filename>.(r|R)' suffix. otherwise, if there are no features and only the meta folder, the meta folder will be removed, resulting in a write
|
|
46
|
-
// to the toplevel!
|
|
47
|
-
const fname = path_1.default.basename(f).replace(/\.tar\.gz$/, '');
|
|
48
|
-
const findIndex = commonRoot.indexOf(fname);
|
|
49
|
-
const commonPart = findIndex < 0 ? commonRoot.length : findIndex + fname.length;
|
|
50
|
-
// transform all map keys by removing the common root
|
|
51
|
-
const transformed = new Map();
|
|
52
|
-
for (const [key, value] of files.entries()) {
|
|
53
|
-
transformed.set(key.slice(commonPart), value);
|
|
54
|
-
}
|
|
55
|
-
return transformed;
|
|
56
|
-
}
|
|
57
|
-
// due to a redefinition after the initial statistic extraction, we extract the type from the remaining path :D
|
|
58
|
-
// original: /^([^-]*)---?(.+)\.tar.gz/
|
|
59
|
-
const filePrefixRegex = /^[^-]*---?(?<fullname>([^/]+)\/(?<pathtest>.+))\.tar\.gz$/;
|
|
60
|
-
const testRegex = /.*test[-_]?(s|that|)\//i;
|
|
61
|
-
/** if it starts with example-, this will return `'example'`, etc. if it starts with '--' this will return `undefined` */
|
|
62
|
-
function identifyExtractionType(path) {
|
|
63
|
-
const match = filePrefixRegex.exec(path.replace(///g, '/'));
|
|
64
|
-
if (match === null || match?.groups === undefined) {
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
// recover
|
|
68
|
-
const originalFile = match.groups.fullname;
|
|
69
|
-
let folder;
|
|
70
|
-
if (testRegex.test(match.groups.pathtest)) {
|
|
71
|
-
folder = 'test';
|
|
72
|
-
}
|
|
73
|
-
else if (match.groups.pathtest.includes('example')) {
|
|
74
|
-
folder = 'example';
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
folder = 'default';
|
|
78
|
-
}
|
|
79
|
-
return { folder, originalFile };
|
|
80
|
-
}
|
|
81
|
-
class StatisticsSummarizer extends summarizer_1.Summarizer {
|
|
82
|
-
constructor(config) {
|
|
83
|
-
super(config);
|
|
84
|
-
}
|
|
85
|
-
removeIfExists(path) {
|
|
86
|
-
if (path && fs_1.default.existsSync(path)) {
|
|
87
|
-
this.log(`Removing existing ${path}`);
|
|
88
|
-
try {
|
|
89
|
-
fs_1.default.rmSync(path, { recursive: true, force: true });
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
log_1.log.error('failure in cleanup');
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* The preparation phase essentially merges all files into one by just attaching lines together!
|
|
98
|
-
*/
|
|
99
|
-
async preparationPhase(useTypeClassification) {
|
|
100
|
-
this.removeIfExists(this.config.intermediateOutputPath);
|
|
101
|
-
fs_1.default.mkdirSync(this.config.intermediateOutputPath, { recursive: true });
|
|
102
|
-
let count = 0;
|
|
103
|
-
const migrator = new process_1.FileMigrator();
|
|
104
|
-
for await (const f of (0, files_1.getAllFiles)(this.config.inputPath, /\.tar.gz$/)) {
|
|
105
|
-
this.log(`[${count++}, ${(0, time_1.date2string)()}] processing file ${f} (to ${this.config.intermediateOutputPath})`);
|
|
106
|
-
let target;
|
|
107
|
-
try {
|
|
108
|
-
target = await extractArchive(f);
|
|
109
|
-
this.log(' Collected!');
|
|
110
|
-
}
|
|
111
|
-
catch (e) {
|
|
112
|
-
this.log(` Failed to extract ${f}, skipping...`);
|
|
113
|
-
this.log(' Error: ' + JSON.stringify(e));
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
this.log(' Migrating files...');
|
|
117
|
-
const extracted = identifyExtractionType(path_1.default.basename(f));
|
|
118
|
-
await migrator.migrate(target, path_1.default.join(this.config.intermediateOutputPath, useTypeClassification ? extracted?.folder ?? 'default' : 'uncategorized'), extracted?.originalFile);
|
|
119
|
-
this.log(' Done! (Cleanup...)');
|
|
120
|
-
}
|
|
121
|
-
migrator.finish();
|
|
122
|
-
this.log(`Found ${count} files to summarize`);
|
|
123
|
-
return Promise.resolve();
|
|
124
|
-
}
|
|
125
|
-
async summarizePhase() {
|
|
126
|
-
// detect all subfolders in the current folder (default, test...) for each: concat.
|
|
127
|
-
this.removeIfExists(this.config.outputPath);
|
|
128
|
-
fs_1.default.mkdirSync(this.config.outputPath, { recursive: true });
|
|
129
|
-
const folders = fs_1.default.readdirSync(this.config.intermediateOutputPath, { recursive: false });
|
|
130
|
-
for (const folder of folders) {
|
|
131
|
-
const folderStr = String(folder);
|
|
132
|
-
const output = path_1.default.join(this.config.outputPath, folderStr);
|
|
133
|
-
const input = path_1.default.join(this.config.intermediateOutputPath, folderStr);
|
|
134
|
-
this.log(`Summarizing for ${input} (target: ${output})`);
|
|
135
|
-
(0, process_2.postProcessFeatureFolder)(this.log, input, this.config, output);
|
|
136
|
-
}
|
|
137
|
-
return Promise.resolve(undefined);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
exports.StatisticsSummarizer = StatisticsSummarizer;
|
|
141
|
-
//# sourceMappingURL=summarizer.js.map
|