Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ArtifactLoader. Fixes #166 #235

Merged
merged 1 commit into from
Jun 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/decorators/DcOpDecorator/DcOpDecorator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*globals define, _*/
/*jshint browser: true, camelcase: false*/

/**
* @author brollb / https://github.com/brollb
*/

define([
'js/Decorators/DecoratorBase',
'./EasyDAG/DcOpDecorator.EasyDAGWidget'
], function (
DecoratorBase,
DcOpDecoratorEasyDAGWidget
) {

'use strict';

var DcOpDecorator,
__parent__ = DecoratorBase,
__parent_proto__ = DecoratorBase.prototype,
DECORATOR_ID = 'DcOpDecorator';

DcOpDecorator = function (params) {
var opts = _.extend({loggerName: this.DECORATORID}, params);

__parent__.apply(this, [opts]);

this.logger.debug('DcOpDecorator ctor');
};

_.extend(DcOpDecorator.prototype, __parent_proto__);
DcOpDecorator.prototype.DECORATORID = DECORATOR_ID;

/*********************** OVERRIDE DecoratorBase MEMBERS **************************/

DcOpDecorator.prototype.initializeSupportedWidgetMap = function () {
this.supportedWidgetMap = {
EasyDAG: DcOpDecoratorEasyDAGWidget
};
};

return DcOpDecorator;
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @author brollb / https://github.com/brollb
*/
.dcop-decorator {
min-width: 65px;
height: 40px;
border: 1px solid black;
background-color: #dedede;
padding: 3px;
text-align: center; }
.dcop-decorator .attr-title {
font-style: italic;
}
.dcop-decorator .name {
margin-top: 10px;
white-space: nowrap;
font-size: 16px;
font-weight: bold;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
text-align: center; }
.dcop-decorator .connector {
background-color: #fefefe;
height: 10px;
width: 10px;
position: absolute;
cursor: pointer;
border: 1px solid blue;
z-index: 10;
margin-left: -6px;
left: 50%; }
.dcop-decorator .connector:hover {
border-color: rgba(82, 168, 236, 0.8);
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); }
.dcop-decorator .connector.top {
top: -6px; }
.dcop-decorator .connector.bottom {
bottom: -6px; }

.selected .dcop-decorator {
border: 1px solid #52a8ec;
background-color: #dbeafc; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*globals define, _*/
/*jshint browser: true, camelcase: false*/

/**
* @author brollb / https://github.com/brollb
*/

define([
'js/Constants',
'decorators/OperationDecorator/EasyDAG/OperationDecorator.EasyDAGWidget',
'css!./DcOpDecorator.EasyDAGWidget.css'
], function (
CONSTANTS,
DecoratorBase
) {

'use strict';

var DcOpDecorator,
DECORATOR_ID = 'DcOpDecorator';

// DcOp nodes need to be able to...
// - dynamically change their outputs (downcast)
DcOpDecorator = function (options) {
options.color = options.color || '#78909c';
DecoratorBase.call(this, options);
};

_.extend(DcOpDecorator.prototype, DecoratorBase.prototype);

DcOpDecorator.prototype.DECORATOR_ID = DECORATOR_ID;

DcOpDecorator.prototype.getTargetFilterFnFor = function() {
return id => {
var node = this.client.getNode(id);
return node.getId() !== node.getMetaTypeId(); // not meta node
};
};

DcOpDecorator.prototype.savePointer = function(name, to) {
// When the 'artifact' pointer is changed, we should change the base
// of the data output node to the target type
if (name === 'artifact' && (typeof to === 'string')) {
var output = this._node.outputs[0];

this.client.startTransaction(`Setting output of ${this.name} to ${to}`);
if (!output) {
// create the output node
this._createOutputNode(to);
} else {
this.client.makePointer(output.id, CONSTANTS.POINTER_BASE, to);
}

// 'cast' the output node to the correct type
this.client.makePointer(this._node.id, name, to);
this.client.completeTransaction();
} else {
DecoratorBase.prototype.savePointer.call(this, name, to);
}
};

DcOpDecorator.prototype._createOutputNode = function(baseId) {
// Get the outputCntrId
// TOOD
var n = this.client.getNode(this._node.id),
outputCntrId;

outputCntrId = n.getChildrenIds().find(id => {
var metaTypeId = this.client.getNode(id).getMetaTypeId(),
metaType = this.client.getNode(metaTypeId);

if (!metaType) {
this.logger.error(`Could not check the type of ${id}!`);
return false;
}
return metaType.getAttribute('name') === 'Outputs';
});

this.client.createChild({
baseId: baseId,
parentId: outputCntrId
});
};

return DcOpDecorator;
});
21 changes: 18 additions & 3 deletions src/plugins/ExecutePipeline/LocalExecutor.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,24 @@ define([
};

// Should these be in lua?
LocalExecutor.prototype.BlobLoader = function(node) {
var hash = this.core.getAttribute(node, 'data');
return this.getOutputs(node)
LocalExecutor.prototype.ArtifactLoader = function(node) {
// FIXME: Get the hash from the output node
var hash;
return this.core.loadChildren(node)
.then(cntrs => {
// Get the output container and load it's children
var output = cntrs
.find(cntr => {
var metaNode = this.core.getMetaType(cntr),
metaName = this.core.getAttribute(metaNode, 'name');
return metaName === 'Outputs';
});
return this.core.loadChildren(output);
})
.then(dataNodes => {
hash = this.core.getAttribute(dataNodes[0], 'data');
return this.getOutputs(node);
})
.then(outputTuples => {
var outputs = outputTuples.map(tuple => tuple[2]),
paths;
Expand Down
4 changes: 2 additions & 2 deletions src/seeds/minimal/minimal.webgmex
Git LFS file not shown
4 changes: 2 additions & 2 deletions src/seeds/pipeline/pipeline.webgmex
Git LFS file not shown
4 changes: 2 additions & 2 deletions src/seeds/project/project.webgmex
Git LFS file not shown
22 changes: 20 additions & 2 deletions src/visualizers/panels/PipelineEditor/PipelineEditorControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ define([
CONN = {
SRC: 'src',
DST: 'dst'
};
},
DECORATORS = {
ArtifactLoader: 'DcOpDecorator'
},
WIDGET_NAME = 'EasyDAG';

PipelineEditorControl = function (options) {
EasyDAGControl.call(this, options);
Expand Down Expand Up @@ -150,6 +154,19 @@ define([
} // Ignore any other updates - ie, Inputs/Outputs containers
};

PipelineEditorControl.prototype._getNodeDecorator = function (nodeObj) {
var decoratorManager = this._client.decoratorManager,
decorator,
decoratorClass;

var base = this._client.getNode(nodeObj.getMetaTypeId()),
baseName = base && base.getAttribute('name');

decorator = DECORATORS[baseName] || this.DEFAULT_DECORATOR;
decoratorClass = decoratorManager.getDecoratorForWidget(decorator, WIDGET_NAME);
return decoratorClass;
};

// Override the getSuccessors method to look up successors by operations
// with input nodes of the selected node's output type (prioritize the
// valid nodes that are using an unused output type, if one exists, ow
Expand Down Expand Up @@ -428,7 +445,8 @@ define([

PipelineEditorControl.prototype._getTargetDirs = function (typeIds) {
// Find the directories containing these types
return this._client.getNode('').getChildrenIds()
return this._client.getNode(CONSTANTS.PROJECT_ROOT_ID).getChildrenIds()
// No referencing data meta types
.filter(id => {
var cMeta = this._client.getChildrenMeta(id),
validChildIds;
Expand Down
3 changes: 3 additions & 0 deletions webgme-setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@
},
"OpIntPtrDecorator": {
"src": "src/decorators/OpIntPtrDecorator"
},
"DcOpDecorator": {
"src": "src/decorators/DcOpDecorator"
}
},
"seeds": {
Expand Down