From 4d0f4c360945ffaee5af328f4d41ba75245accb8 Mon Sep 17 00:00:00 2001 From: Brian Broll Date: Wed, 24 Aug 2016 19:42:04 -0500 Subject: [PATCH] Added fast-forward to ExecutePipeline on merge. Fixes #682 (#712) 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 --- .../CreateExecution/CreateExecution.js | 5 ++--- src/plugins/ExecuteJob/ExecuteJob.js | 17 +++++++++++++++ .../ExecutePipeline/ExecutePipeline.js | 21 +++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/plugins/CreateExecution/CreateExecution.js b/src/plugins/CreateExecution/CreateExecution.js index 20f05982f..7b81ddac1 100644 --- a/src/plugins/CreateExecution/CreateExecution.js +++ b/src/plugins/CreateExecution/CreateExecution.js @@ -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, @@ -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}`); @@ -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 => { diff --git a/src/plugins/ExecuteJob/ExecuteJob.js b/src/plugins/ExecuteJob/ExecuteJob.js index ecc96a71b..0e79dafea 100644 --- a/src/plugins/ExecuteJob/ExecuteJob.js +++ b/src/plugins/ExecuteJob/ExecuteJob.js @@ -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--;) { diff --git a/src/plugins/ExecutePipeline/ExecutePipeline.js b/src/plugins/ExecutePipeline/ExecutePipeline.js index 7e3e10852..b45468baf 100644 --- a/src/plugins/ExecutePipeline/ExecutePipeline.js +++ b/src/plugins/ExecutePipeline/ExecutePipeline.js @@ -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);