Merge pull request #2526 from danielaskdd/hotfix-neo4j-memgraph

Hot Fix AttributeError in Neo4JStorage and MemgraphStorage when using storage specified workspace env var
This commit is contained in:
Daniel.y
2025-12-23 09:03:31 +08:00
committed by GitHub
2 changed files with 16 additions and 6 deletions

View File

@@ -36,10 +36,8 @@ class MemgraphStorage(BaseGraphStorage):
def __init__(self, namespace, global_config, embedding_func, workspace=None):
# Priority: 1) MEMGRAPH_WORKSPACE env 2) user arg 3) default 'base'
memgraph_workspace = os.environ.get("MEMGRAPH_WORKSPACE")
original_workspace = workspace # Save original value for logging
if memgraph_workspace and memgraph_workspace.strip():
logger.info(
f"Using MEMGRAPH_WORKSPACE environment variable: '{memgraph_workspace}' (overriding '{self.workspace}/{self.namespace}')"
)
workspace = memgraph_workspace
if not workspace or not str(workspace).strip():
@@ -51,6 +49,13 @@ class MemgraphStorage(BaseGraphStorage):
global_config=global_config,
embedding_func=embedding_func,
)
# Log after super().__init__() to ensure self.workspace is initialized
if memgraph_workspace and memgraph_workspace.strip():
logger.info(
f"Using MEMGRAPH_WORKSPACE environment variable: '{memgraph_workspace}' (overriding '{original_workspace}/{namespace}')"
)
self._driver = None
def _get_workspace_label(self) -> str:

View File

@@ -67,10 +67,8 @@ class Neo4JStorage(BaseGraphStorage):
def __init__(self, namespace, global_config, embedding_func, workspace=None):
# Read env and override the arg if present
neo4j_workspace = os.environ.get("NEO4J_WORKSPACE")
original_workspace = workspace # Save original value for logging
if neo4j_workspace and neo4j_workspace.strip():
logger.info(
f"Using NEO4J_WORKSPACE environment variable: '{neo4j_workspace}' (overriding '{self.workspace}/{self.namespace}')"
)
workspace = neo4j_workspace
# Default to 'base' when both arg and env are empty
@@ -83,6 +81,13 @@ class Neo4JStorage(BaseGraphStorage):
global_config=global_config,
embedding_func=embedding_func,
)
# Log after super().__init__() to ensure self.workspace is initialized
if neo4j_workspace and neo4j_workspace.strip():
logger.info(
f"Using NEO4J_WORKSPACE environment variable: '{neo4j_workspace}' (overriding '{original_workspace}/{namespace}')"
)
self._driver = None
def _get_workspace_label(self) -> str: