-
Notifications
You must be signed in to change notification settings - Fork 192
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
updated io tree response to add link type information #2033
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1d9d1e9
updated io tree response to add link type information
c80c377
updated further to handle multiple links between two nodes
34ec39e
Merge branch 'release_v0.12.3' into iotree
giovannipizzi 496a8e4
Merge branch 'release_v0.12.3' into iotree
ab3fc17
Merge branch 'iotree' of https://github.com/waychal/aiida_core into i…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -573,77 +573,100 @@ def get_node_shape(ntype): | |
qb = QueryBuilder() | ||
qb.append(Node, tag="main", project=['*'], | ||
filters=self._id_filter) | ||
qb.append(Node, tag="in", project=['*'], edge_project=['label'], | ||
qb.append(Node, tag="in", project=['*'], edge_project=['label', 'type'], | ||
input_of='main') | ||
|
||
input_node_pks = {} | ||
|
||
if qb.count() > 0: | ||
for input in qb.iterdict(): | ||
node = input['in']['*'] | ||
linktype = input['main--in']['label'] | ||
pk = node.pk | ||
uuid = node.uuid | ||
nodetype = node.type | ||
display_type = nodetype.split('.')[-2] | ||
description = node.get_desc() | ||
if description == '': | ||
description = node.type.split('.')[-2] | ||
|
||
nodes.append({ | ||
"id": nodeCount, | ||
"nodeid": pk, | ||
"nodeuuid": uuid, | ||
"nodetype": nodetype, | ||
"displaytype": display_type, | ||
"group": "inputs", | ||
"description": description, | ||
"linktype": linktype, | ||
"shape": get_node_shape(nodetype) | ||
}) | ||
linklabel = input['main--in']['label'] | ||
linktype = input['main--in']['type'] | ||
|
||
# add node if it is not present | ||
if pk not in input_node_pks.keys(): | ||
input_node_pks[pk] = nodeCount | ||
uuid = node.uuid | ||
nodetype = node.type | ||
display_type = nodetype.split('.')[-2] | ||
description = node.get_desc() | ||
if description == '': | ||
description = node.type.split('.')[-2] | ||
|
||
nodes.append({ | ||
"id": nodeCount, | ||
"nodeid": pk, | ||
"nodeuuid": uuid, | ||
"nodetype": nodetype, | ||
"displaytype": display_type, | ||
"group": "inputs", | ||
"description": description, | ||
"linklabel": linklabel, | ||
"linktype": linktype, | ||
"shape": get_node_shape(nodetype) | ||
}) | ||
nodeCount += 1 | ||
|
||
from_edge = input_node_pks[pk] | ||
edges.append({ | ||
"from": nodeCount, | ||
"from": from_edge, | ||
"to": 0, | ||
"arrows": "to", | ||
"color": {"inherit": 'from'}, | ||
"linktype": linktype, | ||
"label": linktype, | ||
}) | ||
nodeCount += 1 | ||
|
||
|
||
# get all outputs | ||
qb = QueryBuilder() | ||
qb.append(Node, tag="main", project=['*'], | ||
filters=self._id_filter) | ||
qb.append(Node, tag="out", project=['*'], edge_project=['label'], | ||
qb.append(Node, tag="out", project=['*'], edge_project=['label', 'type'], | ||
output_of='main') | ||
|
||
output_node_pks = {} | ||
|
||
if qb.count() > 0: | ||
for output in qb.iterdict(): | ||
node = output['out']['*'] | ||
linktype = output['main--out']['label'] | ||
pk = node.pk | ||
uuid = node.uuid | ||
nodetype = node.type | ||
display_type = nodetype.split('.')[-2] | ||
description = node.get_desc() | ||
if description == '': | ||
description = node.type.split('.')[-2] | ||
|
||
nodes.append({ | ||
"id": nodeCount, | ||
"nodeid": pk, | ||
"nodeuuid": uuid, | ||
"nodetype": nodetype, | ||
"displaytype": display_type, | ||
"group": "outputs", | ||
"description": description, | ||
"linktype": linktype, | ||
"shape": get_node_shape(nodetype) | ||
}) | ||
linklabel = output['main--out']['label'] | ||
linktype = output['main--out']['type'] | ||
|
||
# add node if it is not present | ||
if pk not in output_node_pks.keys(): | ||
output_node_pks[pk] = nodeCount | ||
uuid = node.uuid | ||
nodetype = node.type | ||
display_type = nodetype.split('.')[-2] | ||
description = node.get_desc() | ||
if description == '': | ||
description = node.type.split('.')[-2] | ||
|
||
nodes.append({ | ||
"id": nodeCount, | ||
"nodeid": pk, | ||
"nodeuuid": uuid, | ||
"nodetype": nodetype, | ||
"displaytype": display_type, | ||
"group": "outputs", | ||
"description": description, | ||
"linklabel": linklabel, | ||
"linktype": linktype, | ||
"shape": get_node_shape(nodetype) | ||
}) | ||
nodeCount += 1 | ||
|
||
to_edge = output_node_pks[pk] | ||
edges.append({ | ||
"from": 0, | ||
"to": nodeCount, | ||
"to": to_edge, | ||
"arrows": "to", | ||
"color": {"inherit": 'to'}, | ||
"linktype": linktype | ||
"label": linktype | ||
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. Same comment as above |
||
}) | ||
nodeCount += 1 | ||
|
||
|
||
return {"nodes": nodes, "edges": edges} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The linklabel should be moved here from
nodes
, and this should remain to be called linktypeThere 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.
'label' is the name used by JS library to display value on edge. This endpoint is specifically written for materials cloud and passes the data in format used in MC. Otherwise we can reprocess the data completely in frontend again before passing it to the visualization library.