From c66fc3483a9d89de0f3cbb71edd13526e2007d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Gil=20L=C3=B3pez?= Date: Fri, 22 Aug 2025 02:52:51 +0000 Subject: [PATCH] fix: Implement PipelineNotInitializedError usage in get_namespace_data - Add PipelineNotInitializedError import to shared_storage.py - Raise PipelineNotInitializedError when accessing uninitialized pipeline_status namespace - This provides clear error messages to users about initialization requirements - Other namespaces continue to be created dynamically as before Addresses review feedback from PR #1978 about unused exception class --- lightrag/kg/shared_storage.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lightrag/kg/shared_storage.py b/lightrag/kg/shared_storage.py index 228bf272..10c69b14 100644 --- a/lightrag/kg/shared_storage.py +++ b/lightrag/kg/shared_storage.py @@ -8,6 +8,8 @@ import time import logging from typing import Any, Dict, List, Optional, Union, TypeVar, Generic +from lightrag.exceptions import PipelineNotInitializedError + # Define a direct print function for critical logs that must be visible in all processes def direct_log(message, enable_output: bool = False, level: str = "DEBUG"): @@ -1203,6 +1205,13 @@ async def get_namespace_data(namespace: str) -> Dict[str, Any]: async with get_internal_lock(): if namespace not in _shared_dicts: + # Special handling for pipeline_status namespace + if namespace == "pipeline_status": + # Check if pipeline_status should have been initialized but wasn't + # This helps users understand they need to call initialize_pipeline_status() + raise PipelineNotInitializedError(namespace) + + # For other namespaces, create them dynamically as before if _is_multiprocess and _manager is not None: _shared_dicts[namespace] = _manager.dict() else: