cherry-pick 0f2c0de8
This commit is contained in:
parent
b27845ca11
commit
fd739ee133
2 changed files with 5 additions and 21 deletions
|
|
@ -258,7 +258,7 @@ The tool implements comprehensive error tracking to ensure transparent and resil
|
||||||
### Error Reporting
|
### Error Reporting
|
||||||
After migration completes, a detailed report includes:
|
After migration completes, a detailed report includes:
|
||||||
- **Statistics**: Total records, success/failure counts, success rate
|
- **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
|
- **Error Details**: Batch number, error type, message, and records lost
|
||||||
- **Recommendations**: Clear indication of success or need for review
|
- **Recommendations**: Clear indication of success or need for review
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,7 @@ This tool migrates LLM response cache (default:extract:* and default:summary:*)
|
||||||
between different KV storage implementations while preserving workspace isolation.
|
between different KV storage implementations while preserving workspace isolation.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
python -m lightrag.tools.migrate_llm_cache
|
python tools/migrate_llm_cache.py
|
||||||
# or
|
|
||||||
python lightrag/tools/migrate_llm_cache.py
|
|
||||||
|
|
||||||
Supported KV Storage Types:
|
Supported KV Storage Types:
|
||||||
- JsonKVStorage
|
- JsonKVStorage
|
||||||
|
|
@ -25,17 +23,14 @@ from typing import Any, Dict, List
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
# Add project root to path for imports
|
# Add parent directory to path for imports
|
||||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
|
||||||
from lightrag.kg import STORAGE_ENV_REQUIREMENTS
|
from lightrag.kg import STORAGE_ENV_REQUIREMENTS
|
||||||
from lightrag.namespace import NameSpace
|
from lightrag.namespace import NameSpace
|
||||||
from lightrag.utils import setup_logger
|
from lightrag.utils import setup_logger
|
||||||
|
|
||||||
# Load environment variables
|
# 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)
|
load_dotenv(dotenv_path=".env", override=False)
|
||||||
|
|
||||||
# Setup logger
|
# Setup logger
|
||||||
|
|
@ -662,10 +657,6 @@ class MigrationTool:
|
||||||
async def run(self):
|
async def run(self):
|
||||||
"""Run the migration tool"""
|
"""Run the migration tool"""
|
||||||
try:
|
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
|
# Print header
|
||||||
self.print_header()
|
self.print_header()
|
||||||
self.print_storage_types()
|
self.print_storage_types()
|
||||||
|
|
@ -716,7 +707,7 @@ class MigrationTool:
|
||||||
|
|
||||||
if target_data:
|
if target_data:
|
||||||
print(
|
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")
|
print("Migration will overwrite records with the same keys")
|
||||||
|
|
||||||
|
|
@ -760,13 +751,6 @@ class MigrationTool:
|
||||||
await self.target_storage.finalize()
|
await self.target_storage.finalize()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Finalize shared storage
|
|
||||||
try:
|
|
||||||
from lightrag.kg.shared_storage import finalize_share_data
|
|
||||||
finalize_share_data()
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue