#!/usr/bin/env python3 """Publish the corpus to HuggingFace as ilintar/SACB. Two splits: test the 60 selected tasks -- what the benchmark scores by default extended all 129 validated tasks, including the easy `ledger` tier The file maps are stored as JSON strings rather than nested structs, because a struct column would force one schema across tasks that legitimately carry different files. The loader accepts either. """ import argparse, json, sys from pathlib import Path HERE = Path(__file__).parent REPO_ID = "ilintar/SACB" def to_record(row: dict) -> dict: return { "task_id": row["task_id"], "repo": row["repo"], "lang": row["lang"], "category": row["category"], "difficulty": int(row["difficulty"]), "instruction": row["instruction"], "files": json.dumps(row["files"]), "tests": json.dumps(row["tests"]), "gold": json.dumps(row["gold"]), "fail_to_pass": list(row["fail_to_pass"]), "pass_to_pass": list(row["pass_to_pass"]), "n_tests": int(row.get("n_tests", 0)), } def main(): ap = argparse.ArgumentParser() ap.add_argument("--private", action="store_true") ap.add_argument("--dry-run", action="store_true") args = ap.parse_args() selected = [json.loads(l) for l in (HERE / "agentic-corpus-60.jsonl").read_text().splitlines() if l.strip()] everything = [json.loads(l) for l in (HERE / "agentic-corpus.jsonl").read_text().splitlines() if l.strip()] from datasets import Dataset, DatasetDict ds = DatasetDict({ "test": Dataset.from_list([to_record(r) for r in selected]), "extended": Dataset.from_list([to_record(r) for r in everything]), }) print(ds) if args.dry_run: print("dry run, not uploading") return 0 ds.push_to_hub(REPO_ID, private=args.private) print(f"pushed to https://huggingface.co/datasets/{REPO_ID}") card = (HERE / "SACB_CARD.md") if card.is_file(): from huggingface_hub import HfApi HfApi().upload_file( path_or_fileobj=str(card), path_in_repo="README.md", repo_id=REPO_ID, repo_type="dataset", commit_message="Add dataset card", ) print("uploaded dataset card") return 0 if __name__ == "__main__": sys.exit(main())