"""R5 VLMA: one table of the smoke tests (20 steps + save-and-resume on KOHTD train, export, reload, 16 train crops read back). Columns: ok, resume fingerprint match, median step seconds (KOHTD words, batch 32), max train memory, answer-end tokens, reload CER on 16 TRAIN crops (a pipeline check, not a result), hit_cap share, curve-test CER. usage: smoke_table.py OUT_TSV """ import glob import json import os import sys V = "/path/to/TURKIC_OCR_DATA/outputs/r5/vlma" summ = json.load(open(os.path.join(V, "smoke_summary.json"))) rows = [] for short, s in summ.items(): d = os.path.join(V, "runs", "smoke_" + short, "smoke") g = {} if os.path.exists(os.path.join(d, "smoke_generation.json")): g = json.load(open(os.path.join(d, "smoke_generation.json"))) ex = g.get("examples", []) metas = sorted(glob.glob(os.path.join(d, "run_meta_*.json"))) rm = json.load(open(metas[-1])) if metas else {} cv = {} if os.path.exists(os.path.join(d, "curve_test", "meta.json")): cv = json.load(open(os.path.join(d, "curve_test", "meta.json"))) rows.append([short, s.get("ok"), s.get("resume_fingerprint_match"), s.get("median_step_seconds_kohtd_words"), s.get("max_mem_GiB_train"), json.dumps(rm.get("answer_suffix_tokens", []), ensure_ascii=False), (g.get("score_train_rows_not_a_result") or {}).get("plain", {}).get("cer"), (sum(1 for e in ex if e.get("hit_cap")) / len(ex)) if ex else None, int(any(e.get("conf") is not None for e in ex)), cv.get("plain_cer"), s.get("utc")]) hdr = ["short", "ok", "resume_fp_match", "median_step_s_words_b32", "max_mem_GiB_train", "answer_end_tokens", "reload_cer_16_train_crops", "reload_hit_cap_share", "conf_present", "curve_test_cer_32_train_crops", "smoke_utc"] with open(sys.argv[1], "w", encoding="utf-8") as f: f.write("\t".join(hdr) + "\n") for r in rows: f.write("\t".join("" if x is None else str(x) for x in r) + "\n") for r in rows: print("\t".join("" if x is None else str(x) for x in r))