Download source/scripts/build_dataset_code.py from rca-umb/five-desks-control: direct link, hf CLI and curl.
- Browser
- Download file 2.8 kB
-
https://huggingface.co/datasets/rca-umb/five-desks-control/resolve/main/source/scripts/build_dataset_code.py
- Command line
-
hf download hf://datasets/rca-umb/five-desks-control/source/scripts/build_dataset_code.py
-
curl -L -o build_dataset_code.py https://huggingface.co/datasets/rca-umb/five-desks-control/resolve/main/source/scripts/build_dataset_code.py
2.8 kB
| """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())) | |