Skip to content

Commit 482f627

Browse files
authored
Add provenance to job feedback (plots, images, etc). Closes #1728 (#1732)
* Update pipeline seed with metadata provenance * Fix corrupt releases file * Record provenance for metadata. Closes #1728 * Add loadChildren helper to Metadata
1 parent 25cf460 commit 482f627

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

src/plugins/ExecuteJob/ExecuteJob.Metadata.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ define([
1616
const nodeId = this.core.getPath(job);
1717
this.lastAppliedCmd[nodeId] = 0;
1818
const metadata = await this.getMetadataNodes(job);
19-
await Promise.all(metadata.map(node => this.resetMetadataNode(node)));
19+
await Promise.all(metadata.map(node => this.resetMetadataNode(node, job)));
2020
};
2121

2222
ExecuteJob.prototype.clearOldMetadata = async function (job) {
@@ -39,13 +39,16 @@ define([
3939
}
4040
};
4141

42-
ExecuteJob.prototype.resetMetadataNode = async function (node) {
42+
ExecuteJob.prototype.resetMetadataNode = async function (node, job) {
4343
const children = await this.core.loadChildren(node);
4444
children.forEach(child => this.core.deleteNode(child));
4545

4646
const attributes = this.core.getAttributeNames(node)
4747
.filter(attr => attr !== 'id');
4848
attributes.forEach(attr => this.core.delAttribute(node, attr));
49+
50+
const op = await this.getOperation(job);
51+
await this.recordProvenance(node, op);
4952
};
5053

5154
ExecuteJob.prototype.getMetadataNodes = async function (job) {
@@ -100,13 +103,14 @@ define([
100103
const MetadataClass = Metadata.getClassForCommand(cmd);
101104
const metadata = await this.getMetadataNodes(job);
102105
const node = metadata.find(node => this.core.getAttribute(node, 'id')) ||
103-
this.createNodeForMetadata(MetadataClass, job, id);
106+
await this.createNodeForMetadata(MetadataClass, job, id);
104107

105108
const md = new MetadataClass(node, this.core, this.META);
106109
await md.update(content);
107110
};
108111

109-
ExecuteJob.prototype.createNodeForMetadata = function (MetadataClass, job, id) {
112+
ExecuteJob.prototype.createNodeForMetadata = async function (MetadataClass, job, id) {
113+
const op = await this.getOperation(job);
110114
const base = this.META[MetadataClass.getMetaType()];
111115
const msg = `Metadata type not found for ${MetadataClass.name}: ` +
112116
`${MetadataClass.getMetaType()}`;
@@ -115,6 +119,7 @@ define([
115119

116120
const node = this.core.createNode({base, parent: job});
117121
this.core.setAttribute(node, 'id', id);
122+
await this.recordProvenance(node, op);
118123
return node;
119124
};
120125

src/plugins/ExecuteJob/metadata/Figure.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ define([
5252
}
5353

5454
async clearSubGraphs() {
55-
const subGraphs = await this.core.loadChildren(this.node);
55+
const subGraphs = await this.loadChildren();
56+
5657
subGraphs.forEach(subGraph => this.core.deleteNode(subGraph));
5758
}
5859

src/plugins/ExecuteJob/metadata/Metadata.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ define([
1313
throw new Error('not implemented!');
1414
}
1515

16+
async loadChildren() {
17+
const provPath = this.core.getPointerPath(this.node, 'provenance');
18+
const children = (await this.core.loadChildren(this.node))
19+
.filter(node => this.core.getPath(node) !== provPath);
20+
21+
return children;
22+
}
23+
1624
static getCommand() {
1725
throw new Error('not implemented!');
1826
}
1.35 KB
Binary file not shown.

src/seeds/pipeline/releases.jsonl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
{"version":"0.20.0","changelog":"Add provenance info to Data nodes"}
1+
{"version":"0.20.0","changelog":"Add provenance info to Data nodes"}
2+
{"version":"0.21.0","changelog":"Add provenance to metadata (via WithProvenance mixin)"}

0 commit comments

Comments
 (0)