Datasets:
File size: 2,456 Bytes
36a7b71 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # One-off patch of the dataset's v1.3 shards to v1.4 (lead, 2026-11-08): monitors and settings the analysis did not use
# are dropped with everything that only they carried: the live_traffic setting, the Claude Opus 4.8 reference reviews,
# the Qwen3.5-27B reviews, and the two columns only Qwen3.5 filled (p_monitor_test_estimate / _answer). Same shards and
# compression; rewrites build_report.json counts.
# Usage: python patch_v1_4.py <dataset folder>
import collections, glob, json, math, os, sys
import pyarrow as pa, pyarrow.compute as pc, pyarrow.parquet as pq
H = sys.argv[1]
DROP_MONITORS = pa.array(["anthropic/claude-opus-4.8", "Qwen/Qwen3.5-27B"])
DROP_COLUMNS = ["p_monitor_test_estimate", "p_monitor_test_answer"]
cnt = dict(rows=0, setting=collections.Counter(), bench=collections.Counter(), mon=collections.Counter(), js=collections.Counter())
dropped = 0
for f in sorted(glob.glob(f"{H}/data/reviews-*.parquet")):
pf = pq.ParquetFile(f); t = pf.read(); n0 = t.num_rows; rg = math.ceil(n0 / pf.metadata.num_row_groups)
drop = pc.or_(pc.equal(t["setting"], "live_traffic"), pc.is_in(t["monitor_model"], value_set=DROP_MONITORS))
t = t.filter(pc.invert(drop)).drop_columns(DROP_COLUMNS)
assert t.num_rows, f
dropped += n0 - t.num_rows
pq.write_table(t, f, compression="zstd", row_group_size=rg)
cnt["rows"] += t.num_rows
for k, col in (("setting", "setting"), ("bench", "benchmark"), ("mon", "monitor_model")):
cnt[k].update(t[col].to_pylist())
cnt["js"].update(f"{s}/{j}" for s, j in zip(t["setting"].to_pylist(), t["judge_status"].to_pylist()))
rep = json.load(open(f"{H}/build_report.json"))
rep.update(rows=cnt["rows"], rows_by_setting=dict(sorted(cnt["setting"].items())), rows_by_benchmark=dict(sorted(cnt["bench"].items())),
rows_by_monitor=dict(sorted(cnt["mon"].items())), judge_status=dict(sorted(cnt["js"].items())),
bytes=sum(os.path.getsize(f) for f in glob.glob(f"{H}/data/reviews-*.parquet")),
v1_4_patch="2026-11-08: live_traffic setting, Claude Opus 4.8 and Qwen3.5-27B reviews dropped (%d rows), "
"with columns p_monitor_test_estimate / p_monitor_test_answer" % dropped)
json.dump(rep, open(f"{H}/build_report.json", "w"), indent=1, sort_keys=True)
print("dropped", dropped, "rows", cnt["rows"])
print(json.dumps({k: rep[k] for k in ("rows_by_setting", "rows_by_monitor", "rows_by_benchmark", "judge_status")}, indent=1))
|