Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
40 lines
1.9 KiB
Python
40 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Re-run the acceptance over stored cells of the comparison with a corrected accept.py (variants LEL / VAN / VANL; delta/reaccept.py only knows V?).
|
|
|
|
cmp_reaccept.py RUNS_ROOT TASKS_ROOT task [task ...]
|
|
|
|
Old acceptance.log / acceptance.rc are kept as *.prev; cell.json gets `accepted`, `acceptance_rc`, `reaccepted_utc`. Prints every cell with its old and new verdict.
|
|
"""
|
|
import glob
|
|
import json
|
|
import os
|
|
import shutil
|
|
import sys
|
|
import time
|
|
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
sys.path.insert(0, os.path.join(HERE, "..", "delta"))
|
|
import cell as cellmod # noqa: E402
|
|
import taskfile # noqa: E402
|
|
|
|
runs, tasks_root = sys.argv[1], sys.argv[2]
|
|
only = set(sys.argv[3:])
|
|
assert only, "name the tasks"
|
|
assert not taskfile.check(tasks_root), "task files differ from the manifest"
|
|
for cj in sorted(glob.glob(os.path.join(runs, "*", "*-r*", "cell.json"))):
|
|
d = os.path.dirname(cj)
|
|
info = json.load(open(cj))
|
|
if info["task"] not in only:
|
|
continue
|
|
for n in ("acceptance.log", "acceptance.rc"):
|
|
if os.path.exists(os.path.join(d, n)) and not os.path.exists(os.path.join(d, n + ".prev")):
|
|
shutil.copyfile(os.path.join(d, n), os.path.join(d, n + ".prev"))
|
|
rc = cellmod.run_acceptance(os.path.join(tasks_root, info["task"]), os.path.join(d, "workspace"), d, d)
|
|
open(os.path.join(d, "acceptance.rc"), "w").write("%d\n" % rc)
|
|
was = info.get("accepted")
|
|
info.update({"accepted": rc == 0, "acceptance_rc": rc, "reaccepted_utc": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
|
"reaccepted_tasks_manifest_sha256": taskfile.sha256_file(os.path.join(tasks_root, "MANIFEST.sha256"))})
|
|
json.dump(info, open(cj + ".part", "w"), indent=1)
|
|
os.replace(cj + ".part", cj)
|
|
print("%s %s r%s: accepted %s -> %s%s" % (info["variant"], info["task"], info["rep"], was, rc == 0, " CHANGED" if was != (rc == 0) else ""), flush=True)
|