diff --git a/lightrag/tools/README_MIGRATE_LLM_CACHE.md b/lightrag/tools/README_MIGRATE_LLM_CACHE.md index beb7e6b0..8dd72984 100644 --- a/lightrag/tools/README_MIGRATE_LLM_CACHE.md +++ b/lightrag/tools/README_MIGRATE_LLM_CACHE.md @@ -258,7 +258,7 @@ The tool implements comprehensive error tracking to ensure transparent and resil ### Error Reporting After migration completes, a detailed report includes: - **Statistics**: Total records, success/failure counts, success rate -- **Error Summary**: Grouped by error type with occurrence counts +- **Error Summary**: Grouped by error type with occurrence counts - **Error Details**: Batch number, error type, message, and records lost - **Recommendations**: Clear indication of success or need for review diff --git a/lightrag/tools/migrate_llm_cache.py b/lightrag/tools/migrate_llm_cache.py index a9d1f18a..26b7c81c 100644 --- a/lightrag/tools/migrate_llm_cache.py +++ b/lightrag/tools/migrate_llm_cache.py @@ -6,9 +6,7 @@ This tool migrates LLM response cache (default:extract:* and default:summary:*) between different KV storage implementations while preserving workspace isolation. Usage: - python -m lightrag.tools.migrate_llm_cache - # or - python lightrag/tools/migrate_llm_cache.py + python tools/migrate_llm_cache.py Supported KV Storage Types: - JsonKVStorage @@ -25,17 +23,14 @@ from typing import Any, Dict, List from dataclasses import dataclass, field from dotenv import load_dotenv -# Add project root to path for imports -sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +# Add parent directory to path for imports +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from lightrag.kg import STORAGE_ENV_REQUIREMENTS from lightrag.namespace import NameSpace from lightrag.utils import setup_logger # Load environment variables -# use the .env that is inside the current folder -# allows to use different .env file for each lightrag instance -# the OS environment variables take precedence over the .env file load_dotenv(dotenv_path=".env", override=False) # Setup logger @@ -662,10 +657,6 @@ class MigrationTool: async def run(self): """Run the migration tool""" try: - # Initialize shared storage (REQUIRED for storage classes to work) - from lightrag.kg.shared_storage import initialize_share_data - initialize_share_data(workers=1) - # Print header self.print_header() self.print_storage_types() @@ -716,7 +707,7 @@ class MigrationTool: if target_data: print( - f"\n⚠️ Warning: Target storage already has {len(target_data):,} records" + f"\n⚠ Warning: Target storage already has {len(target_data):,} records" ) print("Migration will overwrite records with the same keys") @@ -760,13 +751,6 @@ class MigrationTool: await self.target_storage.finalize() except Exception: pass - - # Finalize shared storage - try: - from lightrag.kg.shared_storage import finalize_share_data - finalize_share_data() - except Exception: - pass async def main():