"""Publish reviewed benchmark artifacts, never local credentials or workspaces.""" import argparse import hashlib import json from pathlib import Path def main(): from huggingface_hub import HfApi parser = argparse.ArgumentParser() parser.add_argument("--repo", default="klein-ml/klein-code-bench") args = parser.parse_args() root = Path(__file__).resolve().parents[1] summary = json.loads((root / "validation-summary.json").read_text()) digest = hashlib.sha256( (root / "klein_code_bench/data/manifest.json").read_bytes() ).hexdigest() if ( not summary["passed"] or summary["tasks"] != 260 or summary["manifest_sha256"] != digest ): raise SystemExit( "Full validation of the current dataset is required before publishing" ) api = HfApi() api.create_repo( repo_id=args.repo, repo_type="dataset", private=False, exist_ok=True ) result = api.upload_folder( repo_id=args.repo, repo_type="dataset", folder_path=str(root), allow_patterns=[ "README.md", "LICENSE", "pyproject.toml", ".gitignore", ".github/workflows/*.yml", "klein_code_bench/*.py", "klein_code_bench/reference/*.py", "klein_code_bench/data/*.jsonl", "klein_code_bench/data/*.json", "tests/*.py", "docs/*.md", "tools/*.py", "dist/*.whl", "validation-summary.json", ], commit_message="Release Klein-Code-Bench v0.1.0: 260 validated project-generation tasks", ) print(result.oid) print(f"https://huggingface.co/datasets/{args.repo}") if __name__ == "__main__": main()