fix: pass workspace to LightRAG instance instead of vector_db_storage_cls_kwargs

Why this change is needed:
LightRAG creates storage instances by passing its own self.workspace field,
not the workspace parameter from vector_db_storage_cls_kwargs. This caused
E2E tests to fail because the workspace was set to default "_" instead of
the configured value like "prod" or "workspace_a".

How it solves it:
- Pass workspace directly to LightRAG constructor as a field parameter
- Remove workspace from vector_db_storage_cls_kwargs where it was being ignored
- This ensures self.workspace is set correctly and propagated to storage instances

Impact:
- Fixes test_backward_compat_old_workspace_naming_qdrant migration failure
- Fixes test_workspace_isolation_e2e_qdrant workspace mismatch
- Proper workspace isolation is now enforced in E2E tests

Testing:
- Modified two Qdrant E2E tests to use correct workspace configuration
- Tests should now find correct legacy collections (e.g., prod_chunks)
This commit is contained in:
BukeLy 2025-11-20 03:09:46 +08:00
parent 48f6511404
commit cedb3d49d2

View file

@ -896,17 +896,15 @@ async def test_backward_compat_old_workspace_naming_qdrant(
)
# Important: Use "prod" workspace to match old naming
updated_config = {**qdrant_config}
updated_config["workspace"] = "prod"
rag = LightRAG(
working_dir=temp_dir,
workspace="prod", # Pass workspace to LightRAG instance
llm_model_func=mock_llm_func,
embedding_func=embedding_func,
tokenizer=mock_tokenizer,
vector_storage="QdrantVectorDBStorage",
vector_db_storage_cls_kwargs={
**updated_config,
**qdrant_config,
"cosine_better_than_threshold": 0.8,
},
)
@ -1016,13 +1014,13 @@ async def test_workspace_isolation_e2e_qdrant(
# Instance A: workspace_a
rag_a = LightRAG(
working_dir=temp_working_dirs["workspace_a"],
workspace="workspace_a", # Pass workspace to LightRAG instance
llm_model_func=mock_llm_func,
embedding_func=embedding_func,
tokenizer=mock_tokenizer,
vector_storage="QdrantVectorDBStorage",
vector_db_storage_cls_kwargs={
**qdrant_config,
"workspace": "workspace_a",
"cosine_better_than_threshold": 0.8,
},
)
@ -1030,13 +1028,13 @@ async def test_workspace_isolation_e2e_qdrant(
# Instance B: workspace_b
rag_b = LightRAG(
working_dir=temp_working_dirs["workspace_b"],
workspace="workspace_b", # Pass workspace to LightRAG instance
llm_model_func=mock_llm_func,
embedding_func=embedding_func,
tokenizer=mock_tokenizer,
vector_storage="QdrantVectorDBStorage",
vector_db_storage_cls_kwargs={
**qdrant_config,
"workspace": "workspace_b",
"cosine_better_than_threshold": 0.8,
},
)