File size: 2,372 Bytes
9368cc4 | 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 66 67 68 69 70 71 72 73 74 75 | #!/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())
|