Skip to content

Commit

Permalink
πŸ‘Œ IMPROVE: Allow Graph to be used by any backend (#5200)
Browse files Browse the repository at this point in the history
This is a follow-up to #5186,
to ensure `Graph` always uses the initialised `Backend`.
  • Loading branch information
chrisjsewell authored Oct 27, 2021
1 parent ea3ab28 commit 5530589
Showing 1 changed file with 5 additions and 4 deletions.
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

0 comments on commit 5530589

Please sign in to comment.