Skip to content

Commit 95e1fb1

Browse files
committed
Remove final_namespace attribute for in-memory storage and use namespace in clean_llm_query_cache.py
1 parent 7ed0eac commit 95e1fb1

File tree

5 files changed

+7
-17
lines changed

5 files changed

+7
-17
lines changed

lightrag/kg/faiss_impl.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,9 @@ def __post_init__(self):
4242
if self.workspace:
4343
# Include workspace in the file path for data isolation
4444
workspace_dir = os.path.join(working_dir, self.workspace)
45-
self.final_namespace = f"{self.workspace}_{self.namespace}"
4645

4746
else:
4847
# Default behavior when workspace is empty
49-
self.final_namespace = self.namespace
5048
workspace_dir = working_dir
5149
self.workspace = ""
5250

@@ -74,11 +72,11 @@ async def initialize(self):
7472
"""Initialize storage data"""
7573
# Get the update flag for cross-process update notification
7674
self.storage_updated = await get_update_flag(
77-
self.final_namespace, workspace=self.workspace
75+
self.namespace, workspace=self.workspace
7876
)
7977
# Get the storage lock for use in other methods
8078
self._storage_lock = get_namespace_lock(
81-
self.final_namespace, workspace=self.workspace
79+
self.namespace, workspace=self.workspace
8280
)
8381

8482
async def _get_index(self):
@@ -404,9 +402,7 @@ async def index_done_callback(self) -> None:
404402
# Save data to disk
405403
self._save_faiss_index()
406404
# Notify other processes that data has been updated
407-
await set_all_update_flags(
408-
self.final_namespace, workspace=self.workspace
409-
)
405+
await set_all_update_flags(self.namespace, workspace=self.workspace)
410406
# Reset own update flag to avoid self-reloading
411407
self.storage_updated.value = False
412408
except Exception as e:
@@ -533,9 +529,7 @@ async def drop(self) -> dict[str, str]:
533529
self._load_faiss_index()
534530

535531
# Notify other processes
536-
await set_all_update_flags(
537-
self.final_namespace, workspace=self.workspace
538-
)
532+
await set_all_update_flags(self.namespace, workspace=self.workspace)
539533
self.storage_updated.value = False
540534

541535
logger.info(

lightrag/kg/json_doc_status_impl.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@ def __post_init__(self):
3535
if self.workspace:
3636
# Include workspace in the file path for data isolation
3737
workspace_dir = os.path.join(working_dir, self.workspace)
38-
self.final_namespace = f"{self.workspace}_{self.namespace}"
3938
else:
4039
# Default behavior when workspace is empty
4140
workspace_dir = working_dir
42-
self.final_namespace = self.namespace
4341
self.workspace = ""
4442

4543
os.makedirs(workspace_dir, exist_ok=True)

lightrag/kg/json_kv_impl.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ def __post_init__(self):
3030
if self.workspace:
3131
# Include workspace in the file path for data isolation
3232
workspace_dir = os.path.join(working_dir, self.workspace)
33-
self.final_namespace = f"{self.workspace}_{self.namespace}"
3433
else:
3534
# Default behavior when workspace is empty
3635
workspace_dir = working_dir
37-
self.final_namespace = self.namespace
3836
self.workspace = ""
3937

4038
os.makedirs(workspace_dir, exist_ok=True)

lightrag/kg/networkx_impl.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@ def __post_init__(self):
4141
if self.workspace:
4242
# Include workspace in the file path for data isolation
4343
workspace_dir = os.path.join(working_dir, self.workspace)
44-
self.final_namespace = f"{self.workspace}_{self.namespace}"
4544
else:
4645
# Default behavior when workspace is empty
47-
self.final_namespace = self.namespace
4846
workspace_dir = working_dir
4947
self.workspace = ""
5048

lightrag/tools/clean_llm_query_cache.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,9 @@ async def delete_query_caches_json(
463463

464464
# CRITICAL: Set update flag so changes persist to disk
465465
# Without this, deletions remain in-memory only and are lost on exit
466-
await set_all_update_flags(storage.final_namespace, storage.workspace)
466+
await set_all_update_flags(
467+
storage.namespace, workspace=storage.workspace
468+
)
467469

468470
# Success
469471
stats.successful_batches += 1

0 commit comments

Comments
 (0)