File size: 1,788 Bytes
072246b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""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()