ares-static-lab / scripts /deploy_static_space.py
jacmor64's picture
Deploy Ares Static Lab Colab training pipeline
8fa3dd6 verified
Raw
History Blame Contribute Delete
1.8 kB
from __future__ import annotations
import argparse
import os
from pathlib import Path
def main() -> None:
parser = argparse.ArgumentParser(description="Upload the public-safe Ares Static Space files to Hugging Face.")
parser.add_argument("--repo-id", default="jacmor64/ares-static-lab", help="Space repo id, e.g. jacmor64/ares-static-lab")
parser.add_argument("--root", default=".")
parser.add_argument("--message", default="Update Ares Static Lab")
parser.add_argument("--private", action="store_true", help="Create Space as private if it does not exist")
args = parser.parse_args()
token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGINGFACE_TOKEN")
if not token:
raise SystemExit("Set HF_TOKEN in the environment. Do not write it into any repo file.")
try:
from huggingface_hub import HfApi, upload_folder
except ImportError as exc:
raise SystemExit("Install huggingface_hub first: pip install huggingface_hub") from exc
root = Path(args.root).resolve()
api = HfApi(token=token)
api.create_repo(args.repo_id, repo_type="space", space_sdk="static", private=args.private, exist_ok=True)
upload_folder(
folder_path=str(root),
repo_id=args.repo_id,
repo_type="space",
token=token,
commit_message=args.message,
ignore_patterns=[
".git/*", "artifacts/*", "checkpoints/*", "runs/*", "wandb/*", "raw_data/*", "processed_data/*",
"**/__pycache__/*", "**/.ipynb_checkpoints/*", "*.pt", "*.pth", "*.ckpt", "*.safetensors", "*.bin",
"*.db", "*.sqlite", "*.sqlite3", ".env", "kaggle.json", ".netrc",
],
)
print(f"Uploaded {root} to https://huggingface.co/spaces/{args.repo_id}")
if __name__ == "__main__":
main()