Spaces:
Sleeping
Sleeping
Initial commit
Browse files- create_space.py +40 -0
create_space.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from huggingface_hub import HfApi, create_repo
|
2 |
+
import os
|
3 |
+
import sys
|
4 |
+
|
5 |
+
def create_and_push_space():
|
6 |
+
try:
|
7 |
+
print("Creating Space...")
|
8 |
+
# Create the space
|
9 |
+
repo_url = create_repo(
|
10 |
+
repo_id="xingqiang/radar-analysis",
|
11 |
+
repo_type="space",
|
12 |
+
space_sdk="gradio",
|
13 |
+
private=False
|
14 |
+
)
|
15 |
+
print(f"Space created successfully at: {repo_url}")
|
16 |
+
|
17 |
+
print("\nInitializing git repository...")
|
18 |
+
commands = [
|
19 |
+
"git init",
|
20 |
+
"git add .",
|
21 |
+
'git commit -m "Initial commit"',
|
22 |
+
f"git remote add space {repo_url}",
|
23 |
+
"git push --force space main"
|
24 |
+
]
|
25 |
+
|
26 |
+
for cmd in commands:
|
27 |
+
print(f"\nExecuting: {cmd}")
|
28 |
+
result = os.system(cmd)
|
29 |
+
if result != 0:
|
30 |
+
print(f"Error executing command: {cmd}")
|
31 |
+
sys.exit(1)
|
32 |
+
|
33 |
+
print("\nSpace setup completed successfully!")
|
34 |
+
|
35 |
+
except Exception as e:
|
36 |
+
print(f"Error: {str(e)}")
|
37 |
+
sys.exit(1)
|
38 |
+
|
39 |
+
if __name__ == "__main__":
|
40 |
+
create_and_push_space()
|