Skip to content

Commit

Permalink
Add provenance to job feedback (plots, images, etc). Closes #1728 (#1732
Browse files Browse the repository at this point in the history
)

* Update pipeline seed with metadata provenance

* Fix corrupt releases file

* Record provenance for metadata. Closes #1728

* Add loadChildren helper to Metadata
  • Loading branch information
brollb authored Jun 10, 2020
1 parent 25cf460 commit 482f627
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/plugins/ExecuteJob/ExecuteJob.Metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ define([
const nodeId = this.core.getPath(job);
this.lastAppliedCmd[nodeId] = 0;
const metadata = await this.getMetadataNodes(job);
await Promise.all(metadata.map(node => this.resetMetadataNode(node)));
await Promise.all(metadata.map(node => this.resetMetadataNode(node, job)));
};

ExecuteJob.prototype.clearOldMetadata = async function (job) {
Expand All @@ -39,13 +39,16 @@ define([
}
};

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

const attributes = this.core.getAttributeNames(node)
.filter(attr => attr !== 'id');
attributes.forEach(attr => this.core.delAttribute(node, attr));

const op = await this.getOperation(job);
await this.recordProvenance(node, op);
};

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

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

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

const node = this.core.createNode({base, parent: job});
this.core.setAttribute(node, 'id', id);
await this.recordProvenance(node, op);
return node;
};

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/ExecuteJob/metadata/Figure.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ define([
}

async clearSubGraphs() {
const subGraphs = await this.core.loadChildren(this.node);
const subGraphs = await this.loadChildren();

subGraphs.forEach(subGraph => this.core.deleteNode(subGraph));
}

Expand Down
8 changes: 8 additions & 0 deletions src/plugins/ExecuteJob/metadata/Metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ define([
throw new Error('not implemented!');
}

async loadChildren() {
const provPath = this.core.getPointerPath(this.node, 'provenance');
const children = (await this.core.loadChildren(this.node))
.filter(node => this.core.getPath(node) !== provPath);

return children;
}

static getCommand() {
throw new Error('not implemented!');
}
Expand Down
Binary file modified src/seeds/pipeline/pipeline.webgmex
Binary file not shown.
3 changes: 2 additions & 1 deletion src/seeds/pipeline/releases.jsonl
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{"version":"0.20.0","changelog":"Add provenance info to Data nodes"}
{"version":"0.20.0","changelog":"Add provenance info to Data nodes"}
{"version":"0.21.0","changelog":"Add provenance to metadata (via WithProvenance mixin)"}

0 comments on commit 482f627

Please sign in to comment.