Spaces:
Runtime error
Runtime error
Commit
•
73ffe91
1
Parent(s):
f38c66d
add restart_space schedule
Browse files- app.py +9 -1
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
import os
|
2 |
|
3 |
import gradio as gr
|
4 |
-
from
|
|
|
5 |
|
6 |
from src.assets.text_content import INTRODUCTION_TEXT, TITLE
|
7 |
|
@@ -10,8 +11,12 @@ from src.load_from_hub import load_from_hub
|
|
10 |
RESULTS_REPO = os.environ.get("RESULTS_REPO", "datasets/vlsp-2023-vllm/vllms-leaderboard")
|
11 |
HIDDEN_TOKEN = os.environ.get("HIDDEN_TOKEN")
|
12 |
|
|
|
13 |
fs = HfFileSystem(token=HIDDEN_TOKEN)
|
14 |
|
|
|
|
|
|
|
15 |
leaderboard_df = load_from_hub(fs, RESULTS_REPO)
|
16 |
|
17 |
demo = gr.Blocks()
|
@@ -34,4 +39,7 @@ with demo:
|
|
34 |
value=leaderboard_df,
|
35 |
)
|
36 |
|
|
|
|
|
|
|
37 |
demo.launch()
|
|
|
1 |
import os
|
2 |
|
3 |
import gradio as gr
|
4 |
+
from apscheduler.schedulers.background import BackgroundScheduler
|
5 |
+
from huggingface_hub import HfFileSystem, HfApi
|
6 |
|
7 |
from src.assets.text_content import INTRODUCTION_TEXT, TITLE
|
8 |
|
|
|
11 |
RESULTS_REPO = os.environ.get("RESULTS_REPO", "datasets/vlsp-2023-vllm/vllms-leaderboard")
|
12 |
HIDDEN_TOKEN = os.environ.get("HIDDEN_TOKEN")
|
13 |
|
14 |
+
api = HfApi(token=HIDDEN_TOKEN)
|
15 |
fs = HfFileSystem(token=HIDDEN_TOKEN)
|
16 |
|
17 |
+
def restart_space():
|
18 |
+
api.restart_space(repo_id="HuggingFaceH4/open_llm_leaderboard", token=HIDDEN_TOKEN)
|
19 |
+
|
20 |
leaderboard_df = load_from_hub(fs, RESULTS_REPO)
|
21 |
|
22 |
demo = gr.Blocks()
|
|
|
39 |
value=leaderboard_df,
|
40 |
)
|
41 |
|
42 |
+
scheduler = BackgroundScheduler()
|
43 |
+
scheduler.add_job(restart_space, "interval", seconds=1800)
|
44 |
+
scheduler.start()
|
45 |
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
APScheduler==3.10.1
|