kimodo-zerogpu / deploy_space.py
polats's picture
Embedded HF view: pin drawer tab rail to upper-left (standalone keeps centered)
affef89 verified
Raw
History Blame Contribute Delete
1.69 kB
from __future__ import annotations
import argparse
from huggingface_hub import HfApi, SpaceHardware
def main() -> None:
parser = argparse.ArgumentParser(description="Create/update the Kimodo ZeroGPU Space.")
parser.add_argument("repo_id", help="Space repo id, for example: username/kimodo-zerogpu")
parser.add_argument("--public", action="store_true", help="Create the Space as public instead of private.")
parser.add_argument(
"--message",
default="Deploy Kimodo ZeroGPU updates",
help="Commit message to use for the Space upload.",
)
args = parser.parse_args()
api = HfApi()
api.create_repo(
repo_id=args.repo_id,
repo_type="space",
space_sdk="gradio",
space_hardware=SpaceHardware.ZERO_A10G,
private=not args.public,
exist_ok=True,
)
commit = api.upload_folder(
repo_id=args.repo_id,
repo_type="space",
folder_path=".",
commit_message=args.message,
ignore_patterns=[
"*.log",
"__pycache__/**",
".git/**",
".gradio/**",
".cache/**",
"*.npz",
# Local dev artifacts (offline viewer smoke test + local store).
"make_preview_test.py",
"preview_test.html",
".kimodo-animations/**",
# Local headless probes / checks (never part of the Space).
"_*.py",
],
)
runtime = api.request_space_hardware(repo_id=args.repo_id, hardware=SpaceHardware.ZERO_A10G)
print(f"Uploaded: {commit.commit_url}")
print(f"Hardware: {runtime.hardware}")
if __name__ == "__main__":
main()