noemacryst-isophase / publish_to_huggingface.py
PureOne's picture
Publish NOEMACRYST-ISOPHASE v6.0.0 public research release
8ecc1bd verified
Raw History Blame Contribute Delete
1.76 kB
"""Publish NOEMACRYST-ISOPHASE as a public Hugging Face research repository.
Security: the token is read from HF_TOKEN or from a hidden terminal prompt. It is never
written into repository files.
"""
from __future__ import annotations
import getpass
import os
from pathlib import Path
try:
from huggingface_hub import HfApi
except ImportError as exc:
raise SystemExit("Install first: python -m pip install -U huggingface_hub") from exc
ROOT = Path(__file__).resolve().parent
REPO_ID = os.environ.get("HF_REPO_ID", "PureOne/noemacryst-isophase")
TOKEN = os.environ.get("HF_TOKEN") or getpass.getpass("Hugging Face write token (hidden): ").strip()
if not TOKEN:
raise SystemExit("No token supplied.")
api = HfApi(token=TOKEN)
api.create_repo(repo_id=REPO_ID, repo_type="dataset", private=False, exist_ok=True)
api.upload_folder(
repo_id=REPO_ID,
repo_type="dataset",
folder_path=str(ROOT),
path_in_repo=".",
ignore_patterns=[
".git/*", "__pycache__/*", "*.pyc", ".pytest_cache/*",
"*.zip", ".env", ".env.*", "*token*", "*TOKEN*"
],
commit_message="Publish NOEMACRYST-ISOPHASE v6.0.0 public research release",
commit_description=(
"Self-contained theory, proofs, synthetic experiments, code, tests, figures, "
"machine-readable claim/status metadata, and experimental validation protocol."
),
)
try:
api.create_tag(
repo_id=REPO_ID,
tag="v6.0.0",
repo_type="dataset",
tag_message="NOEMACRYST-ISOPHASE v6.0.0",
exist_ok=True
)
except Exception as exc:
# A pre-existing tag should not make an otherwise successful public release fail.
print(f"Tag note: {exc}")
print(f"Published: https://huggingface.co/datasets/{REPO_ID}")