app: auto-refresh leaderboard + bootstrap logging
Browse filesStep 6 (E) chunk 5 plus a diagnostic.
Auto-refresh:
- gr.Dataframe now takes `value=load_leaderboard` (callable, not
its call result) plus `every=10`. Gradio re-invokes the function
every 10 seconds and re-renders the dataframe, so pending rows
visibly flip to completed / failed and freshly-submitted rows
appear within 10s without any user action. Manual Refresh
button stays as an "I want it now" override.
Logging bootstrap:
- logging.basicConfig(level=INFO, ...) at app startup so the
`logger.info` / `logger.warning` / `logger.exception` calls
already sprinkled through leaderboard.py and submit.py reach
the Space's runtime logs. Without this they go nowhere
(Python's default no-handler behaviour), which is why every
refresh / worker pathology so far has been silent.
Combined push: the auto-refresh might not surface new rows if
the underlying load_leaderboard returns stale data on the Space
for any reason (CDN, auth, frontend re-render bug); the bootstrap
makes the next round of diagnostics actually visible instead of
guesswork.
|
@@ -5,6 +5,8 @@ Read path lives in :mod:`leaderboard`. Submit-tab validation lives in
|
|
| 5 |
"""
|
| 6 |
from __future__ import annotations
|
| 7 |
|
|
|
|
|
|
|
| 8 |
import gradio as gr
|
| 9 |
|
| 10 |
from leaderboard import (
|
|
@@ -14,6 +16,15 @@ from leaderboard import (
|
|
| 14 |
)
|
| 15 |
from submit import handle_submit
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
ABOUT_MD = f"""## About
|
| 19 |
|
|
@@ -39,10 +50,11 @@ with gr.Blocks(title="CADGenBench Leaderboard") as app:
|
|
| 39 |
|
| 40 |
with gr.Tab("Leaderboard"):
|
| 41 |
df_view = gr.Dataframe(
|
| 42 |
-
value=load_leaderboard
|
| 43 |
interactive=False,
|
| 44 |
wrap=True,
|
| 45 |
label="Results (sorted by aggregate CAD score)",
|
|
|
|
| 46 |
)
|
| 47 |
refresh_btn = gr.Button("Refresh", size="sm")
|
| 48 |
refresh_btn.click(fn=load_leaderboard, outputs=df_view)
|
|
|
|
| 5 |
"""
|
| 6 |
from __future__ import annotations
|
| 7 |
|
| 8 |
+
import logging
|
| 9 |
+
|
| 10 |
import gradio as gr
|
| 11 |
|
| 12 |
from leaderboard import (
|
|
|
|
| 16 |
)
|
| 17 |
from submit import handle_submit
|
| 18 |
|
| 19 |
+
# Surface module-level logger.info / logger.warning / logger.exception
|
| 20 |
+
# calls from leaderboard.py + submit.py in the Space's runtime logs.
|
| 21 |
+
# Otherwise they go nowhere and any refresh / worker pathology is
|
| 22 |
+
# silent. Format keeps timestamps + module + level + message.
|
| 23 |
+
logging.basicConfig(
|
| 24 |
+
level=logging.INFO,
|
| 25 |
+
format="%(asctime)s %(levelname)s [%(name)s] %(message)s",
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
|
| 29 |
ABOUT_MD = f"""## About
|
| 30 |
|
|
|
|
| 50 |
|
| 51 |
with gr.Tab("Leaderboard"):
|
| 52 |
df_view = gr.Dataframe(
|
| 53 |
+
value=load_leaderboard,
|
| 54 |
interactive=False,
|
| 55 |
wrap=True,
|
| 56 |
label="Results (sorted by aggregate CAD score)",
|
| 57 |
+
every=10,
|
| 58 |
)
|
| 59 |
refresh_btn = gr.Button("Refresh", size="sm")
|
| 60 |
refresh_btn.click(fn=load_leaderboard, outputs=df_view)
|