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