From 5530589bad1362a29f54c020570e06459f472ebe Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Thu, 28 Oct 2021 00:27:17 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20Allow=20`Graph`=20to?= =?UTF-8?q?=20be=20used=20by=20any=20backend=20(#5200)?= 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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/aiida/tools/visualization/graph.py b/aiida/tools/visualization/graph.py index b864ad28bb..b11ce15ff7 100644 --- a/aiida/tools/visualization/graph.py +++ b/aiida/tools/visualization/graph.py @@ -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