Spaces:
Runtime error
Runtime error
gauravlochab
commited on
Commit
·
b31cc95
1
Parent(s):
e28f6ec
refactor: Add script to restart Hugging Face Space
Browse files- restart_space.py +15 -0
restart_space.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from huggingface_hub import HfApi
|
2 |
+
import os
|
3 |
+
|
4 |
+
def restart_space():
|
5 |
+
token = os.environ['HF_TOKEN'] # Please navigate to Settings > Secrets and variables > Actions and define "HF_TOKEN".
|
6 |
+
repo_id = "gxurxv/optimus-metrics" # Please replace this value with the name of your own Hugging Face Space.
|
7 |
+
|
8 |
+
try:
|
9 |
+
HfApi().restart_space(repo_id=repo_id, token=token)
|
10 |
+
print(f"Successfully restarted Space: {repo_id}")
|
11 |
+
except Exception as e:
|
12 |
+
print(f"Failed to restart Space {repo_id}: {e}")
|
13 |
+
|
14 |
+
if __name__ == "__main__":
|
15 |
+
restart_space()
|