fix: align cache variable names with test fixtures, restore full SKIP_DIRS
- _client → _client_cache to match conftest.py reset fixture - _get_collection now uses _get_client() return value instead of stale ref - Restore .pytest_cache and other dirs missing from palace.py SKIP_DIRS
This commit is contained in:
+11
-12
@@ -93,18 +93,17 @@ def _wal_log(operation: str, params: dict, result: dict = None):
|
|||||||
logger.error(f"WAL write failed: {e}")
|
logger.error(f"WAL write failed: {e}")
|
||||||
|
|
||||||
|
|
||||||
_client = None
|
_client_cache = None
|
||||||
|
_collection_cache = None
|
||||||
|
_meta_cache = {"data": None, "timestamp": 0, "ttl": 30} # 30 second TTL
|
||||||
|
|
||||||
|
|
||||||
def _get_client():
|
def _get_client():
|
||||||
"""Return a singleton ChromaDB PersistentClient."""
|
"""Return a singleton ChromaDB PersistentClient."""
|
||||||
global _client
|
global _client_cache
|
||||||
if _client is None:
|
if _client_cache is None:
|
||||||
_client = chromadb.PersistentClient(path=_config.palace_path)
|
_client_cache = chromadb.PersistentClient(path=_config.palace_path)
|
||||||
return _client
|
return _client_cache
|
||||||
|
|
||||||
|
|
||||||
_meta_cache = {"data": None, "timestamp": 0, "ttl": 30} # 30 second TTL
|
|
||||||
|
|
||||||
|
|
||||||
def _get_cached_metadata():
|
def _get_cached_metadata():
|
||||||
@@ -123,13 +122,13 @@ def _get_cached_metadata():
|
|||||||
|
|
||||||
def _get_collection(create=False):
|
def _get_collection(create=False):
|
||||||
"""Return the ChromaDB collection, caching the client between calls."""
|
"""Return the ChromaDB collection, caching the client between calls."""
|
||||||
global _client_cache, _collection_cache
|
global _collection_cache
|
||||||
try:
|
try:
|
||||||
_get_client()
|
client = _get_client()
|
||||||
if create:
|
if create:
|
||||||
_collection_cache = _client_cache.get_or_create_collection(_config.collection_name)
|
_collection_cache = client.get_or_create_collection(_config.collection_name)
|
||||||
elif _collection_cache is None:
|
elif _collection_cache is None:
|
||||||
_collection_cache = _client_cache.get_collection(_config.collection_name)
|
_collection_cache = client.get_collection(_config.collection_name)
|
||||||
return _collection_cache
|
return _collection_cache
|
||||||
except Exception:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -19,6 +19,18 @@ SKIP_DIRS = {
|
|||||||
".next",
|
".next",
|
||||||
"coverage",
|
"coverage",
|
||||||
".mempalace",
|
".mempalace",
|
||||||
|
".ruff_cache",
|
||||||
|
".mypy_cache",
|
||||||
|
".pytest_cache",
|
||||||
|
".cache",
|
||||||
|
".tox",
|
||||||
|
".nox",
|
||||||
|
".idea",
|
||||||
|
".vscode",
|
||||||
|
".ipynb_checkpoints",
|
||||||
|
".eggs",
|
||||||
|
"htmlcov",
|
||||||
|
"target",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user