File size: 1,130 Bytes
3461098
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# scripts/seed_phase3.py
"""
Phase 3 graph re-seed.
Re-seeds Neo4j for all documents to:
- Fix cross-jurisdiction REFERENCES (MahaRERA → RERA Act sections)
- Add DERIVED_FROM edges (Document + Section level)
"""
from __future__ import annotations
import asyncio, sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))

import structlog
from civicsetu.ingestion.graph_seeder import GraphSeeder
from civicsetu.stores.graph_store import GraphStore

log = structlog.get_logger(__name__)

async def main():
    log.info("phase3_seed_start")
    # Full re-seed: doc_id=None seeds all active documents
    stats = await GraphSeeder.seed_from_postgres(doc_id=None)
    log.info("phase3_seed_complete", stats=stats)
    print("\n" + "="*60)
    print("Phase 3 graph seed complete")
    print(f"  Docs          : {stats.get('docs')}")
    print(f"  Sections      : {stats.get('sections')}")
    print(f"  REFERENCES    : {stats.get('refs')}")
    print(f"  DERIVED_FROM  : {stats.get('derived_from')}")
    print("="*60)
    await GraphStore.close()

if __name__ == "__main__":
    asyncio.run(main())