From 39836bdeb0f95cb01e69156b3780c34774cc0a7f Mon Sep 17 00:00:00 2001 From: Chris Sewell <chrisj_sewell@hotmail.com> Date: Wed, 27 Oct 2021 23:46:27 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20Allow=20`Graph`?= =?UTF-8?q?=20to=20be=20used=20by=20any=20backend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a follow-up to #5186, to ensure `Graph` always uses the initialised `Backend`. --- aiida/tools/visualization/graph.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aiida/tools/visualization/graph.py b/aiida/tools/visualization/graph.py index b864ad28bb..7ebff435ca 100644 --- a/aiida/tools/visualization/graph.py +++ b/aiida/tools/visualization/graph.py @@ -436,8 +436,10 @@ def _load_node(node): :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 From c2255991f3fc9b7a93eb2dcc406ee1169adda506 Mon Sep 17 00:00:00 2001 From: Chris Sewell <chrisj_sewell@hotmail.com> Date: Thu, 28 Oct 2021 00:07:03 +0200 Subject: [PATCH 2/2] Update graph.py --- aiida/tools/visualization/graph.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/aiida/tools/visualization/graph.py b/aiida/tools/visualization/graph.py index 7ebff435ca..b11ce15ff7 100644 --- a/aiida/tools/visualization/graph.py +++ b/aiida/tools/visualization/graph.py @@ -428,8 +428,7 @@ 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