Spaces:
Runtime error
Runtime error
Peter Michael Gits Claude commited on
Commit ·
624ed9b
1
Parent(s): 16b78bc
Add HuggingFace Space creation script
Browse files🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- create_space.py +46 -0
create_space.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from huggingface_hub import HfApi
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
# Create HuggingFace Space
|
| 6 |
+
api = HfApi()
|
| 7 |
+
|
| 8 |
+
try:
|
| 9 |
+
# Create the space
|
| 10 |
+
space_url = api.create_repo(
|
| 11 |
+
repo_id="pgits/stt-gpu-service-python-v4",
|
| 12 |
+
repo_type="space",
|
| 13 |
+
exist_ok=True,
|
| 14 |
+
space_sdk="docker",
|
| 15 |
+
space_hardware="t4-small",
|
| 16 |
+
space_sleep_time=1800 # 30 minutes
|
| 17 |
+
)
|
| 18 |
+
print(f"Space created successfully: {space_url}")
|
| 19 |
+
|
| 20 |
+
# Upload all files
|
| 21 |
+
files_to_upload = [
|
| 22 |
+
"app.py",
|
| 23 |
+
"requirements.txt",
|
| 24 |
+
"Dockerfile",
|
| 25 |
+
"README.md",
|
| 26 |
+
".space_config.yaml"
|
| 27 |
+
]
|
| 28 |
+
|
| 29 |
+
for file in files_to_upload:
|
| 30 |
+
if os.path.exists(file):
|
| 31 |
+
print(f"Uploading {file}...")
|
| 32 |
+
api.upload_file(
|
| 33 |
+
path_or_fileobj=file,
|
| 34 |
+
path_in_repo=file,
|
| 35 |
+
repo_id="pgits/stt-gpu-service-python-v4",
|
| 36 |
+
repo_type="space"
|
| 37 |
+
)
|
| 38 |
+
print(f"✓ {file} uploaded")
|
| 39 |
+
else:
|
| 40 |
+
print(f"⚠️ {file} not found")
|
| 41 |
+
|
| 42 |
+
print("🚀 Space deployment completed!")
|
| 43 |
+
print(f"URL: https://huggingface.co/spaces/pgits/stt-gpu-service-python-v4")
|
| 44 |
+
|
| 45 |
+
except Exception as e:
|
| 46 |
+
print(f"Error: {e}")
|