Spaces:
Runtime error
Runtime error
Remove restart_scheduler
Browse files- app.py +0 -6
- requirements.txt +0 -2
- restart_scheduler.py +0 -24
- settings.py +0 -5
app.py
CHANGED
@@ -13,15 +13,9 @@ from constants import (
|
|
13 |
VISIBILITY_CHOICES,
|
14 |
)
|
15 |
from demo_list import DemoList, get_df_from_yaml
|
16 |
-
from restart_scheduler import RestartScheduler
|
17 |
-
from settings import HF_TOKEN, INTERVAL_MINUTES, SPACE_ID
|
18 |
|
19 |
demo_list = DemoList(get_df_from_yaml("list.yaml"))
|
20 |
|
21 |
-
if SPACE_ID is not None and INTERVAL_MINUTES > 0:
|
22 |
-
scheduler = RestartScheduler(space_id=SPACE_ID, interval_minutes=INTERVAL_MINUTES, hf_token=HF_TOKEN)
|
23 |
-
scheduler.start()
|
24 |
-
|
25 |
|
26 |
def update_status_checkboxes(choices: list[str]) -> list[str]:
|
27 |
if "(ALL)" in choices:
|
|
|
13 |
VISIBILITY_CHOICES,
|
14 |
)
|
15 |
from demo_list import DemoList, get_df_from_yaml
|
|
|
|
|
16 |
|
17 |
demo_list = DemoList(get_df_from_yaml("list.yaml"))
|
18 |
|
|
|
|
|
|
|
|
|
19 |
|
20 |
def update_status_checkboxes(choices: list[str]) -> list[str]:
|
21 |
if "(ALL)" in choices:
|
requirements.txt
CHANGED
@@ -1,7 +1,5 @@
|
|
1 |
-
apscheduler==3.10.4
|
2 |
gradio==3.41.2
|
3 |
huggingface-hub==0.16.4
|
4 |
pandas==2.0.3
|
5 |
PyYAML==6.0
|
6 |
-
requests==2.31.0
|
7 |
tqdm==4.66.1
|
|
|
|
|
1 |
gradio==3.41.2
|
2 |
huggingface-hub==0.16.4
|
3 |
pandas==2.0.3
|
4 |
PyYAML==6.0
|
|
|
5 |
tqdm==4.66.1
|
restart_scheduler.py
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
from apscheduler.schedulers.background import BackgroundScheduler
|
2 |
-
from huggingface_hub import HfApi
|
3 |
-
from huggingface_hub.utils import RepositoryNotFoundError
|
4 |
-
|
5 |
-
|
6 |
-
class RestartScheduler:
|
7 |
-
def __init__(self, space_id: str, interval_minutes: int, hf_token: str | None):
|
8 |
-
api = HfApi(token=hf_token)
|
9 |
-
if api.get_token_permission() != "write":
|
10 |
-
raise ValueError("The HF token must have write permission.")
|
11 |
-
try:
|
12 |
-
api.space_info(repo_id=space_id)
|
13 |
-
except RepositoryNotFoundError:
|
14 |
-
raise ValueError("The Space ID does not exist.")
|
15 |
-
if interval_minutes <= 0:
|
16 |
-
raise ValueError("The interval must be positive.")
|
17 |
-
|
18 |
-
self.scheduler = BackgroundScheduler()
|
19 |
-
self.scheduler.add_job(
|
20 |
-
func=lambda: api.restart_space(space_id), trigger="interval", seconds=60 * interval_minutes
|
21 |
-
)
|
22 |
-
|
23 |
-
def start(self):
|
24 |
-
self.scheduler.start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
settings.py
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
|
3 |
-
HF_TOKEN = os.getenv("HUGGING_FACE_HUB_TOKEN")
|
4 |
-
SPACE_ID = os.getenv("SPACE_ID")
|
5 |
-
INTERVAL_MINUTES = int(os.getenv("INTERVAL_MINUTES", "30"))
|
|
|
|
|
|
|
|
|
|
|
|