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

👌 IMPROVE: Allow Graph to be used by any backend #5200

Merged
merged 2 commits into from
Oct 27, 2021
Merged
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
9 changes: 5 additions & 4 deletions aiida/tools/visualization/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,16 +428,17 @@ def edges(self):
"""return a copy of the edges"""
return self._edges.copy()

@staticmethod
def _load_node(node):
def _load_node(self, node):
""" load a node (if not already loaded)

:param node: node or node pk/uuid
:type node: int or str or aiida.orm.nodes.node.Node
:returns: aiida.orm.nodes.node.Node
"""
if isinstance(node, (int, str)):
return orm.load_node(node)
if isinstance(node, int):
return orm.Node.Collection.get_cached(orm.Node, self._backend).get(pk=node)
if isinstance(node, str):
return orm.Node.Collection.get_cached(orm.Node, self._backend).get(uuid=node)
return node

@staticmethod
Expand Down