"""R5 FREEZE: after r5_freeze_curve.sh, check that every part of curve_v1 was drawn from the expected version of its source manifest (GEN production_done.json stage 1 for the synthetic val sets, PRINT's sha256 for print_real_val, the registry for kohtd_lmtune), that no part is missing, and that the registry entry matches the frozen file. usage: python -I check_curve.py CURVE_INFO_JSON CURVE_FROZEN_JSON PRODUCTION_DONE_JSON EVALSETS_JSON OUT_JSON """ import json import sys info_p, frozen_p, pd_p, reg_p, out = sys.argv[1:6] info = json.load(open(info_p, encoding="utf-8")) fz = json.load(open(frozen_p, encoding="utf-8")) pd = json.load(open(pd_p, encoding="utf-8")) reg = json.load(open(reg_p, encoding="utf-8")) sets = {s["name"]: s for s in reg["sets"]} expect = {"synth_hand_val": pd["manifests"]["synth_hand_val.tsv"]["sha256"], "synth_typed_val": pd["manifests"]["synth_typed_val.tsv"]["sha256"], "synth_clutter_val": pd["manifests"]["synth_clutter_val.tsv"]["sha256"], "print_real_val": "36235ee1806f32b8f30f4bfbbd5ced306a98eb1201fe768f257393241588e82e", "V1lm": sets["V1lm"]["manifest_sha256"]} res = {"problems": [], "parts": []} for p in info["parts"]: e = expect.get(p["part"]) ok = p.get("manifest_sha256") == e res["parts"].append({"part": p["part"], "rows_drawn": p.get("rows_drawn"), "short_languages": p.get("short_languages"), "source_sha256": p.get("manifest_sha256"), "expected": e, "match": ok}) if not ok: res["problems"].append("%s drawn from sha256 %s, expected %s" % (p["part"], p.get("manifest_sha256"), e)) if p.get("short_languages"): res["problems"].append("%s short in %s" % (p["part"], p["short_languages"])) if info.get("missing_parts"): res["problems"].append("missing parts " + str(info["missing_parts"])) c = sets.get("curve_v1") if not c or c.get("manifest_sha256") != fz["manifest_sha256"] or c.get("n_rows") != fz["rows"]: res["problems"].append("registry curve_v1 entry missing or differs from curve_v1_frozen.json") res["frozen"] = fz res["status"] = "PASS" if not res["problems"] else "FAIL" json.dump(res, open(out, "w", encoding="utf-8"), indent=1, ensure_ascii=False) print(res["status"], res["problems"], fz.get("manifest_sha256"), fz.get("rows"), fz.get("rows_by_part"))