Download scripts/reproduce.py from Gyubeum/AndroidFlux_Evaluation_Output: direct link, hf CLI and curl.
- Browser
- Download file 9.93 kB
-
https://huggingface.co/datasets/Gyubeum/AndroidFlux_Evaluation_Output/resolve/main/scripts/reproduce.py
- Command line
-
hf download hf://datasets/Gyubeum/AndroidFlux_Evaluation_Output/scripts/reproduce.py
-
curl -L -o reproduce.py https://huggingface.co/datasets/Gyubeum/AndroidFlux_Evaluation_Output/resolve/main/scripts/reproduce.py
9.93 kB
| #!/usr/bin/env python3 | |
| """Recompute every number in this repository from the stored per-episode outcomes. | |
| python3 scripts/reproduce.py # recompute everything, print a summary | |
| python3 scripts/reproduce.py --check # also compare against the stored headers | |
| python3 scripts/reproduce.py --csv out.csv # write one row per cell | |
| python3 scripts/reproduce.py --cell human_verified/replay_65/t/ma3_7b | |
| Standard library only. Run it from the repository root, or pass --root. | |
| This is deliberately small and readable. It answers one question -- "does the | |
| number in the header follow from the per-episode outcomes?" -- and nothing else. | |
| For the paper tables, the model registry, the AndroidWorld axis and the full | |
| diagnostic set, use ``scripts/score_tables.py``. | |
| Scoring | |
| ------- | |
| The two artefact families are scored by DIFFERENT rules, and mixing them up | |
| changes the answer: | |
| validation.json / per_episode.json success = score > 0 (0.5 counts) | |
| sr_summary.json (AndroidWorld) success = score >= 1 (0.5 does not) | |
| Per-episode records do not all carry the same field. The fallback order is | |
| ``is_successful`` -> ``success`` -> ``score``, and ``is_successful`` may be null | |
| (the task raised before producing a verdict); null is a failure, not a skip. | |
| """ | |
| import argparse | |
| import csv | |
| import json | |
| import os | |
| import sys | |
| EXPECTED_DENOM = { | |
| ("human_verified/replay_65", "clean"): 65, | |
| ("human_verified/replay_65", "t_minus_5"): 65, | |
| ("human_verified/replay_65", "t_minus_3"): 65, | |
| ("human_verified/replay_65", "t_minus_1"): 65, | |
| ("human_verified/replay_65", "t"): 65, | |
| ("human_verified/replay_65", "t_plus_1_pos"): 52, | |
| ("human_verified/replay_65", "t_plus_1_neg"): 52, | |
| ("human_verified/snapshot_15", "clean"): 15, | |
| ("human_verified/snapshot_15", "t_minus_1"): 15, | |
| ("human_verified/snapshot_15", "t"): 15, | |
| ("llm_verified/replay_312", "clean"): 312, | |
| ("llm_verified/replay_312", "t"): 312, | |
| } | |
| def outcome(record): | |
| """True if this episode counts as a success under `score > 0`.""" | |
| for field in ("is_successful", "success", "score"): | |
| if field in record and record[field] is not None: | |
| value = record[field] | |
| if isinstance(value, bool): | |
| return value | |
| try: | |
| return float(value) > 0 | |
| except (TypeError, ValueError): | |
| continue | |
| # No usable verdict. The episode ran and produced nothing -- a failure, and | |
| # never a reason to shrink the denominator. | |
| return False | |
| def rows_of(cell_dir): | |
| """Per-episode records for a cell, and where they were read from. | |
| validation.json normally carries them inline as `rows`. Older cells put | |
| them in a sibling per_episode.json instead. Cells that carry neither can | |
| only be taken at their header's word, and that is reported, not hidden. | |
| """ | |
| validation_path = os.path.join(cell_dir, "validation.json") | |
| if not os.path.exists(validation_path): | |
| return None, None, None | |
| with open(validation_path, encoding="utf-8") as handle: | |
| header = json.load(handle) | |
| rows = header.get("rows") | |
| if isinstance(rows, list) and rows: | |
| return header, rows, "validation.json:rows" | |
| sibling = os.path.join(cell_dir, "per_episode.json") | |
| if os.path.exists(sibling): | |
| with open(sibling, encoding="utf-8") as handle: | |
| rows = json.load(handle) | |
| if isinstance(rows, list) and rows: | |
| return header, rows, "per_episode.json" | |
| return header, None, None | |
| def walk(root): | |
| """Yield (axis, condition, model, directory) for every cell under root.""" | |
| for axis in ("human_verified/replay_65", "human_verified/snapshot_15", | |
| "llm_verified/replay_312"): | |
| axis_dir = os.path.join(root, *axis.split("/")) | |
| if not os.path.isdir(axis_dir): | |
| continue | |
| for condition in sorted(os.listdir(axis_dir)): | |
| # Preserved runs are kept, never deleted, under a name that says why | |
| # (".aborted_*", ".stopped_*", ".enginedead_*_partial"). They are not | |
| # cells. Only the FIRST character decides: "qwen3vl_8b.dup1" is a real | |
| # published cell and must survive. | |
| if condition.startswith(".") or condition.startswith("__"): | |
| continue | |
| condition_dir = os.path.join(axis_dir, condition) | |
| if not os.path.isdir(condition_dir): | |
| continue | |
| for model in sorted(os.listdir(condition_dir)): | |
| if model.startswith(".") or model.startswith("__"): | |
| continue | |
| cell_dir = os.path.join(condition_dir, model) | |
| if os.path.isdir(cell_dir): | |
| yield axis, condition, model, cell_dir | |
| def main(): | |
| parser = argparse.ArgumentParser(description=__doc__, | |
| formatter_class=argparse.RawDescriptionHelpFormatter) | |
| parser.add_argument("--root", default=".", help="repository root (default: .)") | |
| parser.add_argument("--check", action="store_true", | |
| help="compare the recomputed value against the stored header") | |
| parser.add_argument("--csv", metavar="PATH", help="write one row per cell") | |
| parser.add_argument("--cell", metavar="PATH", | |
| help="one cell, e.g. human_verified/replay_65/t/ma3_7b") | |
| args = parser.parse_args() | |
| cells = list(walk(args.root)) | |
| # A checker that examines NOTHING must not report success. With no guard a | |
| # mistyped --root walked zero cells and still printed "every stored header | |
| # agrees with its own rows" and exited 0. The same shape turned up in the | |
| # publishing gate: a flat directory listing found no files in a nested tree | |
| # and reported every cell as passing. | |
| if not cells: | |
| sys.exit("no cells found under %s -- expected " | |
| "<root>/human_verified/replay_65/<cond>/<model>/ and siblings. " | |
| "Point --root at the repository root." % os.path.abspath(args.root)) | |
| if args.cell: | |
| wanted = args.cell.strip("/") | |
| cells = [c for c in cells if "/".join([c[0], c[1], c[2]]) == wanted] | |
| if not cells: | |
| sys.exit("no such cell: %s" % args.cell) | |
| out = [] | |
| disagreements = [] | |
| headers_only = [] | |
| for axis, condition, model, cell_dir in cells: | |
| header, rows, source = rows_of(cell_dir) | |
| if header is None: | |
| continue | |
| if rows is None: | |
| num = header.get("success_count") | |
| den = header.get("result_count") or header.get("expected_entries") | |
| headers_only.append("%s/%s/%s" % (axis, condition, model)) | |
| source = "header only" | |
| else: | |
| num = sum(1 for r in rows if outcome(r)) | |
| den = len(rows) | |
| expected = EXPECTED_DENOM.get((axis, condition)) | |
| record = { | |
| "axis": axis, "condition": condition, "model": model, | |
| "success": num, "entries": den, | |
| "rate": round(100.0 * num / den, 2) if den else "", | |
| "expected_denominator": expected if expected is not None else "", | |
| "denominator_matches": "" if expected is None else (den == expected), | |
| "valid": header.get("valid"), | |
| "issues": len(header.get("issues") or []), | |
| "read_from": source, | |
| } | |
| out.append(record) | |
| if args.check and rows is not None: | |
| stored_num = header.get("success_count") | |
| stored_den = header.get("result_count") | |
| if stored_num is not None and stored_num != num: | |
| disagreements.append( | |
| "%s/%s/%s success_count=%s but the rows give %d" | |
| % (axis, condition, model, stored_num, num)) | |
| if stored_den is not None and stored_den != den: | |
| disagreements.append( | |
| "%s/%s/%s result_count=%s but the file carries %d rows" | |
| % (axis, condition, model, stored_den, den)) | |
| rate = header.get("success_rate") | |
| if isinstance(rate, float) and den and abs(rate - num / den) > 1e-9: | |
| disagreements.append( | |
| "%s/%s/%s success_rate=%s but success/entries = %.6f" | |
| % (axis, condition, model, rate, num / den)) | |
| width = max([len("%s/%s/%s" % (r["axis"], r["condition"], r["model"])) | |
| for r in out] or [1]) | |
| for r in out: | |
| name = "%s/%s/%s" % (r["axis"], r["condition"], r["model"]) | |
| flag = "" if r["denominator_matches"] in ("", True) else " <- denominator %s expected" % r["expected_denominator"] | |
| note = "" if r["read_from"] != "header only" else " <- header only, rule not re-applied" | |
| print("%-*s %4s/%-4s %6s%% valid=%-5s issues=%-3d%s%s" | |
| % (width, name, r["success"], r["entries"], r["rate"], | |
| r["valid"], r["issues"], flag, note)) | |
| print("\n%d cell(s)" % len(out)) | |
| if headers_only: | |
| print("%d cell(s) carry no per-episode rows; their numbers are only as " | |
| "good as the producer:" % len(headers_only)) | |
| for name in headers_only: | |
| print(" %s" % name) | |
| if args.check: | |
| if disagreements: | |
| print("\n%d disagreement(s) between stored headers and the rows:" | |
| % len(disagreements)) | |
| for line in disagreements: | |
| print(" %s" % line) | |
| else: | |
| print("\nevery stored header agrees with its own rows") | |
| if args.csv: | |
| with open(args.csv, "w", newline="", encoding="utf-8") as handle: | |
| writer = csv.DictWriter(handle, fieldnames=list(out[0].keys())) | |
| writer.writeheader() | |
| writer.writerows(out) | |
| print("wrote %s" % args.csv) | |
| return 1 if (args.check and disagreements) else 0 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |