Download deploy.py from arimatch1/cka-kubernetes-practice: direct link, hf CLI and curl.
- Browser
- Download file 1.78 kB
-
https://huggingface.co/spaces/arimatch1/cka-kubernetes-practice/resolve/main/deploy.py
- Command line
-
hf download hf://spaces/arimatch1/cka-kubernetes-practice/deploy.py
-
curl -L -o deploy.py https://huggingface.co/spaces/arimatch1/cka-kubernetes-practice/resolve/main/deploy.py
1.78 kB
| # Run this script to deploy the Space to HuggingFace | |
| import os | |
| import subprocess | |
| import sys | |
| def deploy(): | |
| try: | |
| from huggingface_hub import HfApi | |
| except ImportError: | |
| subprocess.check_call([sys.executable, "-m", "pip", "install", "huggingface_hub"]) | |
| from huggingface_hub import HfApi | |
| api = HfApi() | |
| # Get username from whoami | |
| user_info = api.whoami() | |
| username = user_info["name"] | |
| repo_id = f"{username}/cka-kubernetes-practice" | |
| print(f"Deploying to HuggingFace as: {username}") | |
| # Create the Space | |
| try: | |
| api.create_repo( | |
| repo_id=repo_id, | |
| repo_type="space", | |
| space_sdk="docker", | |
| private=False, | |
| exist_ok=True | |
| ) | |
| print(f"Space created: {repo_id}") | |
| except Exception as e: | |
| print(f"Space may already exist: {e}") | |
| # Upload all files | |
| api.upload_folder( | |
| folder_path="./cka-kubernetes-practice", | |
| repo_id=repo_id, | |
| repo_type="space" | |
| ) | |
| print("") | |
| print("╔══════════════════════════════════════════════════════════╗") | |
| print("║ ✅ Deployment complete! ║") | |
| print(f"║ 🌐 URL: https://huggingface.co/spaces/{repo_id:<20}║") | |
| print("║ ⏳ Build takes ~3-5 minutes on HuggingFace ║") | |
| print("║ 📺 Check build logs in the Space's 'Logs' tab ║") | |
| print("╚══════════════════════════════════════════════════════════╝") | |
| if __name__ == "__main__": | |
| deploy() | |