Skip to content

Commit 8c8186a

Browse files
authored
Merge pull request #2526 from danielaskdd/hotfix-neo4j-memgraph
Hot Fix AttributeError in Neo4JStorage and MemgraphStorage when using storage specified workspace env var
2 parents dccf1ef + 736d7f7 commit 8c8186a

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

lightrag/kg/memgraph_impl.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ class MemgraphStorage(BaseGraphStorage):
3636
def __init__(self, namespace, global_config, embedding_func, workspace=None):
3737
# Priority: 1) MEMGRAPH_WORKSPACE env 2) user arg 3) default 'base'
3838
memgraph_workspace = os.environ.get("MEMGRAPH_WORKSPACE")
39+
original_workspace = workspace # Save original value for logging
3940
if memgraph_workspace and memgraph_workspace.strip():
40-
logger.info(
41-
f"Using MEMGRAPH_WORKSPACE environment variable: '{memgraph_workspace}' (overriding '{self.workspace}/{self.namespace}')"
42-
)
4341
workspace = memgraph_workspace
4442

4543
if not workspace or not str(workspace).strip():
@@ -51,6 +49,13 @@ def __init__(self, namespace, global_config, embedding_func, workspace=None):
5149
global_config=global_config,
5250
embedding_func=embedding_func,
5351
)
52+
53+
# Log after super().__init__() to ensure self.workspace is initialized
54+
if memgraph_workspace and memgraph_workspace.strip():
55+
logger.info(
56+
f"Using MEMGRAPH_WORKSPACE environment variable: '{memgraph_workspace}' (overriding '{original_workspace}/{namespace}')"
57+
)
58+
5459
self._driver = None
5560

5661
def _get_workspace_label(self) -> str:

lightrag/kg/neo4j_impl.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ class Neo4JStorage(BaseGraphStorage):
6767
def __init__(self, namespace, global_config, embedding_func, workspace=None):
6868
# Read env and override the arg if present
6969
neo4j_workspace = os.environ.get("NEO4J_WORKSPACE")
70+
original_workspace = workspace # Save original value for logging
7071
if neo4j_workspace and neo4j_workspace.strip():
71-
logger.info(
72-
f"Using NEO4J_WORKSPACE environment variable: '{neo4j_workspace}' (overriding '{self.workspace}/{self.namespace}')"
73-
)
7472
workspace = neo4j_workspace
7573

7674
# Default to 'base' when both arg and env are empty
@@ -83,6 +81,13 @@ def __init__(self, namespace, global_config, embedding_func, workspace=None):
8381
global_config=global_config,
8482
embedding_func=embedding_func,
8583
)
84+
85+
# Log after super().__init__() to ensure self.workspace is initialized
86+
if neo4j_workspace and neo4j_workspace.strip():
87+
logger.info(
88+
f"Using NEO4J_WORKSPACE environment variable: '{neo4j_workspace}' (overriding '{original_workspace}/{namespace}')"
89+
)
90+
8691
self._driver = None
8792

8893
def _get_workspace_label(self) -> str:

0 commit comments

Comments
 (0)