Skip to content

Commit

Permalink
Added fast-forward to ExecutePipeline on merge. Fixes #682 (#712)
Browse files Browse the repository at this point in the history
WIP #682 Added cache update on merge

WIP #682 Updating cache, rootNode, activeNode on merge

WIP #682 Changed to fast-forward

WIP #682 Fixed merge errors w/ multi executions

WIP #682 Added fast-forward to ExecuteJob

WIP #682 Added more logs and removed old comment
  • Loading branch information
brollb authored Aug 25, 2016
1 parent 209f46a commit 4d0f4c3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/plugins/CreateExecution/CreateExecution.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ define([
// Given a pipeline, copy all the operations to a custom job
// - Copy the operations
// - Wrap the operations in "Job" boxes which contain running info
// - eg,
// - 'debug' the given run (download all execution files)
// - 'console' show console output (future feature)
// - Update the references
var tgtNode,
execName,
Expand All @@ -108,6 +105,7 @@ define([
base: this.META.Execution,
parent: execDir
});
this.logger.debug(`New execution created w/ id: ${this.core.getPath(tgtNode)}`);

// Get a unique name
this.logger.debug(`About to get a unique name starting w/ ${basename}`);
Expand Down Expand Up @@ -189,6 +187,7 @@ define([
})
.then(execDir => {
var cIds = this.core.getChildrenPaths(execDir);
this.logger.debug(`Current executions are ${cIds.join(', ')}`);
return Q.all(cIds.map(id => this.core.loadByPath(this.rootNode, id)));
})
.then(execs => {
Expand Down
17 changes: 17 additions & 0 deletions src/plugins/ExecuteJob/ExecuteJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,27 @@ define([
msg = `"${name}" execution has forked to "${result.forkName}"`;
this.currentForkName = result.forkName;
this.sendNotification(msg);
} else if (result.status === STORAGE_CONSTANTS.MERGED) {
this.logger.debug('Merged changes. About to update plugin nodes');
return this.updateNodes();
}
});
};

ExecuteJob.prototype.updateNodes = function () {
var activeId = this.core.getPath(this.activeNode);

return Q.ninvoke(this.project, 'loadObject', this.currentHash)
.then(commitObject => {
return this.core.loadRoot(commitObject.root);
})
.then(rootObject => {
this.rootNode = rootObject;
return this.core.loadByPath(rootObject,activeId);
})
.then(activeObject => this.activeNode = activeObject);
};

ExecuteJob.prototype.getConnections = function (nodes) {
var conns = [];
for (var i = nodes.length; i--;) {
Expand Down
21 changes: 21 additions & 0 deletions src/plugins/ExecutePipeline/ExecutePipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,33 @@ define([
this.currentForkName = result.forkName;
msg = `"${this.pipelineName}" execution has forked to "${result.forkName}"`;
this.sendNotification(msg);
} else if (result.status === STORAGE_CONSTANTS.MERGED) {
this.logger.debug('Merged changes. About to update plugin nodes');
return this.updateNodes();
}

});

return this._currentSave;
};

ExecutePipeline.prototype.updateNodes = function () {
var result = ExecuteJob.prototype.updateNodes.call(this);
return result.then(() => this.updateCache());
};

ExecutePipeline.prototype.updateCache = function () {
var nodeIds = Object.keys(this.nodes),
nodes = nodeIds.map(id => this.core.loadByPath(this.rootNode, id));

this.logger.debug(`updating node cache (${nodeIds.length} nodes)`);
return Q.all(nodes).then(nodes => {
for (var i = nodeIds.length; i--;) {
this.nodes[nodeIds[i]] = nodes[i];
}
});
};

ExecutePipeline.prototype.isInputData = function (node) {
var prnt = this.core.getParent(node);
return this.core.isTypeOf(prnt, this.META.Inputs);
Expand Down

0 comments on commit 4d0f4c3

Please sign in to comment.