Improve LightRAG initialization checker tool with better usage docs
• Add workspace param to get_namespace_data
• Update docstring with proper usage example
• Simplify demo to show correct workflow
• Remove confusing before/after comparison
• Clarify tool should run after init
(cherry picked from commit 393f880311)
This commit is contained in:
parent
dcf88a8273
commit
67007ed9a6
1 changed files with 14 additions and 15 deletions
|
|
@ -3,10 +3,17 @@
|
||||||
Diagnostic tool to check LightRAG initialization status.
|
Diagnostic tool to check LightRAG initialization status.
|
||||||
|
|
||||||
This tool helps developers verify that their LightRAG instance is properly
|
This tool helps developers verify that their LightRAG instance is properly
|
||||||
initialized before use, preventing common initialization errors.
|
initialized and ready to use. It should be called AFTER initialize_storages()
|
||||||
|
to validate that all components are correctly set up.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
python -m lightrag.tools.check_initialization
|
# Basic usage in your code:
|
||||||
|
rag = LightRAG(...)
|
||||||
|
await rag.initialize_storages()
|
||||||
|
await check_lightrag_setup(rag, verbose=True)
|
||||||
|
|
||||||
|
# Run demo from command line:
|
||||||
|
python -m lightrag.tools.check_initialization --demo
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
@ -82,11 +89,11 @@ async def check_lightrag_setup(rag_instance: LightRAG, verbose: bool = False) ->
|
||||||
try:
|
try:
|
||||||
from lightrag.kg.shared_storage import get_namespace_data
|
from lightrag.kg.shared_storage import get_namespace_data
|
||||||
|
|
||||||
get_namespace_data("pipeline_status")
|
get_namespace_data("pipeline_status", workspace=rag_instance.workspace)
|
||||||
print("✅ Pipeline status: INITIALIZED")
|
print("✅ Pipeline status: INITIALIZED")
|
||||||
except KeyError:
|
except KeyError:
|
||||||
issues.append(
|
issues.append(
|
||||||
"Pipeline status not initialized - call initialize_pipeline_status()"
|
"Pipeline status not initialized - call rag.initialize_storages() first"
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
issues.append(f"Error checking pipeline status: {str(e)}")
|
issues.append(f"Error checking pipeline status: {str(e)}")
|
||||||
|
|
@ -101,8 +108,6 @@ async def check_lightrag_setup(rag_instance: LightRAG, verbose: bool = False) ->
|
||||||
|
|
||||||
print("\n📝 To fix, run this initialization sequence:\n")
|
print("\n📝 To fix, run this initialization sequence:\n")
|
||||||
print(" await rag.initialize_storages()")
|
print(" await rag.initialize_storages()")
|
||||||
print(" from lightrag.kg.shared_storage import initialize_pipeline_status")
|
|
||||||
print(" await initialize_pipeline_status()")
|
|
||||||
print(
|
print(
|
||||||
"\n📚 Documentation: https://github.com/HKUDS/LightRAG#important-initialization-requirements"
|
"\n📚 Documentation: https://github.com/HKUDS/LightRAG#important-initialization-requirements"
|
||||||
)
|
)
|
||||||
|
|
@ -127,7 +132,6 @@ async def check_lightrag_setup(rag_instance: LightRAG, verbose: bool = False) ->
|
||||||
async def demo():
|
async def demo():
|
||||||
"""Demonstrate the diagnostic tool with a test instance."""
|
"""Demonstrate the diagnostic tool with a test instance."""
|
||||||
from lightrag.llm.openai import openai_embed, gpt_4o_mini_complete
|
from lightrag.llm.openai import openai_embed, gpt_4o_mini_complete
|
||||||
from lightrag.kg.shared_storage import initialize_pipeline_status
|
|
||||||
|
|
||||||
print("=" * 50)
|
print("=" * 50)
|
||||||
print("LightRAG Initialization Diagnostic Tool")
|
print("LightRAG Initialization Diagnostic Tool")
|
||||||
|
|
@ -140,15 +144,10 @@ async def demo():
|
||||||
llm_model_func=gpt_4o_mini_complete,
|
llm_model_func=gpt_4o_mini_complete,
|
||||||
)
|
)
|
||||||
|
|
||||||
print("\n🔴 BEFORE initialization:\n")
|
print("\n🔄 Initializing storages...\n")
|
||||||
await check_lightrag_setup(rag, verbose=True)
|
await rag.initialize_storages() # Auto-initializes pipeline_status
|
||||||
|
|
||||||
print("\n" + "=" * 50)
|
print("\n🔍 Checking initialization status:\n")
|
||||||
print("\n🔄 Initializing...\n")
|
|
||||||
await rag.initialize_storages()
|
|
||||||
await initialize_pipeline_status()
|
|
||||||
|
|
||||||
print("\n🟢 AFTER initialization:\n")
|
|
||||||
await check_lightrag_setup(rag, verbose=True)
|
await check_lightrag_setup(rag, verbose=True)
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue