-
Notifications
You must be signed in to change notification settings - Fork 73
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
Changes from 13 commits
d4bd938
6d9a60d
3a9d140
578e533
f40d843
3e444f9
f070af0
ce2807b
fbfc9ab
183dfb8
4469b02
b06bd55
6d6a287
ab4bdac
74e8443
a1579a7
ac12c61
2340637
122d35d
4402371
ff7d087
4d1e0fa
896b7a2
9df083a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ dependencies: | |
- pillow | ||
- matplotlib | ||
- simplejson | ||
- plotly |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
/* globals define */ | ||
define([ | ||
'deepforge/storage/index', | ||
'deepforge/viz/PlotlyDescExtractor', | ||
'deepforge/viz/FigureExtractor', | ||
'./Version', | ||
'q' | ||
], function( | ||
Storage, | ||
PlotlyDescExtractor, | ||
FigureExtractor, | ||
Version, | ||
Q | ||
) { | ||
const GRAPH = 'Graph'; | ||
const getGraphNode = 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[core.getPath(children[i])] = children[i]; | ||
} | ||
await getGraphNode(core, children[i], graphNodes); | ||
} | ||
}; | ||
|
||
const allUpdates = [ | ||
{ | ||
|
@@ -21,7 +35,7 @@ define([ | |
}); | ||
}, | ||
apply: function(core, rootNode, META) { | ||
// Create 'MyUtilities' node | ||
// Create 'MyUtilities' nodeupdate | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why was this changed? It seems like it was probably unintentional. |
||
const utils = core.createNode({ | ||
parent: rootNode, | ||
base: META.FCO | ||
|
@@ -72,6 +86,37 @@ define([ | |
} | ||
} | ||
} | ||
}, | ||
{ | ||
name: 'UpdateGraphContainment', | ||
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.22.0')) && | ||
version.greaterThan(new Version('0.19.1')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if it is below 0.19.1? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes to the |
||
} | ||
}, | ||
apply: async function(core, rootNode, META) { | ||
let graphNodes = {}; | ||
await getGraphNode(core, rootNode, graphNodes); | ||
const graphNodeKeys = Object.keys(graphNodes); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't look like you use |
||
const coreFigureExtractor = new FigureExtractor.CoreFigureExtractor(core, rootNode); | ||
for (let i = 0; i < graphNodeKeys.length; i++){ | ||
const graphNode = graphNodes[graphNodeKeys[i]]; | ||
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); | ||
} | ||
} | ||
} | ||
]; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rootNode
only appears to be the root node on the first call. This should probably benode
instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, why are you setting the graph nodes in a dictionary rather than simply returning a list of graph nodes from the given subtree?
It would probably be good to rename the function to
getGraphNodes
or something so it is obvious that it returns multiple nodes.