Datasets:
Download tools/publish_hf.py from klein-ml/klein-code-bench: direct link, hf CLI and curl.
- Browser
- Download file 1.79 kB
-
https://huggingface.co/datasets/klein-ml/klein-code-bench/resolve/main/tools/publish_hf.py
- Command line
-
hf download hf://datasets/klein-ml/klein-code-bench/tools/publish_hf.py
-
curl -L -o publish_hf.py https://huggingface.co/datasets/klein-ml/klein-code-bench/resolve/main/tools/publish_hf.py
1.79 kB
| """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() | |