Move LLM cache migration tool to lightrag.tools module
- Relocated tool to proper package structure - Updated import paths and documentation - Added shared storage initialization - Fixed module path resolution - Updated usage instructions
This commit is contained in:
parent
0f2c0de8df
commit
6fc54d3625
2 changed files with 21 additions and 6 deletions
|
|
@ -78,7 +78,9 @@ pip install -r requirements.txt
|
|||
Run from the LightRAG project root directory:
|
||||
|
||||
```bash
|
||||
python tools/migrate_llm_cache.py
|
||||
python -m lightrag.tools.migrate_llm_cache
|
||||
# or
|
||||
python lightrag/tools/migrate_llm_cache.py
|
||||
```
|
||||
|
||||
### Interactive Workflow
|
||||
|
|
@ -328,7 +330,7 @@ MONGO_URI=mongodb://user:pass@prod-server:27017/
|
|||
MONGO_DATABASE=LightRAG
|
||||
|
||||
# 2. Run tool
|
||||
python tools/migrate_llm_cache.py
|
||||
python -m lightrag.tools.migrate_llm_cache
|
||||
|
||||
# 3. Select: 1 (JsonKVStorage) -> 4 (MongoKVStorage)
|
||||
```
|
||||
|
|
@ -356,7 +358,7 @@ POSTGRES_HOST=new-postgres-server
|
|||
# ... Other PostgreSQL configs
|
||||
|
||||
# 2. Run tool
|
||||
python tools/migrate_llm_cache.py
|
||||
python -m lightrag.tools.migrate_llm_cache
|
||||
|
||||
# 3. Select: 2 (RedisKVStorage) -> 3 (PGKVStorage)
|
||||
```
|
||||
|
|
@ -6,7 +6,9 @@ This tool migrates LLM response cache (default:extract:* and default:summary:*)
|
|||
between different KV storage implementations while preserving workspace isolation.
|
||||
|
||||
Usage:
|
||||
python tools/migrate_llm_cache.py
|
||||
python -m lightrag.tools.migrate_llm_cache
|
||||
# or
|
||||
python lightrag/tools/migrate_llm_cache.py
|
||||
|
||||
Supported KV Storage Types:
|
||||
- JsonKVStorage
|
||||
|
|
@ -23,8 +25,8 @@ from typing import Any, Dict, List
|
|||
from dataclasses import dataclass, field
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Add parent directory to path for imports
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
# Add project root to path for imports
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
|
||||
|
||||
from lightrag.kg import STORAGE_ENV_REQUIREMENTS
|
||||
from lightrag.namespace import NameSpace
|
||||
|
|
@ -657,6 +659,10 @@ 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()
|
||||
|
|
@ -751,6 +757,13 @@ 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():
|
||||
Loading…
Add table
Reference in a new issue