Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
38 lines
1.7 KiB
Python
38 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Re-run the acceptance script over stored cells (same bytes of the task files, writable copy), e.g. after an acceptance infrastructure error.
|
|
|
|
reaccept.py RUNS_ROOT TASKS_ROOT [task ...]
|
|
|
|
The old acceptance.log / acceptance.rc are kept as *.prev, cell.json gets `accepted`, `acceptance_rc` and `reaccepted_utc`. Prints cells whose verdict changed.
|
|
"""
|
|
import glob
|
|
import json
|
|
import os
|
|
import shutil
|
|
import sys
|
|
import time
|
|
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
sys.path.insert(0, HERE)
|
|
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 not taskfile.check(tasks_root), "task files differ from the manifest"
|
|
for cj in sorted(glob.glob(os.path.join(runs, "V?", "*-r*", "cell.json"))):
|
|
d = os.path.dirname(cj)
|
|
info = json.load(open(cj))
|
|
if only and 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())})
|
|
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 ""))
|