| 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", |
| |
| "make_preview_test.py", |
| "preview_test.html", |
| ".kimodo-animations/**", |
| |
| "_*.py", |
| |
| "experiments/**", |
| "kimodo_lab.py", |
| "flux_lab.py", |
| "wiener_dojo.py", |
| "wiener_dojo_web.py", |
| ".comic-cache/**", |
| "comic_klein_out/**", |
| "weiner_dataset_raw/**", |
| "weiner_lora_train/**", |
| "weiner_lora_train.zip", |
| "*.task", |
| "*.obj", |
| "dojo_*", |
| ".gitignore", |
| ], |
| ) |
| 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}") |
|
|
| |
| |
| try: |
| import _restart_local_gradio |
| _restart_local_gradio.restart() |
| except Exception as exc: |
| print(f"local gradio restart skipped: {type(exc).__name__}: {exc}") |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|