Skip to content

Commit

Permalink
Added custom layer support to executions. Fixes #296
Browse files Browse the repository at this point in the history
WIP #296 Fixed execution support
  • Loading branch information
brollb committed Jun 17, 2016
1 parent 98b289d commit c6d03de
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
32 changes: 26 additions & 6 deletions src/plugins/ExecutePipeline/ExecutePipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,12 +591,7 @@ define([

// add the given files
return this.createEntryFile(node, files)
// Add the custom layer definitions
// (with an init.lua file)
// TODO
.then(() => this.createInputs(node, files))
// Update the main file
// TODO
.then(() => this.createCustomLayers(node, files))
.then(() => this.createInputs(node, files))
.then(() => this.createOutputs(node, files))
.then(() => this.createMainFile(node, files))
Expand All @@ -606,6 +601,31 @@ define([
});
};

ExecutePipeline.prototype.createCustomLayers = function (node, files) {
var isCustomLayer = {},
metaDict = this.core.getAllMetaNodes(this.rootNode),
metanodes,
customLayers,
code;

metanodes = Object.keys(metaDict).map(id => metaDict[id]);
// Get all the custom layers
metanodes.forEach(node => {
if (this.core.getAttribute(node, 'name') === 'CustomLayer') {
isCustomLayer[this.core.getPath(node)] = true;
}
});
customLayers = metanodes.filter(node =>
this.core.getMixinPaths(node).some(id => isCustomLayer[id]));

// Get the code definitions for each
code = 'require \'nn\'\n\n' + customLayers
.map(node => this.core.getAttribute(node, 'code')).join('\n');

// Create the custom layers file
files['custom-layers.lua'] = code;
};

ExecutePipeline.prototype.createInputs = function (node, files) {
var tplContents;
return this.getInputs(node)
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/ExecutePipeline/templates/main.ejs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- load custom layers
require './custom-layers'

-- input data<% inputs.forEach(function(pair) { var input = pair[0], isNil = pair[1];%>
<%= isNil ? 'local ' : ''%><%= input %> = <% if (isNil) { %>nil<% } else { %>require './inputs/<%= input %>'<%}}); %>

Expand Down

0 comments on commit c6d03de

Please sign in to comment.