Spaces:
Running
Running
Added the button for restart the space
Browse files
app.py
CHANGED
@@ -16,8 +16,10 @@ from content import (
|
|
16 |
MORE_DETAILS_MARKDOWN,
|
17 |
ABOUT_MARKDOWN,
|
18 |
)
|
19 |
-
from server import LeaderboardServer, xmlAndMarkdownEscape, xmlQuoteAttr
|
20 |
|
|
|
|
|
21 |
# For testing purpose
|
22 |
HF_DISABLE_SUBMIT = bool(int(os.environ.get("HF_DISABLE_SUBMIT", "0")))
|
23 |
from server import HF_FAKE_TOURNAMENT
|
@@ -294,14 +296,30 @@ def results_dataset_integrity_check():
|
|
294 |
def update_results_dataset_integrity_solving_progress():
|
295 |
progress = leaderboard_server.tournament_results_integrity_solving_progress * 100
|
296 |
|
297 |
-
|
298 |
-
|
|
|
299 |
value=f"Tournament results is preparing, please wait… {progress:.0f}% done"
|
300 |
)
|
|
|
|
|
|
|
|
|
|
|
301 |
else:
|
302 |
-
|
303 |
-
value="Tournament results is prepared, please
|
304 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
|
306 |
def on_tournament_results_corrupted():
|
307 |
if leaderboard_server.tournament_results_corrupted and not leaderboard_server.tournament_results_integrity_solving:
|
@@ -326,6 +344,9 @@ def on_tournament_results_corrupted():
|
|
326 |
results_dataset_integrity_solving_progress,
|
327 |
)
|
328 |
|
|
|
|
|
|
|
329 |
def on_application_load():
|
330 |
with leaderboard_server.var_lock.ro:
|
331 |
leaderboard = gr.update(
|
@@ -393,13 +414,22 @@ def gradio_app():
|
|
393 |
visible=False,
|
394 |
)
|
395 |
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
results_dataset_integrity_solving_progress_timer = gr.Timer(
|
397 |
value=60, # seconds
|
398 |
)
|
399 |
|
400 |
results_dataset_integrity_solving_progress_timer.tick(
|
401 |
fn=update_results_dataset_integrity_solving_progress,
|
402 |
-
outputs=
|
|
|
|
|
|
|
403 |
)
|
404 |
|
405 |
results_dataset_integrity_check_btn.click(
|
@@ -415,6 +445,13 @@ def gradio_app():
|
|
415 |
fn=results_dataset_integrity_check
|
416 |
)
|
417 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
418 |
main.load(
|
419 |
fn=on_tournament_results_corrupted,
|
420 |
outputs=[
|
@@ -423,7 +460,10 @@ def gradio_app():
|
|
423 |
]
|
424 |
).then(
|
425 |
fn=update_results_dataset_integrity_solving_progress,
|
426 |
-
outputs=
|
|
|
|
|
|
|
427 |
)
|
428 |
|
429 |
return main
|
|
|
16 |
MORE_DETAILS_MARKDOWN,
|
17 |
ABOUT_MARKDOWN,
|
18 |
)
|
19 |
+
from server import LeaderboardServer, xmlAndMarkdownEscape, xmlQuoteAttr, api
|
20 |
|
21 |
+
HF_SPACE_TOKEN = os.environ["HF_SPACE_TOKEN"]
|
22 |
+
HF_SPACE_ID = os.environ["HF_SPACE_ID"]
|
23 |
# For testing purpose
|
24 |
HF_DISABLE_SUBMIT = bool(int(os.environ.get("HF_DISABLE_SUBMIT", "0")))
|
25 |
from server import HF_FAKE_TOURNAMENT
|
|
|
296 |
def update_results_dataset_integrity_solving_progress():
|
297 |
progress = leaderboard_server.tournament_results_integrity_solving_progress * 100
|
298 |
|
299 |
+
|
300 |
+
if leaderboard_server.tournament_results_corrupted:
|
301 |
+
results_dataset_integrity_solving_progress = gr.update(
|
302 |
value=f"Tournament results is preparing, please wait… {progress:.0f}% done"
|
303 |
)
|
304 |
+
|
305 |
+
results_dataset_integrity_restart_btn = gr.update(
|
306 |
+
interactive=False,
|
307 |
+
visible=False,
|
308 |
+
)
|
309 |
else:
|
310 |
+
results_dataset_integrity_solving_progress = gr.update(
|
311 |
+
value="Tournament results is prepared, please restart this space with the button showed below."
|
312 |
)
|
313 |
+
|
314 |
+
results_dataset_integrity_restart_btn = gr.update(
|
315 |
+
interactive=True,
|
316 |
+
visible=True,
|
317 |
+
)
|
318 |
+
|
319 |
+
return (
|
320 |
+
results_dataset_integrity_solving_progress,
|
321 |
+
results_dataset_integrity_restart_btn,
|
322 |
+
)
|
323 |
|
324 |
def on_tournament_results_corrupted():
|
325 |
if leaderboard_server.tournament_results_corrupted and not leaderboard_server.tournament_results_integrity_solving:
|
|
|
344 |
results_dataset_integrity_solving_progress,
|
345 |
)
|
346 |
|
347 |
+
def restart_space():
|
348 |
+
api.restart_space(repo_id=HF_SPACE_ID, token=HF_SPACE_TOKEN)
|
349 |
+
|
350 |
def on_application_load():
|
351 |
with leaderboard_server.var_lock.ro:
|
352 |
leaderboard = gr.update(
|
|
|
414 |
visible=False,
|
415 |
)
|
416 |
|
417 |
+
results_dataset_integrity_restart_btn = gr.Button(
|
418 |
+
value='Restart this space',
|
419 |
+
interactive=False,
|
420 |
+
visible=False,
|
421 |
+
)
|
422 |
+
|
423 |
results_dataset_integrity_solving_progress_timer = gr.Timer(
|
424 |
value=60, # seconds
|
425 |
)
|
426 |
|
427 |
results_dataset_integrity_solving_progress_timer.tick(
|
428 |
fn=update_results_dataset_integrity_solving_progress,
|
429 |
+
outputs=[
|
430 |
+
results_dataset_integrity_solving_progress,
|
431 |
+
results_dataset_integrity_restart_btn,
|
432 |
+
]
|
433 |
)
|
434 |
|
435 |
results_dataset_integrity_check_btn.click(
|
|
|
445 |
fn=results_dataset_integrity_check
|
446 |
)
|
447 |
|
448 |
+
results_dataset_integrity_restart_btn.click(
|
449 |
+
fn=lambda: gr.update(interactive=False),
|
450 |
+
outputs=results_dataset_integrity_restart_btn
|
451 |
+
).then(
|
452 |
+
fn=restart_space
|
453 |
+
)
|
454 |
+
|
455 |
main.load(
|
456 |
fn=on_tournament_results_corrupted,
|
457 |
outputs=[
|
|
|
460 |
]
|
461 |
).then(
|
462 |
fn=update_results_dataset_integrity_solving_progress,
|
463 |
+
outputs=[
|
464 |
+
results_dataset_integrity_solving_progress,
|
465 |
+
results_dataset_integrity_restart_btn,
|
466 |
+
]
|
467 |
)
|
468 |
|
469 |
return main
|
server.py
CHANGED
@@ -30,9 +30,10 @@ VISIBLE_METRICS = SUPPORTED_METRICS + ["macro_f1"]
|
|
30 |
|
31 |
api = HfApi()
|
32 |
|
|
|
|
|
|
|
33 |
HF_FAKE_TOURNAMENT = bool(int(os.environ.get("HF_FAKE_TOURNAMENT", "0")))
|
34 |
-
HF_RESULTS_DATASET = os.environ.get("HF_RESULTS_DATASET") # <HF_RESULTS_DATASET> ::= <owner> "/" <dataset name>; e.g. CZLC/LLM_benchmark_data
|
35 |
-
HF_TOKEN = os.environ.get("HF_TOKEN")
|
36 |
|
37 |
TASKS_METADATA_PATH = "./tasks_metadata.json"
|
38 |
|
|
|
30 |
|
31 |
api = HfApi()
|
32 |
|
33 |
+
HF_TOKEN = os.environ["HF_TOKEN"]
|
34 |
+
HF_RESULTS_DATASET = os.environ["HF_RESULTS_DATASET"] # <HF_RESULTS_DATASET> ::= <owner> "/" <dataset name>; e.g. CZLC/LLM_benchmark_data
|
35 |
+
# For testing purpose
|
36 |
HF_FAKE_TOURNAMENT = bool(int(os.environ.get("HF_FAKE_TOURNAMENT", "0")))
|
|
|
|
|
37 |
|
38 |
TASKS_METADATA_PATH = "./tasks_metadata.json"
|
39 |
|