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

Incorporate Plotly JSON to metamodel (Closes #1745) #1747

Merged
merged 24 commits into from
Jul 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d4bd938
WIP- Inital Version of plotly json in metamodel
umesh-timalsina Jul 7, 2020
6d9a60d
WIP- update devProject; increate timeout for devProject
umesh-timalsina Jul 8, 2020
3a9d140
WIP- Fix node id from test seeds
umesh-timalsina Jul 8, 2020
578e533
Fix releases.jsonl
umesh-timalsina Jul 8, 2020
f40d843
WIP- Remove Line node creation from ExecuteJob.spec.js
umesh-timalsina Jul 8, 2020
3e444f9
Fix timeout in ExecutePipeline.spec.js and fix releases.jsonl
umesh-timalsina Jul 8, 2020
f070af0
Merge remote-tracking branch 'origin/master' into 1745-ploty-metamodel
umesh-timalsina Jul 9, 2020
ce2807b
WIP-Add 3D support for DeepforgePlotlyRenderer
umesh-timalsina Jul 10, 2020
fbfc9ab
WIP- Fix np masked array imports in plotly_backend.py
umesh-timalsina Jul 10, 2020
183dfb8
Merge remote-tracking branch 'origin/master' into 1745-ploty-metamodel
umesh-timalsina Jul 11, 2020
4469b02
WIP-Refactor fix HelloWorld Job execution ID
umesh-timalsina Jul 13, 2020
b06bd55
WIP- Increase timeout for sciserver to 10 minutes
umesh-timalsina Jul 13, 2020
6d6a287
Merge remote-tracking branch 'origin/master', Fix Updates
umesh-timalsina Jul 20, 2020
ab4bdac
WIP- add PR refactors, pin matplotlib
umesh-timalsina Jul 21, 2020
74e8443
Merge remote-tracking branch 'origin/master' into 1745-ploty-metamodel
umesh-timalsina Jul 21, 2020
a1579a7
merge branch master
umesh-timalsina Jul 22, 2020
ac12c61
WIP- Add beforeLibraryUpdates flag to UpdateGraphContainment
umesh-timalsina Jul 22, 2020
2340637
Merge remote-tracking branch 'origin/master' into 1745-ploty-metamodel
umesh-timalsina Jul 23, 2020
122d35d
Add Metadata node as Mixin for correct extraction of older seeds
umesh-timalsina Jul 23, 2020
4402371
Filter provenance nodes from mixin application; Add fix for #1799
umesh-timalsina Jul 23, 2020
ff7d087
WIP- Fix version check in UpdateGraphContainment
umesh-timalsina Jul 23, 2020
4d1e0fa
WIP- Cover cases for layout.title as object
umesh-timalsina Jul 23, 2020
896b7a2
WIP- displayTitle fix for undefined cases
umesh-timalsina Jul 23, 2020
9df083a
WIP- adjust height of a single plot; check falsy values in data attri…
umesh-timalsina Jul 24, 2020
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
1 change: 1 addition & 0 deletions environment.worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dependencies:
- pillow
- matplotlib==3.2.2
- simplejson
- plotly
83 changes: 77 additions & 6 deletions src/common/updates/Updates.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,51 @@
/* globals define */
define([
'deepforge/storage/index',
'deepforge/viz/PlotlyDescExtractor',
'deepforge/viz/FigureExtractor',
'./Version',
'q'
], function(
Storage,
PlotlyDescExtractor,
FigureExtractor,
Version,
Q
) {
const GRAPH = 'Graph';
const getGraphNodes = async function(core, rootNode, graphNodes=[]) {
const children = await core.loadChildren(rootNode);
for(let i = 0; i < children.length; i++) {
if (core.getAttribute(children[i], 'name') === GRAPH && !core.isMetaNode(children[i])) {
graphNodes.push(children[i]);
}
await getGraphNodes(core, children[i], graphNodes);
}
};

const addMetadataMixinToNodeSubTree = async function(core, META, node) {
const METADATA_NODE_PATH = core.getPath(META['pipeline.Metadata']);
const IMPLICIT_OPERATION_NODE = META['pipeline.ImplicitOperation'];
const graphNodeChildren = (await core.loadSubTree(node))
.filter(node => {
return IMPLICIT_OPERATION_NODE ?
!core.isTypeOf(node, IMPLICIT_OPERATION_NODE) :
true;
});

graphNodeChildren.forEach(node => {
core.addMixin(node, METADATA_NODE_PATH);
});
};

const getPipelineLibraryVersion = function(core, rootNode) {
const pipelineRoot = core.getLibraryRoot(rootNode, 'pipeline');
const hasPipelineLibrary = !!pipelineRoot;
if (hasPipelineLibrary) {
const versionString = core.getAttribute(pipelineRoot, 'version');
return new Version(versionString);
}
};

const allUpdates = [
{
Expand Down Expand Up @@ -48,12 +86,9 @@ define([
{
name: 'UpdateDataNodesToUserAssets',
isNeeded: async function(core, rootNode) {
const pipelineRoot = core.getLibraryRoot(rootNode, 'pipeline');
const hasPipelineLibrary = !!pipelineRoot;
if (hasPipelineLibrary) {
const versionString = core.getAttribute(pipelineRoot, 'version');
const version = new Version(versionString);
return version.lessThan(new Version('0.13.0'));
const pipelineLibraryVersion = getPipelineLibraryVersion(core, rootNode);
if(pipelineLibraryVersion) {
return pipelineLibraryVersion.lessThan(new Version('0.13.0'));
}
},
apply: async function(core, rootNode, META) {
Expand All @@ -72,6 +107,42 @@ define([
}
}
}
},
{
name: 'UpdateGraphContainment',
beforeLibraryUpdates: true,
isNeeded: async function(core, rootNode) {
const pipelineLibraryVersion = getPipelineLibraryVersion(core, rootNode);
if (pipelineLibraryVersion) {
return pipelineLibraryVersion.lessThan(new Version('0.22.0')) &&
pipelineLibraryVersion.greaterThan(new Version('0.19.1'));
}
},
apply: async function(core, rootNode, META) {
let graphNodes = [];
await getGraphNodes(core, rootNode, graphNodes);
const coreFigureExtractor = new FigureExtractor.CoreFigureExtractor(core, rootNode);
const pipelineVersion = getPipelineLibraryVersion(core, rootNode);
const shouldAddMetadataMixin = pipelineVersion ?
pipelineVersion.lessThan(new Version('0.21.1')) :
false;

for (let i = 0; i < graphNodes.length; i++){
const graphNode = graphNodes[i];
if(shouldAddMetadataMixin){
await addMetadataMixinToNodeSubTree(core, META, graphNode);
}
const desc = await coreFigureExtractor.extract(graphNode);
const plotlyJSON = PlotlyDescExtractor.descToPlotlyJSON(desc);
const parentNode = core.getParent(graphNode);
const updatedGraphNode = core.createNode({
parent: parentNode,
base: META['pipeline.Graph']
});
core.setAttribute(updatedGraphNode, 'data', JSON.stringify(plotlyJSON));
core.deleteNode(graphNode);
}
}
}
];

Expand Down
20 changes: 3 additions & 17 deletions src/plugins/ExecuteJob/metadata/Figure.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
/* globals define */
define([
'./Metadata',
'./Metadata'
], function(
Metadata,
Metadata
) {
class Figure extends Metadata {
async update(state) {
this.core.setAttribute(this.node, 'title', state.title);
await this.clearSubGraphs();

state.axes.forEach(axes => {
const axesNode = this.core.createNode({
parent: this.node,
base: axes.is3D ? this.META.Plot3D : this.META.Plot2D
});
this.setAxesProperties(axesNode, axes);
this.addAxesLines(axesNode, this.node, axes);
if(!axes.is3D){
this.addAxesImage(axesNode, this.node, axes);
}
this.addAxesScatterPoints(axesNode, this.node, axes);
});
this.core.setAttribute(this.node, 'data', JSON.stringify(state));
}

setAxesProperties(axesNode, axes){
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/GenerateJob/GenerateJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ define([
this.result.setSuccess(true);
this.result.addArtifact(hash);
callback(null, this.result);
};
};

GenerateJob.prototype.createRunScript = async function (files) {
let runDebug = Templates.RUN_DEBUG;
Expand Down Expand Up @@ -291,7 +291,7 @@ define([
files.addFile('config.json', JSON.stringify(configs));
files.addFile('start.js', Templates.START);
files.addFile('utils.build.js', Templates.UTILS);
files.addFile('backend_deepforge.py', Templates.MATPLOTLIB_BACKEND);
files.addFile('plotly_backend.py', Templates.MATPLOTLIB_BACKEND);

inputs.forEach(pair => {
const dataInfo = this.core.getAttribute(pair[2], 'data');
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/GenerateJob/templates/backend_deepforge.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,9 @@ def draw(self):
"""
Draw the figure using the renderer
"""
self.send_deepforge_update()
renderer = RendererTemplate(self.figure.dpi)
self.figure.draw(renderer)
self.send_deepforge_update()

def send_deepforge_update(self):
state = self.figure_to_state()
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/GenerateJob/templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ define([
'text!./run-debug.js',
'text!./main.ejs',
'text!./deepforge.ejs',
'text!./backend_deepforge.py',
'text!./plotly_backend.py',
'text!./deepforge__init__.py',
'text!./serialize.ejs',
'text!./deserialize.ejs',
Expand Down
Loading