tooling(scratch): decode-check run-to-run changes and a one-event view
Each run is diffed against the previous one (--compare-to, or the newest other run in ~/dl2-archive/checker-runs): changes.md lists every (event, field) that matched before and no longer does, how many now match, and how each field's counts moved; summary.md leads with the regression count. --file NAME checks one event and prints its table, writing no run folder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
This commit is contained in:
1 parent
5e85cf1018
commit
c8fc649568
3 files changed
+111
No files matched your search
@@ -141,3 +141,51 @@ def _pick_examples(agg: dict, key: str, groups: dict) -> list[dict]:
|
||||
rerun = f"python scratch/check_s3_decode.py {agg['bin_dir']} {agg['xml_dir']} --file "
|
||||
return [{"file": e["file"], "bw": e["bw"], "sfm": e["sfm"], "detail": e["detail"],
|
||||
"rerun": rerun + e["file"]} for e in picked]
|
||||
|
||||
|
||||
def _verdicts(results_path: Path) -> dict[tuple[str, str], str]:
|
||||
out = {}
|
||||
with gzip.open(results_path, "rt", encoding="utf-8") as fh:
|
||||
for line in fh:
|
||||
ev = json.loads(line)
|
||||
for row in ev["results"]:
|
||||
out[(ev["file"], row[0])] = row[1]
|
||||
return out
|
||||
|
||||
|
||||
def compare_runs(prev_results: Path, cur_results: Path) -> dict:
|
||||
"""What changed between two runs: per-field verdict counts before and
|
||||
after, every (event, field) that used to match and no longer does, and how
|
||||
many non-matches now match."""
|
||||
before, after = _verdicts(prev_results), _verdicts(cur_results)
|
||||
fields: dict[str, dict[str, list[int]]] = defaultdict(lambda: defaultdict(lambda: [0, 0]))
|
||||
for (_, field), v in before.items():
|
||||
fields[field][v][0] += 1
|
||||
for (_, field), v in after.items():
|
||||
fields[field][v][1] += 1
|
||||
regressions = [{"file": f, "field": fld, "before": "match", "after": v}
|
||||
for (f, fld), v in sorted(after.items())
|
||||
if v != "match" and before.get((f, fld)) == "match"]
|
||||
fixed = sum(1 for k, v in after.items() if v == "match" and before.get(k) not in (None, "match"))
|
||||
return {"fields": {f: dict(c) for f, c in fields.items()}, "regressions": regressions,
|
||||
"fixed": fixed, "prev": str(prev_results)}
|
||||
|
||||
|
||||
def write_changes(chg: dict, path: Path) -> None:
|
||||
regs = chg["regressions"]
|
||||
lines = [f"# Changes since {chg.get('prev', 'the previous run')}", "",
|
||||
f"{len(regs)} regressions · {chg['fixed']} fixed", ""]
|
||||
if regs:
|
||||
lines += ["## Regressions (matched before, not now)", "", "| file | field | now |", "|---|---|---|"]
|
||||
lines += [f"| {r['file']} | {r['field']} | {r['after']} |" for r in regs[:500]]
|
||||
if len(regs) > 500:
|
||||
lines.append(f"| … {len(regs) - 500} more | | |")
|
||||
lines.append("")
|
||||
moved = {f: c for f, c in chg["fields"].items() if any(b != a for b, a in c.values())}
|
||||
if moved:
|
||||
lines += ["## Fields whose counts moved (before → after)", "",
|
||||
"| field | " + " | ".join(VERDICTS) + " |", "|---|" + "---|" * len(VERDICTS)]
|
||||
for f in sorted(moved):
|
||||
lines.append(f"| {f} | " + " | ".join(
|
||||
f"{moved[f].get(v, [0, 0])[0]} → {moved[f].get(v, [0, 0])[1]}" for v in VERDICTS) + " |")
|
||||
Path(path).write_text("\n".join(lines) + "\n")
|
||||
Reference in new issue
Block a user