#!/usr/bin/env python3 """Upload the complete research artifact to a Hugging Face dataset repository. Usage: HF_TOKEN=hf_xxx python scripts/upload_hf.py [repo_id] The token is read from the environment and is never written to disk. """ from __future__ import annotations import os import sys from pathlib import Path from huggingface_hub import HfApi ROOT = Path(__file__).resolve().parents[1] DEFAULT_REPO = "eduzrh/nv-kgmad" IGNORE = [ "_internal/**", "logs/**", "**/__pycache__/**", "**/*.pyc", ".pytest_cache/**", "paper/math/**", ".git/**", ] def main() -> None: token = os.getenv("HF_TOKEN") or os.getenv("HUGGINGFACE_TOKEN") if not token: raise SystemExit("set HF_TOKEN in the environment") repo_id = sys.argv[1] if len(sys.argv) > 1 else DEFAULT_REPO api = HfApi(token=token) user = api.whoami()["name"] print("authenticated as", user) api.create_repo(repo_id=repo_id, repo_type="dataset", exist_ok=True, private=False) print("repo ready:", f"https://huggingface.co/datasets/{repo_id}") api.upload_folder( folder_path=str(ROOT), repo_id=repo_id, repo_type="dataset", ignore_patterns=IGNORE, commit_message="Upload NV-KGMAD code, data, cached responses, results and paper", ) print("upload complete") if __name__ == "__main__": main()