"""validate_schema_model_generation_v1.py — schema model generation validator""" from __future__ import annotations import json from pathlib import Path ROOT = Path(__file__).resolve().parents[1] SCHEMA_DIR = ROOT / "schemas" / "generated" OUT_DIR = ROOT / "src" / "quant_engine" / "models" / "generated" REPORT = ROOT / "Temp" / "schema_model_generation_v1.json" def main() -> int: schema_count = len(list(SCHEMA_DIR.glob("*.schema.json"))) module_count = len(list(OUT_DIR.glob("*.py"))) if not REPORT.exists(): print("SCHEMA_MODEL_GENERATION_FAIL: missing report") return 1 try: report = json.loads(REPORT.read_text(encoding="utf-8")) except Exception as exc: print(f"SCHEMA_MODEL_GENERATION_FAIL: invalid report ({exc})") return 1 ok = ( report.get("status") == "OK" and int(report.get("schema_count") or 0) == schema_count and int(report.get("generated_module_count") or 0) == schema_count and module_count == schema_count + 1 # generated modules + package __init__ ) if ok: print("SCHEMA_MODEL_GENERATION_OK") print(f"schema_count={schema_count} module_count={module_count}") return 0 print("SCHEMA_MODEL_GENERATION_FAIL") print(f"schema_count={schema_count} report={report} module_count={module_count}") return 1 if __name__ == "__main__": raise SystemExit(main())