@lde/pipeline 0.30.16 → 0.30.18
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 +15 -0
- package/dist/combineReporters.d.ts +16 -0
- package/dist/combineReporters.d.ts.map +1 -0
- package/dist/combineReporters.js +51 -0
- package/dist/pipeline.d.ts +7 -1
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +6 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -276,6 +276,21 @@ Writes generated quads to a destination:
|
|
|
276
276
|
- `SparqlUpdateWriter` — writes to a SPARQL endpoint via UPDATE queries
|
|
277
277
|
- `FileWriter` — writes to local files
|
|
278
278
|
|
|
279
|
+
### Reporter
|
|
280
|
+
|
|
281
|
+
A `ProgressReporter` observes the run, receiving lifecycle events such as `pipelineStart`, `stageComplete`, `datasetValidated` and `pipelineComplete`. Every method is optional, so a reporter implements only the events it cares about.
|
|
282
|
+
|
|
283
|
+
Pass a single reporter, or an array to have several observe the same run — for example a console reporter alongside one that collects validation verdicts:
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
new Pipeline({
|
|
287
|
+
// …
|
|
288
|
+
reporter: [new ConsoleReporter(), verdictCollector],
|
|
289
|
+
});
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Each reporter receives every event, in array order; a reporter that does not implement a given event is skipped for it.
|
|
293
|
+
|
|
279
294
|
### Provenance store
|
|
280
295
|
|
|
281
296
|
A `ProvenanceStore` gives the pipeline a small per-dataset memory, so a future run can skip datasets that are genuinely unchanged. It is purely a storage seam: the framework owns the skip decision (see [`sourceFingerprint`](#source-change-fingerprint) and `shouldReprocess`), the store owns only how each record is persisted.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ProgressReporter } from './progressReporter.js';
|
|
2
|
+
/**
|
|
3
|
+
* Combine several {@link ProgressReporter}s into one that forwards every
|
|
4
|
+
* lifecycle call to each child that implements it. Lets a single run be
|
|
5
|
+
* observed by more than one reporter – e.g. a console reporter alongside a
|
|
6
|
+
* verdict-collecting one.
|
|
7
|
+
*
|
|
8
|
+
* Each method is dispatched to the children in array order; a child that does
|
|
9
|
+
* not implement a given (optional) method is skipped for that call.
|
|
10
|
+
*
|
|
11
|
+
* Internal to the package: not re-exported from `index.ts`. {@link Pipeline}
|
|
12
|
+
* uses it to normalise a `reporter` array into the single reporter its call
|
|
13
|
+
* sites expect, so the broader API need not grow a new public symbol.
|
|
14
|
+
*/
|
|
15
|
+
export declare function combineReporters(reporters: readonly ProgressReporter[]): ProgressReporter;
|
|
16
|
+
//# sourceMappingURL=combineReporters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combineReporters.d.ts","sourceRoot":"","sources":["../src/combineReporters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAU9D;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,gBAAgB,EAAE,GACrC,gBAAgB,CA4ClB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combine several {@link ProgressReporter}s into one that forwards every
|
|
3
|
+
* lifecycle call to each child that implements it. Lets a single run be
|
|
4
|
+
* observed by more than one reporter – e.g. a console reporter alongside a
|
|
5
|
+
* verdict-collecting one.
|
|
6
|
+
*
|
|
7
|
+
* Each method is dispatched to the children in array order; a child that does
|
|
8
|
+
* not implement a given (optional) method is skipped for that call.
|
|
9
|
+
*
|
|
10
|
+
* Internal to the package: not re-exported from `index.ts`. {@link Pipeline}
|
|
11
|
+
* uses it to normalise a `reporter` array into the single reporter its call
|
|
12
|
+
* sites expect, so the broader API need not grow a new public symbol.
|
|
13
|
+
*/
|
|
14
|
+
export function combineReporters(reporters) {
|
|
15
|
+
const forward = (method, ...args) => {
|
|
16
|
+
for (const reporter of reporters) {
|
|
17
|
+
// Cast to the concrete signature for `method`: indexing by a generic key
|
|
18
|
+
// yields a union of method types TS won't call directly, even though the
|
|
19
|
+
// arguments are correlated.
|
|
20
|
+
const handler = reporter[method];
|
|
21
|
+
// Every method is optional; notify only the children that implement it.
|
|
22
|
+
handler?.(...args);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
// Listing every method explicitly (rather than a Proxy) keeps the forwarding
|
|
26
|
+
// type-safe: typing the result as `Required<ProgressReporter>` forces a new
|
|
27
|
+
// entry here whenever the interface grows, so a forgotten method fails to
|
|
28
|
+
// compile instead of silently going unforwarded.
|
|
29
|
+
const combined = {
|
|
30
|
+
pipelineStart: (...args) => forward('pipelineStart', ...args),
|
|
31
|
+
datasetsSelected: (...args) => forward('datasetsSelected', ...args),
|
|
32
|
+
datasetStart: (...args) => forward('datasetStart', ...args),
|
|
33
|
+
distributionProbed: (...args) => forward('distributionProbed', ...args),
|
|
34
|
+
importStarted: (...args) => forward('importStarted', ...args),
|
|
35
|
+
importFailed: (...args) => forward('importFailed', ...args),
|
|
36
|
+
distributionValidated: (...args) => forward('distributionValidated', ...args),
|
|
37
|
+
distributionSelected: (...args) => forward('distributionSelected', ...args),
|
|
38
|
+
stageStart: (...args) => forward('stageStart', ...args),
|
|
39
|
+
stageProgress: (...args) => forward('stageProgress', ...args),
|
|
40
|
+
stageComplete: (...args) => forward('stageComplete', ...args),
|
|
41
|
+
stageFailed: (...args) => forward('stageFailed', ...args),
|
|
42
|
+
stageSkipped: (...args) => forward('stageSkipped', ...args),
|
|
43
|
+
datasetValidated: (...args) => forward('datasetValidated', ...args),
|
|
44
|
+
datasetComplete: (...args) => forward('datasetComplete', ...args),
|
|
45
|
+
datasetSkipped: (...args) => forward('datasetSkipped', ...args),
|
|
46
|
+
pipelineComplete: (...args) => forward('pipelineComplete', ...args),
|
|
47
|
+
timeoutTightened: (...args) => forward('timeoutTightened', ...args),
|
|
48
|
+
timeoutRelaxed: (...args) => forward('timeoutRelaxed', ...args),
|
|
49
|
+
};
|
|
50
|
+
return combined;
|
|
51
|
+
}
|
package/dist/pipeline.d.ts
CHANGED
|
@@ -42,7 +42,13 @@ export interface PipelineOptions {
|
|
|
42
42
|
stageOutputResolver: StageOutputResolver;
|
|
43
43
|
outputDir: string;
|
|
44
44
|
};
|
|
45
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Observer(s) notified of pipeline lifecycle events. Pass an array to have
|
|
47
|
+
* several reporters observe the same run – e.g. a console reporter alongside
|
|
48
|
+
* a verdict-collecting one; every reporter receives each event in array
|
|
49
|
+
* order. A single reporter may be passed directly.
|
|
50
|
+
*/
|
|
51
|
+
reporter?: ProgressReporter | readonly ProgressReporter[];
|
|
46
52
|
/**
|
|
47
53
|
* Optional per-dataset processing memory. When set, the pipeline skips a
|
|
48
54
|
* dataset whose source-change fingerprint and {@link pipelineVersion} both
|
package/dist/pipeline.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAgB,MAAM,cAAc,CAAC;AAGrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EACL,KAAK,oBAAoB,EAG1B,MAAM,4BAA4B,CAAC;AAKpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAY7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AACA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S,gBAAgB,EAAE,CAAC;IAC1D;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,MAAM,aAAa,CAAC;CAC/B;AAkFD,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAyC;IAC3E,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAuB;IAC5D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAA8B;IACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAmB;IAC7C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAsB;IACrD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAkB;IACnD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAS;gBAE9B,OAAO,EAAE,eAAe;IA+C9B,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAoBZ,cAAc;IA+K5B,+EAA+E;YACjE,aAAa;YAmBb,gBAAgB;IAW9B,OAAO,CAAE,aAAa;IAOtB;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAMnB;;;OAGG;YACW,QAAQ;IA0CtB,2EAA2E;YAC7D,eAAe;YAqBf,QAAQ;YA+DP,SAAS;CAczB"}
|
package/dist/pipeline.js
CHANGED
|
@@ -9,6 +9,7 @@ import { NetworkError, SparqlProbeResult, } from '@lde/distribution-probe';
|
|
|
9
9
|
import { ImportSuccessful } from '@lde/sparql-importer';
|
|
10
10
|
import { importOutcomeToVerdict, probeResultToVerdict, } from '@lde/distribution-health';
|
|
11
11
|
import { NotSupported } from './sparql/executor.js';
|
|
12
|
+
import { combineReporters } from './combineReporters.js';
|
|
12
13
|
import { ConstantTimeoutPolicy, } from './sparql/timeoutPolicy.js';
|
|
13
14
|
/**
|
|
14
15
|
* Split an async iterable into `count` branches that can be consumed
|
|
@@ -113,7 +114,11 @@ export class Pipeline {
|
|
|
113
114
|
this.distributionResolver =
|
|
114
115
|
options.distributionResolver ?? new SparqlDistributionResolver();
|
|
115
116
|
this.chaining = options.chaining;
|
|
116
|
-
|
|
117
|
+
// `Array.isArray` narrows the array branch but not the readonly-array out of
|
|
118
|
+
// the else branch, so cast the single-reporter case explicitly.
|
|
119
|
+
this.reporter = Array.isArray(options.reporter)
|
|
120
|
+
? combineReporters(options.reporter)
|
|
121
|
+
: options.reporter;
|
|
117
122
|
this.timeoutFactory =
|
|
118
123
|
options.timeout ?? (() => new ConstantTimeoutPolicy(300_000));
|
|
119
124
|
this.provenanceStore = options.provenanceStore;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lde/pipeline",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.18",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "git+https://github.com/ldelements/lde.git",
|
|
6
6
|
"directory": "packages/pipeline"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@lde/dataset": "0.7.7",
|
|
28
28
|
"@lde/dataset-registry-client": "0.8.3",
|
|
29
|
-
"@lde/distribution-health": "0.1.
|
|
29
|
+
"@lde/distribution-health": "0.1.2",
|
|
30
30
|
"@lde/distribution-probe": "0.1.10",
|
|
31
31
|
"@lde/sparql-importer": "0.6.5",
|
|
32
32
|
"@lde/sparql-server": "0.4.11",
|