Remove final_namespace attribute for in-memory storage and use namespace in clean_llm_query_cache.py
This commit is contained in:
parent
7ed0eac4c9
commit
95e1fb1612
5 changed files with 7 additions and 17 deletions
|
|
@ -42,11 +42,9 @@ class FaissVectorDBStorage(BaseVectorStorage):
|
||||||
if self.workspace:
|
if self.workspace:
|
||||||
# Include workspace in the file path for data isolation
|
# Include workspace in the file path for data isolation
|
||||||
workspace_dir = os.path.join(working_dir, self.workspace)
|
workspace_dir = os.path.join(working_dir, self.workspace)
|
||||||
self.final_namespace = f"{self.workspace}_{self.namespace}"
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Default behavior when workspace is empty
|
# Default behavior when workspace is empty
|
||||||
self.final_namespace = self.namespace
|
|
||||||
workspace_dir = working_dir
|
workspace_dir = working_dir
|
||||||
self.workspace = ""
|
self.workspace = ""
|
||||||
|
|
||||||
|
|
@ -74,11 +72,11 @@ class FaissVectorDBStorage(BaseVectorStorage):
|
||||||
"""Initialize storage data"""
|
"""Initialize storage data"""
|
||||||
# Get the update flag for cross-process update notification
|
# Get the update flag for cross-process update notification
|
||||||
self.storage_updated = await get_update_flag(
|
self.storage_updated = await get_update_flag(
|
||||||
self.final_namespace, workspace=self.workspace
|
self.namespace, workspace=self.workspace
|
||||||
)
|
)
|
||||||
# Get the storage lock for use in other methods
|
# Get the storage lock for use in other methods
|
||||||
self._storage_lock = get_namespace_lock(
|
self._storage_lock = get_namespace_lock(
|
||||||
self.final_namespace, workspace=self.workspace
|
self.namespace, workspace=self.workspace
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _get_index(self):
|
async def _get_index(self):
|
||||||
|
|
@ -404,9 +402,7 @@ class FaissVectorDBStorage(BaseVectorStorage):
|
||||||
# Save data to disk
|
# Save data to disk
|
||||||
self._save_faiss_index()
|
self._save_faiss_index()
|
||||||
# Notify other processes that data has been updated
|
# Notify other processes that data has been updated
|
||||||
await set_all_update_flags(
|
await set_all_update_flags(self.namespace, workspace=self.workspace)
|
||||||
self.final_namespace, workspace=self.workspace
|
|
||||||
)
|
|
||||||
# Reset own update flag to avoid self-reloading
|
# Reset own update flag to avoid self-reloading
|
||||||
self.storage_updated.value = False
|
self.storage_updated.value = False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -533,9 +529,7 @@ class FaissVectorDBStorage(BaseVectorStorage):
|
||||||
self._load_faiss_index()
|
self._load_faiss_index()
|
||||||
|
|
||||||
# Notify other processes
|
# Notify other processes
|
||||||
await set_all_update_flags(
|
await set_all_update_flags(self.namespace, workspace=self.workspace)
|
||||||
self.final_namespace, workspace=self.workspace
|
|
||||||
)
|
|
||||||
self.storage_updated.value = False
|
self.storage_updated.value = False
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,9 @@ class JsonDocStatusStorage(DocStatusStorage):
|
||||||
if self.workspace:
|
if self.workspace:
|
||||||
# Include workspace in the file path for data isolation
|
# Include workspace in the file path for data isolation
|
||||||
workspace_dir = os.path.join(working_dir, self.workspace)
|
workspace_dir = os.path.join(working_dir, self.workspace)
|
||||||
self.final_namespace = f"{self.workspace}_{self.namespace}"
|
|
||||||
else:
|
else:
|
||||||
# Default behavior when workspace is empty
|
# Default behavior when workspace is empty
|
||||||
workspace_dir = working_dir
|
workspace_dir = working_dir
|
||||||
self.final_namespace = self.namespace
|
|
||||||
self.workspace = ""
|
self.workspace = ""
|
||||||
|
|
||||||
os.makedirs(workspace_dir, exist_ok=True)
|
os.makedirs(workspace_dir, exist_ok=True)
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,9 @@ class JsonKVStorage(BaseKVStorage):
|
||||||
if self.workspace:
|
if self.workspace:
|
||||||
# Include workspace in the file path for data isolation
|
# Include workspace in the file path for data isolation
|
||||||
workspace_dir = os.path.join(working_dir, self.workspace)
|
workspace_dir = os.path.join(working_dir, self.workspace)
|
||||||
self.final_namespace = f"{self.workspace}_{self.namespace}"
|
|
||||||
else:
|
else:
|
||||||
# Default behavior when workspace is empty
|
# Default behavior when workspace is empty
|
||||||
workspace_dir = working_dir
|
workspace_dir = working_dir
|
||||||
self.final_namespace = self.namespace
|
|
||||||
self.workspace = ""
|
self.workspace = ""
|
||||||
|
|
||||||
os.makedirs(workspace_dir, exist_ok=True)
|
os.makedirs(workspace_dir, exist_ok=True)
|
||||||
|
|
|
||||||
|
|
@ -41,10 +41,8 @@ class NetworkXStorage(BaseGraphStorage):
|
||||||
if self.workspace:
|
if self.workspace:
|
||||||
# Include workspace in the file path for data isolation
|
# Include workspace in the file path for data isolation
|
||||||
workspace_dir = os.path.join(working_dir, self.workspace)
|
workspace_dir = os.path.join(working_dir, self.workspace)
|
||||||
self.final_namespace = f"{self.workspace}_{self.namespace}"
|
|
||||||
else:
|
else:
|
||||||
# Default behavior when workspace is empty
|
# Default behavior when workspace is empty
|
||||||
self.final_namespace = self.namespace
|
|
||||||
workspace_dir = working_dir
|
workspace_dir = working_dir
|
||||||
self.workspace = ""
|
self.workspace = ""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -463,7 +463,9 @@ class CleanupTool:
|
||||||
|
|
||||||
# CRITICAL: Set update flag so changes persist to disk
|
# CRITICAL: Set update flag so changes persist to disk
|
||||||
# Without this, deletions remain in-memory only and are lost on exit
|
# Without this, deletions remain in-memory only and are lost on exit
|
||||||
await set_all_update_flags(storage.final_namespace, storage.workspace)
|
await set_all_update_flags(
|
||||||
|
storage.namespace, workspace=storage.workspace
|
||||||
|
)
|
||||||
|
|
||||||
# Success
|
# Success
|
||||||
stats.successful_batches += 1
|
stats.successful_batches += 1
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue