Spaces:
Runtime error
Runtime error
Update
Browse files
app.py
CHANGED
@@ -11,16 +11,17 @@ from huggingface_hub import HfApi
|
|
11 |
|
12 |
from demo_list import DemoList
|
13 |
|
14 |
-
INTERVAL_MIN = int(os.getenv('INTERVAL_MIN', '10'))
|
15 |
-
|
16 |
demo_list = DemoList()
|
17 |
|
18 |
api = HfApi()
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
scheduler.
|
|
|
|
|
|
|
24 |
|
25 |
STATUS_CHOICES = [
|
26 |
'RUNNING',
|
@@ -45,7 +46,6 @@ SDK_CHOICES = [
|
|
45 |
'streamlit',
|
46 |
'docker',
|
47 |
]
|
48 |
-
WHOAMI = api.whoami()['name']
|
49 |
OWNER_CHOICES = [WHOAMI, 'other organizations']
|
50 |
|
51 |
|
|
|
11 |
|
12 |
from demo_list import DemoList
|
13 |
|
|
|
|
|
14 |
demo_list = DemoList()
|
15 |
|
16 |
api = HfApi()
|
17 |
+
WHOAMI = api.whoami()['name']
|
18 |
+
if (SPACE_ID := os.getenv('SPACE_ID')) is not None:
|
19 |
+
INTERVAL_MIN = int(os.getenv('INTERVAL_MIN', '10'))
|
20 |
+
scheduler = BackgroundScheduler()
|
21 |
+
scheduler.add_job(func=lambda: api.restart_space(SPACE_ID),
|
22 |
+
trigger='interval',
|
23 |
+
seconds=60 * INTERVAL_MIN)
|
24 |
+
scheduler.start()
|
25 |
|
26 |
STATUS_CHOICES = [
|
27 |
'RUNNING',
|
|
|
46 |
'streamlit',
|
47 |
'docker',
|
48 |
]
|
|
|
49 |
OWNER_CHOICES = [WHOAMI, 'other organizations']
|
50 |
|
51 |
|