aienos.com
Source of www.aienos.com, served from my own hardware
Brought by drakestapleton
aienos.com / scripts / allen / science / evidence / run_hard20.py
| 1 | #!/usr/bin/env python3 |
| 2 | # Run hard20.jsonl against an aien-math binary and judge each row with the corpus's own |
| 3 | # tests/oracle_common.verdict (no second matcher). Usage: run_hard20.py ENGINE_ROOT [BIN] |
| 4 | import json, os, subprocess, sys |
| 5 | root = sys.argv[1] |
| 6 | binp = sys.argv[2] if len(sys.argv) > 2 else os.path.join(root, "build", "aien-math") |
| 7 | sys.path.insert(0, os.path.join(root, "tests")) |
| 8 | from oracle_common import load, verdict, expected # noqa: E402 |
| 9 | here = os.path.dirname(os.path.abspath(__file__)) |
| 10 | cases = load(os.path.join(here, "hard20.jsonl")) |
| 11 | out, tally = [], {} |
| 12 | for c in cases: |
| 13 | try: |
| 14 | p = subprocess.run([binp, "eval", "-e", c["code"]], capture_output=True, text=True, timeout=60) |
| 15 | got, rc = p.stdout.rstrip("\n"), p.returncode |
| 16 | except subprocess.TimeoutExpired: |
| 17 | got, rc = "<timeout>", -1 |
| 18 | v = verdict(c, got, rc) |
| 19 | tally[v] = tally.get(v, 0) + 1 |
| 20 | out.append({"id": c["id"], "topic": c["topic"], "code": c["code"], "want": expected(c), |
| 21 | "compare": c.get("compare", "exact"), "source": c["source"], |
| 22 | "oracle_row": c["oracle_row"], "observed": got, "rc": rc, "verdict": v}) |
| 23 | print(f"{c['id']:3s} {v:12s} rc={rc} {c['code'][:70]}") |
| 24 | json.dump({"binary": binp, "results": out, "tally": tally}, open(os.path.join(here, "hard20-results.json"), "w"), indent=1) |
| 25 | print("tally", tally) |
| 26 | sys.exit(0 if tally.get("pass", 0) == len(cases) else 1) |