41 lines
1020 B
Python
41 lines
1020 B
Python
"""03_reset — wipe the in-memory graph cache and (best-effort) the Cognee dataset."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
|
|
def main() -> int:
|
|
pkl = ROOT / "lore_engine_poc" / ".graph.pkl"
|
|
if pkl.exists():
|
|
pkl.unlink()
|
|
print(f"[03_reset] removed {pkl}")
|
|
else:
|
|
print("[03_reset] no graph cache to remove")
|
|
|
|
try:
|
|
import cognee
|
|
import asyncio
|
|
|
|
async def _run() -> None:
|
|
await cognee.prune.prune_data()
|
|
await cognee.prune.prune_system(metadata=True)
|
|
print("[03_reset] cognee.prune_data() + prune_system() complete")
|
|
|
|
asyncio.run(_run())
|
|
except ImportError:
|
|
print("[03_reset] cognee not installed; nothing to do")
|
|
except Exception as e:
|
|
print(f"[03_reset] cognee prune failed (non-fatal): {e}")
|
|
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|