From f444ae21b4fc242e819723e616c6ea7c2a05d118 Mon Sep 17 00:00:00 2001 From: hajdul88 <52442977+hajdul88@users.noreply.github.com> Date: Wed, 4 Dec 2024 18:14:08 +0100 Subject: [PATCH] fix: adds back the ids to the nodes after node_link_graph --- cognee/infrastructure/databases/graph/networkx/adapter.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cognee/infrastructure/databases/graph/networkx/adapter.py b/cognee/infrastructure/databases/graph/networkx/adapter.py index d249b6336..aadad639f 100644 --- a/cognee/infrastructure/databases/graph/networkx/adapter.py +++ b/cognee/infrastructure/databases/graph/networkx/adapter.py @@ -274,6 +274,9 @@ async def load_graph_from_file(self, file_path: str = None): edge["updated_at"] = datetime.strptime(edge["updated_at"], "%Y-%m-%dT%H:%M:%S.%f%z") self.graph = nx.readwrite.json_graph.node_link_graph(graph_data) + + for node_id, node_data in self.graph.nodes(data=True): + node_data['id'] = node_id else: # Log that the file does not exist and an empty graph is initialized logger.warning("File %s not found. Initializing an empty graph.", file_path)