Download source/scripts/make_dataset.py from ajinkyamulay/analyst-workbench: direct link, hf CLI and curl.
- Browser
- Download file 5.16 kB
-
https://huggingface.co/datasets/ajinkyamulay/analyst-workbench/resolve/main/source/scripts/make_dataset.py
- Command line
-
hf download hf://datasets/ajinkyamulay/analyst-workbench/source/scripts/make_dataset.py
-
curl -L -o make_dataset.py https://huggingface.co/datasets/ajinkyamulay/analyst-workbench/resolve/main/source/scripts/make_dataset.py
5.16 kB
| """Build the public Hugging Face dataset: task catalog, seeded sample instances, and source.""" | |
| import json | |
| import os | |
| import shutil | |
| import sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| sys.path.insert(0, str(ROOT)) | |
| from workbench.tasks import ALL_TASK_IDS, TASK_IDS, build_task # noqa: E402 | |
| DOMAINS = { | |
| "swe": "software engineering", "ind": "industrial and physical systems", | |
| "sci": "natural science", "off": "office and white-collar work", | |
| "fin": "finance and economics", "math": "math and formal reasoning", | |
| "sec": "cybersecurity", "med": "media and content production", | |
| } | |
| SUMMARY = { | |
| "swe-fix-function": "Repair a buggy function from a bank of 8 (18 bug variants); hidden tests decide.", | |
| "swe-implement-spec": "Implement a function from a written spec and examples; hidden tests decide.", | |
| "swe-crash-triage": "Reproduce a crash in a small project; report file, line, exception type and the bad record.", | |
| "ind-vibration-alarm": "Apply a consecutive-reading alarm rule to interleaved pump sensor data.", | |
| "ind-tank-balance": "Simulate a tank mass balance from valve and drain schedules; find overflow and a level.", | |
| "ind-oee": "Compute line OEE with overlapping downtime reports merged.", | |
| "sci-longest-orf": "Find and translate the longest open reading frame on a DNA strand.", | |
| "sci-limiting-reagent": "Stoichiometry: limiting reactant and isolated product mass at a given yield.", | |
| "sci-dilution-series": "Beer-Lambert with blank correction and a serial dilution back to stock concentration.", | |
| "off-meeting-slot": "Earliest common meeting slot across calendars in several time zones.", | |
| "off-expense-audit": "Audit expense lines against a policy with caps, currency conversion and receipts.", | |
| "off-regional-revenue": "Join orders to customers and total a quarter's revenue by region.", | |
| "fin-loan-balance": "Amortization with cent rounding and extra principal payments.", | |
| "fin-npv-ranking": "Rank projects by NPV from uneven cash flow schedules.", | |
| "fin-portfolio-value": "Value a multi-currency portfolio from trades, closing prices and FX.", | |
| "math-grid-paths": "Count monotone lattice paths around obstacles.", | |
| "math-number-theory": "CRT, inclusion-exclusion counting, or digit sums of large powers.", | |
| "math-constrained-path": "Shortest path cost and count of shortest routes avoiding a closed node.", | |
| "sec-ssh-bruteforce": "Find the IP that brute-forced and then logged in, per a windowed rule, among decoys.", | |
| "sec-decode-config": "Deobfuscate a defanged config blob (base64 + rotating XOR) to recover a hostname.", | |
| "sec-firewall-rules": "Evaluate first-match firewall rules with CIDRs and port ranges.", | |
| "med-subtitle-stats": "Count a speaker's subtitle cues and their on-screen time, including two-speaker cues.", | |
| "med-edl-duration": "Program duration of a cuts-only EDL, skipping disabled events, as timecode.", | |
| "med-headline-style": "Apply a title-case style guide with small words, acronyms and hyphens.", | |
| "swe-repo-repair": "Find and fix injected regressions in a vendored open-source library; its own test suite grades.", | |
| "swe-repo-boltons": "Repo Repair on boltons 26.2.0.", | |
| "swe-repo-inflection": "Repo Repair on inflection 0.5.1.", | |
| "swe-repo-more-itertools": "Repo Repair on more-itertools 11.1.0.", | |
| "swe-repo-toolz": "Repo Repair on toolz 1.2.0.", | |
| } | |
| def main(out: Path): | |
| if out.exists(): | |
| shutil.rmtree(out) | |
| (out / "data").mkdir(parents=True) | |
| with open(out / "data" / "tasks.jsonl", "w") as f: | |
| for tid in ALL_TASK_IDS: | |
| fam, lv = tid.split("@") | |
| f.write(json.dumps({"task_id": f"{fam}-l{lv}", "family": fam, "level": int(lv), | |
| "domain": DOMAINS[fam.split("-")[0]], "summary": SUMMARY[fam]}) + "\n") | |
| with open(out / "data" / "samples.jsonl", "w") as f: | |
| for tid in ALL_TASK_IDS: | |
| if tid.startswith("swe-repo-"): # whole libraries; see data/repo_catalog instead | |
| continue | |
| for seed in range(3): | |
| t = build_task(tid, seed) | |
| f.write(json.dumps({ | |
| "task_id": tid, "seed": seed, "instruction": t.instruction, | |
| "files": [{"name": k, "content": v} for k, v in sorted(t.files.items())], | |
| "reference_answer": t.oracle, | |
| }) + "\n") | |
| catalog = Path(os.environ.get("WB_REPO_LIBS", "/app/repo_libs")) / "catalog" | |
| if catalog.is_dir(): | |
| shutil.copytree(catalog, out / "data" / "repo_catalog") | |
| src = out / "source" | |
| for rel in ["workbench", "server", "scripts", "tests", "docs", "repo_repair"]: | |
| shutil.copytree(ROOT / rel, src / rel, ignore=shutil.ignore_patterns("__pycache__")) | |
| for rel in ["openenv.yaml", "requirements.txt", "README.md"]: | |
| shutil.copy(ROOT / rel, src / rel) | |
| shutil.copy(ROOT / "README.md", out / "README.md") | |
| print(f"wrote {len(ALL_TASK_IDS)} task variants and {3 * len(ALL_TASK_IDS)} samples to {out}") | |
| if __name__ == "__main__": | |
| main(Path(sys.argv[1] if len(sys.argv) > 1 else "dataset")) | |