Skip to content

Commit

Permalink
Added import torch action to arch editor. Fixes #447 (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
brollb authored Jul 7, 2016
1 parent 56a0b78 commit 14c0af8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/plugins/ImportTorch/ImportTorch.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,17 @@ define([

this.blobClient.getMetadata(srcHash)
.then(mdata => { // Create the new model
var name = mdata.name.replace('.lua', '');
this.tgtNode = this.core.createNode({
base: this.META.Architecture,
parent: this.activeNode
});
this.core.setAttribute(this.tgtNode, 'name', name);
// If the current node is an architecture, assume we are just extending it
this.importedName = mdata.name.replace('.lua', '');
if (this.isMetaTypeOf(this.activeNode, this.META.Architecture)) {
this.tgtNode = this.activeNode;
} else { // Create a new architecture
this.tgtNode = this.core.createNode({
base: this.META.Architecture,
parent: this.activeNode
});
this.core.setAttribute(this.tgtNode, 'name', this.importedName);
}
return this.blobClient.getObjectAsString(srcHash);
})
.then(src => { // Retrieved the source code
Expand All @@ -81,7 +86,7 @@ define([
return this.save('ImportTorch updated model.');
})
.then(() => { // changes saved successfully
var name = this.core.getAttribute(this.tgtNode, 'name');
var name = this.importedName;
this.result.setSuccess(true);
this.createMessage(this.tgtNode,
`Successfully imported ${name} architecture`);
Expand Down
7 changes: 7 additions & 0 deletions src/visualizers/panels/ForgeActionButton/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ define([
this.addOperation();
}
}
],
Architecture: [
{
name: 'Import Torch Architecture',
icon: 'swap_vert',
action: importTorch
}
]
};
});

0 comments on commit 14c0af8

Please sign in to comment.