Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
58 lines
2.5 KiB
Python
58 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Score stored Codex cells with BOTH versions of the acceptance scripts, without touching the cells.
|
|
|
|
cmp_accept_both.py OUT_ROOT CELL_DIR [CELL_DIR ...]
|
|
|
|
STRICT = codex-compare/tasks/<task>/accept.py (board check: all five stages AND a loop inside ONE file).
|
|
RELAXED = codex-compare/reaccept-1/tasks/<task>/accept.py (all five stages anywhere in the frontend sources plus a loop in a file that mentions
|
|
"stage"); it is the version the saved VAN/VANL cells were accepted with, so it is the gate unless the owner says otherwise.
|
|
accept.py reads the workspace and works on a copy, so the stored cell is never modified; logs go to OUT_ROOT/<run>-<variant>-<cell>/{strict,relaxed}/.
|
|
Needs PATH with node/npm and NESTNG_NM_ROOT for nestng-crm (see the report stub of the route-tail-skip gate).
|
|
"""
|
|
import json
|
|
import os
|
|
import re
|
|
import sys
|
|
|
|
COMPARE = "/data/leleka-e2e/codex-compare"
|
|
TASK_ROOTS = {"strict": COMPARE + "/tasks", "relaxed": COMPARE + "/reaccept-1/tasks"}
|
|
sys.path.insert(0, COMPARE + "/delta")
|
|
import cell as cellmod # noqa: E402
|
|
|
|
|
|
def read_log(out_dir):
|
|
return open(os.path.join(out_dir, "acceptance.log"), encoding="utf-8").read()
|
|
|
|
|
|
def score(version, task, workspace, out_dir):
|
|
"""Run one accept.py version -> (exit code, 'passed/total' of the SUMMARY line)."""
|
|
os.makedirs(out_dir, exist_ok=True)
|
|
rc = cellmod.run_acceptance(os.path.join(TASK_ROOTS[version], task), workspace, out_dir, out_dir)
|
|
summary = re.search(r"SUMMARY (\d+/\d+)", read_log(out_dir))
|
|
return rc, summary.group(1) if summary else "no summary"
|
|
|
|
|
|
def failed_checks(out_dir):
|
|
return [line[5:] for line in read_log(out_dir).splitlines() if line.startswith("FAIL ")]
|
|
|
|
|
|
def score_cell(out_root, cell_dir):
|
|
info = json.load(open(os.path.join(cell_dir, "cell.json")))
|
|
run = os.path.basename(os.path.dirname(os.path.dirname(cell_dir)))
|
|
name = "%s-%s-%s" % (run, info["variant"], os.path.basename(cell_dir))
|
|
for version in ("strict", "relaxed"):
|
|
out_dir = os.path.join(out_root, name, version)
|
|
rc, summary = score(version, info["task"], os.path.join(cell_dir, "workspace"), out_dir)
|
|
print("%s\t%s\t%s\t%s\trc=%d\t%s\t%s" % (run, info["variant"], info["task"], os.path.basename(cell_dir), rc, version, summary), flush=True)
|
|
for failed in failed_checks(out_dir):
|
|
print(" FAIL %s" % failed, flush=True)
|
|
|
|
|
|
def main():
|
|
for cell_dir in sys.argv[2:]:
|
|
score_cell(sys.argv[1], cell_dir)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|