build_production_graph.py 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. """Build production Neo4j data and LLM metadata; --check-only never calls services."""
  2. from __future__ import annotations
  3. import argparse
  4. import json
  5. import sys
  6. from step2_graph_building.production_pipeline import ROOT, build_production_graph
  7. def main():
  8. sys.stdout.reconfigure(encoding='utf-8')
  9. ap = argparse.ArgumentParser(description=__doc__)
  10. ap.add_argument('--template-dir', help='metadata directory (overrides METADATA_TEMPLATE_DIR)')
  11. ap.add_argument('--production-dir', default=ROOT / 'data/production')
  12. ap.add_argument('--relations', help='relation file (overrides RELATION_DIR/relation.xlsx)')
  13. ap.add_argument('--keys', default=ROOT / 'data/graph_keys.json')
  14. ap.add_argument('--output-dir', default=ROOT / 'output')
  15. ap.add_argument('--check-only', action='store_true')
  16. args = ap.parse_args()
  17. result = build_production_graph(template_dir=args.template_dir, production_dir=args.production_dir,
  18. relation_path=args.relations, keys_path=args.keys, output_dir=args.output_dir,
  19. check_only=args.check_only)
  20. # Conflicting business keys remain in the local report, not generic console logs.
  21. print(json.dumps({k:v for k,v in result.items() if k != 'issues'}, ensure_ascii=False, indent=2))
  22. print('问题数量:', len(result.get('issues', [])))
  23. print('构图报告:', str(args.output_dir) + '/step2_build_report.json')
  24. return 0 if result['ok'] else 1
  25. if __name__ == '__main__':
  26. raise SystemExit(main())