File size: 2,701 Bytes
0081600
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python3
"""Publish the current HVCE release folder to a public Hugging Face Hub repo.

The write token is read from HF_TOKEN. It is never written to project files.
"""
from __future__ import annotations

import os
import sys
from pathlib import Path

from huggingface_hub import HfApi, create_repo, upload_folder

RELEASE_TAG = "v4.0.0-OmniCrown"
DEFAULT_REPO_NAME = "heaven-vector-compression-engine"


def main() -> int:
    token = os.environ.get("HF_TOKEN", "").strip()
    if not token:
        print("ERROR: HF_TOKEN is not set. Use PUBLISH_TO_HUGGINGFACE.bat.", file=sys.stderr)
        return 2

    repo_name = os.environ.get("HVCE_REPO_NAME", DEFAULT_REPO_NAME).strip() or DEFAULT_REPO_NAME
    api = HfApi(token=token)
    who = api.whoami()
    username = who.get("name") or who.get("fullname")
    if not username:
        print("ERROR: Could not determine the authenticated Hugging Face username.", file=sys.stderr)
        return 3

    repo_id = f"{username}/{repo_name}"
    root = Path(__file__).resolve().parent

    print(f"Authenticated as: {username}")
    print(f"Target repository: {repo_id}")
    print("Visibility: public")

    create_repo(
        repo_id=repo_id,
        repo_type="model",
        private=False,
        exist_ok=True,
        token=token,
    )

    # Explicitly ensure public visibility even when reusing an existing repo.
    try:
        api.update_repo_settings(repo_id=repo_id, repo_type="model", private=False)
    except Exception as exc:
        print(f"Warning: could not explicitly update visibility: {exc}")

    ignore_patterns = [
        ".git/*", ".git/**", "__pycache__/*", "**/__pycache__/*", "*.pyc", "*.pyo",
        ".pytest_cache/*", ".pytest_cache/**", "benchmarks/local_run/*", "benchmarks/local_run/**",
        "upload_work/*", "upload_work/**"
    ]

    upload_folder(
        folder_path=str(root),
        repo_id=repo_id,
        repo_type="model",
        token=token,
        commit_message="HVCE v4.0.0 OmniCrown — very early public research prototype",
        ignore_patterns=ignore_patterns,
    )

    try:
        api.create_tag(
            repo_id=repo_id,
            repo_type="model",
            tag=RELEASE_TAG,
            tag_message="HVCE v4.0.0 OmniCrown public research prototype",
        )
        print(f"Created tag: {RELEASE_TAG}")
    except Exception as exc:
        print(f"Tag note: {exc}")

    url = f"https://huggingface.co/{repo_id}"
    print("\nPublication complete:")
    print(url)
    print("\nReminder: this repository is intentionally framed as a very early prototype; it may compress poorly.")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())