File size: 2,796 Bytes
ab59633 | 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | """Assemble the Hugging Face dataset folder for Five Desks Code (candidate B): tasks, calibration and source.
The bug catalog itself (which line of which library was changed) is the answer key and is not published; the
builder scripts in source/codedesk/build reproduce it from the pinned library versions.
Usage: python3 scripts/build_dataset_code.py (file copies only; reads calibration from reports/calibration-code)
"""
import collections
import glob
import json
import shutil
from pathlib import Path
from statistics import mean
ROOT = Path(__file__).resolve().parents[1]
DATA = ROOT / "codedesk" / "data"
OUT = ROOT / "dataset_code"
SELECTED = json.loads((ROOT / "reports" / "selection-code.json").read_text()) if (
ROOT / "reports" / "selection-code.json").exists() else []
GROUP_LIBS = collections.defaultdict(set)
catalog = json.loads((DATA / "catalog.json").read_text())
for m in catalog:
from_lib = m["lib"]
GROUP_LIBS[m["domain"]].add(from_lib)
calib = collections.defaultdict(list)
for f in glob.glob(str(ROOT / "reports" / "calibration-code" / "*" / "episodes.jsonl")):
for line in open(f):
e = json.loads(line)
calib[e["task_id"]].append(e["reward"])
shutil.rmtree(OUT, ignore_errors=True)
(OUT / "calibration").mkdir(parents=True)
for d in glob.glob(str(ROOT / "reports" / "calibration-code" / "*")):
name = Path(d).name
for fn in ["summary.json", "episodes.jsonl"]:
if (Path(d) / fn).exists():
shutil.copy(Path(d) / fn, OUT / "calibration" / f"{name}_{fn}")
per_lib = collections.Counter(m["lib"] for m in catalog)
with open(OUT / "tasks.jsonl", "w") as f:
for task_id in sorted(calib) or SELECTED:
rewards = calib.get(task_id, [])
f.write(json.dumps({
"task_id": task_id,
"submitted_for_training": task_id in SELECTED,
"qwen3_8_27b_mean_reward": round(mean(rewards), 3) if rewards else None,
"qwen3_8_27b_rewards": rewards,
}) + "\n")
(OUT / "libraries.json").write_text(json.dumps({"mutants_per_library": per_lib,
"libraries_per_domain": {k: sorted(v) for k, v in GROUP_LIBS.items()}},
indent=1) + "\n")
src = OUT / "source"
shutil.copytree(ROOT / "codedesk", src / "codedesk", ignore=shutil.ignore_patterns(
"__pycache__", "*.pyc", "data", "out", "sdists", "*.log"))
for item in ["requirements.lock", "scripts/calibrate_v2.py", "scripts/calibrate.py", "scripts/wsclient.py",
"proxy_eval/run.py"]:
(src / item).parent.mkdir(parents=True, exist_ok=True)
shutil.copy(ROOT / item, src / item)
shutil.copy(ROOT / "card_code.md", OUT / "README.md")
print("dataset at", OUT, sorted(p.name for p in OUT.iterdir()))
|