ACOM7 commited on
Commit
9dee6f9
·
verified ·
1 Parent(s): 2aa957a

Delete create_new_space.py

Browse files
Files changed (1) hide show
  1. create_new_space.py +0 -64
create_new_space.py DELETED
@@ -1,64 +0,0 @@
1
- import os
2
- import sys
3
- import time
4
- from pathlib import Path
5
- from huggingface_hub import HfApi
6
-
7
- token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGING_FACE_HUB_TOKEN")
8
-
9
- if not token:
10
- env_file = Path.home() / ".env"
11
- if env_file.exists():
12
- for line in env_file.read_text().splitlines():
13
- if line.startswith("HF_TOKEN="):
14
- token = line.split("=", 1)[1].strip().strip('"').strip("'")
15
- break
16
-
17
- if not token:
18
- print("MISSING_TOKEN")
19
- sys.exit(1)
20
-
21
- api = HfApi(token=token)
22
- repo_id = "Aeonicc/anysplat-zerogpu-demo"
23
-
24
- print(f"1. Creating brand-new Space repository '{repo_id}'...")
25
- space_url = api.create_repo(
26
- repo_id=repo_id,
27
- repo_type="space",
28
- space_sdk="gradio",
29
- exist_ok=True,
30
- )
31
- print(f"Space repository created: {space_url}")
32
-
33
- print("2. Syncing local codebase to the new Space repository...")
34
- folder_path = Path(__file__).parent.resolve()
35
- api.upload_folder(
36
- folder_path=str(folder_path),
37
- repo_id=repo_id,
38
- repo_type="space",
39
- ignore_patterns=[".git*", "__pycache__*", "*.log"],
40
- commit_message="Initial commit for brand new AnySplat ZeroGPU Space"
41
- )
42
- print("Codebase upload complete!")
43
-
44
- print("3. Requesting ZeroGPU (zero-a10g) hardware for Space...")
45
- try:
46
- api.request_space_hardware(repo_id=repo_id, hardware="zero-a10g")
47
- print("ZeroGPU hardware requested successfully!")
48
- except Exception as e:
49
- print(f"Hardware request note: {e}")
50
-
51
- print("4. Monitoring Space build and runtime status...")
52
- for i in range(40):
53
- info = api.get_space_runtime(repo_id)
54
- stage = info.stage
55
- print(f"Status check {i+1}: stage = {stage}, hardware = {info.hardware}")
56
- if stage in ["RUNNING", "RUNNING_APP_STARTING"]:
57
- print("Space is RUNNING and READY!")
58
- sys.exit(0)
59
- elif stage in ["BUILD_ERROR", "RUNTIME_ERROR", "CONFIG_ERROR"]:
60
- print(f"Space encountered error stage: {stage}")
61
- sys.exit(2)
62
- time.sleep(5)
63
-
64
- print("Space creation and setup initiated, building in background.")