File size: 1,521 Bytes
ce235ae
 
 
 
 
 
 
 
 
 
 
 
 
 
dd6f7d9
ce235ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Publish NanoJev conversion source only while weight redistribution is unresolved."""

from __future__ import annotations

import argparse
from pathlib import Path

from huggingface_hub import CommitOperationAdd, HfApi

ROOT = Path(__file__).resolve().parent
REPO = "FluidInference/nanojev-coreml"
FILES = (
    ".gitignore",
    "README.md",
    "RESULTS.md",
    "STATUS.md",
    "assets.lock.json",
    "assets.py",
    "convert-coreml.py",
    "export_model.py",
    "fixtures.py",
    "preprocessing.py",
    "pyproject.toml",
    "publish-hf-source.py",
    "tests/test_native_renderer.py",
    "uv.lock",
    "verify.py",
)


def main() -> None:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--dry-run", action="store_true")
    args = parser.parse_args()
    operations = [CommitOperationAdd(path_in_repo="README.md", path_or_fileobj=ROOT / "hf/README.md")]
    for name in FILES:
        operations.append(CommitOperationAdd(path_in_repo=f"source/{name}", path_or_fileobj=ROOT / name))
    if args.dry_run:
        for operation in operations:
            print(operation.path_in_repo)
        return
    api = HfApi()
    api.create_repo(REPO, repo_type="model", private=False, exist_ok=True)
    result = api.create_commit(
        repo_id=REPO,
        repo_type="model",
        operations=operations,
        commit_message="Publish NanoJev Core ML conversion source without trained weights",
    )
    print(result.commit_url)


if __name__ == "__main__":
    main()