#!/usr/bin/env python3 """Publish the built corpus to AtomicChat/calib-corpora as one atomic commit. The previous revision's two files are moved to `legacy/` rather than deleted: identical bytes, new path, and the dataset repo keeps full git history either way. Their content has already been folded into the new build. """ from __future__ import annotations import os import sys from huggingface_hub import CommitOperationAdd, CommitOperationDelete, HfApi REPO = "AtomicChat/calib-corpora" HERE = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) OUT = os.path.join(HERE, "out") EXISTING = os.path.join(HERE, "existing") PIPELINE = os.path.join(HERE, "pipeline") LEGACY_FILES = ["calib_coding.txt", "heldout_coding.txt"] def main(dry_run=False): api = HfApi() ops = [] # corpus + metrics + readme for fn in sorted(os.listdir(OUT)): p = os.path.join(OUT, fn) if os.path.isfile(p): ops.append(CommitOperationAdd(path_in_repo=fn, path_or_fileobj=p)) # build scripts, for reproducibility for fn in sorted(os.listdir(PIPELINE)): if fn.endswith(".py"): ops.append(CommitOperationAdd(path_in_repo=f"pipeline/{fn}", path_or_fileobj=os.path.join(PIPELINE, fn))) clone_sh = os.path.join(HERE, "clone.sh") if os.path.isfile(clone_sh): ops.append(CommitOperationAdd(path_in_repo="clone.sh", path_or_fileobj=clone_sh)) # previous revision preserved under legacy/ for fn in LEGACY_FILES: p = os.path.join(EXISTING, fn) if os.path.isfile(p): ops.append(CommitOperationAdd(path_in_repo=f"legacy/{fn}", path_or_fileobj=p)) ops.append(CommitOperationDelete(path_in_repo=fn)) print(f"{len(ops)} operations:") for o in ops: kind = "DEL " if isinstance(o, CommitOperationDelete) else "ADD " print(f" {kind}{o.path_in_repo}") if dry_run: print("\n(dry run, nothing uploaded)") return api.create_commit( repo_id=REPO, repo_type="dataset", operations=ops, commit_message="Rebuild calibration corpus for DeepSeek-V4-Flash-0731 imatrix", commit_description=( "Domain-weighted rebuild targeting 3D/graphics generation and agentic tool use.\n\n" "- 7 requested domains plus a verified vocabulary sweep for the 3 hash-routed layers\n" "- agentic and reasoning slices rendered with the model's official encoding_dsv4 prompt format\n" "- exact + MinHash near-dup (J>=0.80) deduplication\n" "- document-level train/heldout split; eval_neutral drawn from held-apart sources\n" "- explicit benchmark-contamination scan, report included\n" "- previous revision moved to legacy/ and folded into the build" ), ) print(f"\nuploaded to https://huggingface.co/datasets/{REPO}") if __name__ == "__main__": main(dry_run="--dry-run" in sys.argv)