Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import logging
|
|
3 |
import time
|
4 |
import gradio as gr
|
5 |
import datasets
|
6 |
-
from huggingface_hub import snapshot_download,
|
7 |
from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
|
8 |
from gradio_space_ci import enable_space_ci
|
9 |
|
@@ -290,26 +290,32 @@ with demo:
|
|
290 |
show_copy_button=True,
|
291 |
)
|
292 |
|
293 |
-
|
294 |
-
async def update_leaderboard(payload: WebhookPayload) -> None:
|
295 |
-
if payload.repo.type == "dataset" and payload.event.action == "update":
|
296 |
-
leaderboard_dataset = datasets.load_dataset(AGGREGATED_REPO, "default", split="train", cache_dir=HF_HOME)
|
297 |
-
leaderboard_df = get_leaderboard_df(
|
298 |
-
leaderboard_dataset=leaderboard_dataset,
|
299 |
-
cols=COLS,
|
300 |
-
benchmark_cols=BENCHMARK_COLS,
|
301 |
-
)
|
302 |
-
leaderboard.value = leaderboard_df
|
303 |
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
|
311 |
-
finished_eval_table.value = finished_eval_queue_df
|
312 |
-
running_eval_table.value = running_eval_queue_df
|
313 |
-
pending_eval_table.value = pending_eval_queue_df
|
314 |
|
315 |
-
|
|
|
3 |
import time
|
4 |
import gradio as gr
|
5 |
import datasets
|
6 |
+
from huggingface_hub import snapshot_download, WebhooksServer, WebhookPayload
|
7 |
from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
|
8 |
from gradio_space_ci import enable_space_ci
|
9 |
|
|
|
290 |
show_copy_button=True,
|
291 |
)
|
292 |
|
293 |
+
demo.queue(default_concurrency_limit=40)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
|
295 |
+
# Add webhooks
|
296 |
+
app = WebhooksServer(ui=demo)
|
297 |
+
|
298 |
+
@app.add_webhook
|
299 |
+
async def update_leaderboard(payload: WebhookPayload) -> None:
|
300 |
+
if payload.repo.type == "dataset" and payload.event.action == "update":
|
301 |
+
leaderboard_dataset = datasets.load_dataset(AGGREGATED_REPO, "default", split="train", cache_dir=HF_HOME)
|
302 |
+
leaderboard_df = get_leaderboard_df(
|
303 |
+
leaderboard_dataset=leaderboard_dataset,
|
304 |
+
cols=COLS,
|
305 |
+
benchmark_cols=BENCHMARK_COLS,
|
306 |
+
)
|
307 |
+
leaderboard.value = leaderboard_df
|
308 |
+
|
309 |
+
@app.add_webhook
|
310 |
+
async def update_queue(payload: WebhookPayload) -> None:
|
311 |
+
if payload.repo.type == "dataset" and payload.event.action == "update":
|
312 |
+
download_dataset(QUEUE_REPO, EVAL_REQUESTS_PATH)
|
313 |
+
eval_queue_dfs = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
|
314 |
+
finished_eval_queue_df, running_eval_queue_df, pending_eval_queue_df = eval_queue_dfs
|
315 |
+
|
316 |
+
finished_eval_table.value = finished_eval_queue_df
|
317 |
+
running_eval_table.value = running_eval_queue_df
|
318 |
+
pending_eval_table.value = pending_eval_queue_df
|
319 |
|
|
|
|
|
|
|
320 |
|
321 |
+
app.launch(share=True)
|