Spaces:
Runtime error
Runtime error
Fix Loading hang: remove demo.load, disable timer in UI-only mode
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import os
|
|
| 3 |
from pathlib import Path
|
| 4 |
|
| 5 |
import gradio as gr
|
|
|
|
| 6 |
|
| 7 |
from src.about import (
|
| 8 |
CITATION_BUTTON_LABEL,
|
|
@@ -86,7 +87,8 @@ def refresh_leaderboard() -> tuple:
|
|
| 86 |
build_status_line(status),
|
| 87 |
build_countdown_html(),
|
| 88 |
]
|
| 89 |
-
|
|
|
|
| 90 |
values_df = grouped["domain_values"].get(domain)
|
| 91 |
ranks_df = grouped["domain_ranks"].get(domain)
|
| 92 |
if values_df is not None and not values_df.empty:
|
|
@@ -100,6 +102,46 @@ def refresh_leaderboard() -> tuple:
|
|
| 100 |
return tuple(outputs)
|
| 101 |
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
def maybe_refresh_after_eval() -> tuple:
|
| 104 |
"""Refresh leaderboard only when eval state changes (start or finish)."""
|
| 105 |
global _last_seen_eval_token
|
|
@@ -119,10 +161,6 @@ def maybe_refresh_after_eval() -> tuple:
|
|
| 119 |
return refresh_leaderboard()
|
| 120 |
|
| 121 |
|
| 122 |
-
grouped_initial = get_grouped_dfs(RESULTS_PATH)
|
| 123 |
-
DOMAINS: list[str] = grouped_initial["domains"]
|
| 124 |
-
INITIAL_OUTPUTS = refresh_leaderboard()
|
| 125 |
-
|
| 126 |
demo = gr.Blocks(
|
| 127 |
css=build_custom_css(),
|
| 128 |
head=eval_countdown_head_js(),
|
|
@@ -180,9 +218,10 @@ with demo:
|
|
| 180 |
for values_df, ranks_df in domain_tables:
|
| 181 |
refresh_outputs.extend([values_df, ranks_df])
|
| 182 |
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
|
|
|
| 187 |
|
| 188 |
-
demo.
|
|
|
|
| 3 |
from pathlib import Path
|
| 4 |
|
| 5 |
import gradio as gr
|
| 6 |
+
import pandas as pd
|
| 7 |
|
| 8 |
from src.about import (
|
| 9 |
CITATION_BUTTON_LABEL,
|
|
|
|
| 87 |
build_status_line(status),
|
| 88 |
build_countdown_html(),
|
| 89 |
]
|
| 90 |
+
domains: list[str] = grouped["domains"]
|
| 91 |
+
for domain in domains:
|
| 92 |
values_df = grouped["domain_values"].get(domain)
|
| 93 |
ranks_df = grouped["domain_ranks"].get(domain)
|
| 94 |
if values_df is not None and not values_df.empty:
|
|
|
|
| 102 |
return tuple(outputs)
|
| 103 |
|
| 104 |
|
| 105 |
+
def load_initial_outputs() -> tuple[list[str], tuple]:
|
| 106 |
+
try:
|
| 107 |
+
grouped = get_grouped_dfs(RESULTS_PATH)
|
| 108 |
+
status = load_online_status(RESULTS_PATH)
|
| 109 |
+
domains = grouped["domains"]
|
| 110 |
+
outputs: list = [
|
| 111 |
+
prepare_values_table(grouped["overall_values"]),
|
| 112 |
+
prepare_ranks_table(grouped["overall_ranks"]),
|
| 113 |
+
build_status_line(status),
|
| 114 |
+
build_countdown_html(),
|
| 115 |
+
]
|
| 116 |
+
for domain in domains:
|
| 117 |
+
values_df = grouped["domain_values"].get(domain)
|
| 118 |
+
ranks_df = grouped["domain_ranks"].get(domain)
|
| 119 |
+
if values_df is not None and not values_df.empty:
|
| 120 |
+
outputs.append(prepare_values_table(values_df))
|
| 121 |
+
else:
|
| 122 |
+
outputs.append(prepare_values_table(grouped["overall_values"].iloc[:0]))
|
| 123 |
+
if ranks_df is not None and not ranks_df.empty:
|
| 124 |
+
outputs.append(prepare_ranks_table(ranks_df))
|
| 125 |
+
else:
|
| 126 |
+
outputs.append(prepare_ranks_table(grouped["overall_ranks"].iloc[:0]))
|
| 127 |
+
return domains, tuple(outputs)
|
| 128 |
+
except FileNotFoundError:
|
| 129 |
+
empty = pd.DataFrame(columns=["Model"])
|
| 130 |
+
placeholder = (
|
| 131 |
+
"**Leaderboard** · no `results/` data yet — "
|
| 132 |
+
"run `python scripts/run_online_daemon.py --once` locally"
|
| 133 |
+
)
|
| 134 |
+
return [], (
|
| 135 |
+
empty,
|
| 136 |
+
empty,
|
| 137 |
+
placeholder,
|
| 138 |
+
eval_countdown_markup(0, BENCHMARK_INTERVAL_SECONDS, running=False),
|
| 139 |
+
)
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
DOMAINS, INITIAL_OUTPUTS = load_initial_outputs()
|
| 143 |
+
|
| 144 |
+
|
| 145 |
def maybe_refresh_after_eval() -> tuple:
|
| 146 |
"""Refresh leaderboard only when eval state changes (start or finish)."""
|
| 147 |
global _last_seen_eval_token
|
|
|
|
| 161 |
return refresh_leaderboard()
|
| 162 |
|
| 163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
demo = gr.Blocks(
|
| 165 |
css=build_custom_css(),
|
| 166 |
head=eval_countdown_head_js(),
|
|
|
|
| 218 |
for values_df, ranks_df in domain_tables:
|
| 219 |
refresh_outputs.extend([values_df, ranks_df])
|
| 220 |
|
| 221 |
+
# UI-only: data updates on container rebuild after local push — no load hook or timer.
|
| 222 |
+
if LIVE_EVAL_ENABLED:
|
| 223 |
+
gr.Timer(value=EVAL_WATCH_POLL_SECONDS).tick(
|
| 224 |
+
maybe_refresh_after_eval, inputs=[], outputs=refresh_outputs
|
| 225 |
+
)
|
| 226 |
|
| 227 |
+
demo.launch()
|