Spaces:
Running
Running
Commit
Β·
b7b8a3b
1
Parent(s):
c297628
state based logic test
Browse files
main.py
CHANGED
|
@@ -351,11 +351,7 @@ def render_details(imputation, splits, tasks, datasets, lb_matrix):
|
|
| 351 |
make_overview_images(lb, subset_name=lb.name)
|
| 352 |
|
| 353 |
# Render Leaderboard safely
|
| 354 |
-
|
| 355 |
-
make_leaderboard(lb)
|
| 356 |
-
except Exception as e:
|
| 357 |
-
gr.Error(f"Error loading leaderboard: {e}")
|
| 358 |
-
gr.Markdown(f"β οΈ **Could not load table:** {e}")
|
| 359 |
|
| 360 |
gr.Image(
|
| 361 |
lb.get_path_to_winrate_matrix(),
|
|
@@ -424,6 +420,11 @@ def main():
|
|
| 424 |
gr.Markdown("## π TabArena Leaderboards")
|
| 425 |
lb_matrix = LBMatrix()
|
| 426 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 427 |
# Impute
|
| 428 |
with gr.Tabs(elem_classes="tab-buttons") as t_impute_tabs:
|
| 429 |
for impute_id, impute_t in enumerate(lb_matrix.imputation):
|
|
@@ -431,6 +432,7 @@ def main():
|
|
| 431 |
lb_matrix.get_name_for_lb("imputation", impute_t),
|
| 432 |
id=impute_id,
|
| 433 |
) as t_impute:
|
|
|
|
| 434 |
|
| 435 |
# Splits
|
| 436 |
with gr.Tabs(elem_classes="tab-buttons"):
|
|
@@ -441,16 +443,16 @@ def main():
|
|
| 441 |
),
|
| 442 |
id=f"{impute_id}_{splits_id}",
|
| 443 |
) as t_splits:
|
|
|
|
| 444 |
|
| 445 |
# Tasks
|
| 446 |
with gr.Tabs(elem_classes="tab-buttons"):
|
| 447 |
for tasks_id, tasks_t in enumerate(lb_matrix.tasks):
|
| 448 |
with gr.TabItem(
|
| 449 |
-
|
| 450 |
-
"tasks", tasks_t
|
| 451 |
-
),
|
| 452 |
id=f"{impute_id}_{splits_id}_{tasks_id}",
|
| 453 |
) as t_tasks:
|
|
|
|
| 454 |
|
| 455 |
# Datasets
|
| 456 |
with gr.Tabs(elem_classes="tab-buttons"):
|
|
@@ -459,19 +461,63 @@ def main():
|
|
| 459 |
datasets_t,
|
| 460 |
) in enumerate(lb_matrix.datasets):
|
| 461 |
with gr.TabItem(
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
id=f"{impute_id}_{splits_id}_{tasks_id}_{datasets_id}",
|
| 466 |
) as t_dataset:
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
datasets=datasets_t,
|
| 472 |
-
lb_matrix=lb_matrix,
|
| 473 |
)
|
| 474 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 475 |
|
| 476 |
with gr.Row(), gr.Accordion("π Version History", open=False):
|
| 477 |
gr.Markdown(VERSION_HISTORY_BUTTON_TEXT, elem_classes="markdown-text")
|
|
|
|
| 351 |
make_overview_images(lb, subset_name=lb.name)
|
| 352 |
|
| 353 |
# Render Leaderboard safely
|
| 354 |
+
make_leaderboard(lb)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
|
| 356 |
gr.Image(
|
| 357 |
lb.get_path_to_winrate_matrix(),
|
|
|
|
| 420 |
gr.Markdown("## π TabArena Leaderboards")
|
| 421 |
lb_matrix = LBMatrix()
|
| 422 |
|
| 423 |
+
impute_state = gr.State(lb_matrix.imputation[0])
|
| 424 |
+
splits_state = gr.State(lb_matrix.splits[0])
|
| 425 |
+
tasks_state = gr.State(lb_matrix.tasks[0])
|
| 426 |
+
datasets_state = gr.State(lb_matrix.datasets[0])
|
| 427 |
+
|
| 428 |
# Impute
|
| 429 |
with gr.Tabs(elem_classes="tab-buttons") as t_impute_tabs:
|
| 430 |
for impute_id, impute_t in enumerate(lb_matrix.imputation):
|
|
|
|
| 432 |
lb_matrix.get_name_for_lb("imputation", impute_t),
|
| 433 |
id=impute_id,
|
| 434 |
) as t_impute:
|
| 435 |
+
t_impute.select(lambda x=impute_t: x, outputs=impute_state)
|
| 436 |
|
| 437 |
# Splits
|
| 438 |
with gr.Tabs(elem_classes="tab-buttons"):
|
|
|
|
| 443 |
),
|
| 444 |
id=f"{impute_id}_{splits_id}",
|
| 445 |
) as t_splits:
|
| 446 |
+
t_splits.select(lambda x=splits_t: x, outputs=splits_state)
|
| 447 |
|
| 448 |
# Tasks
|
| 449 |
with gr.Tabs(elem_classes="tab-buttons"):
|
| 450 |
for tasks_id, tasks_t in enumerate(lb_matrix.tasks):
|
| 451 |
with gr.TabItem(
|
| 452 |
+
lb_matrix.get_name_for_lb("tasks", tasks_t),
|
|
|
|
|
|
|
| 453 |
id=f"{impute_id}_{splits_id}_{tasks_id}",
|
| 454 |
) as t_tasks:
|
| 455 |
+
t_tasks.select(lambda x=tasks_t: x, outputs=tasks_state)
|
| 456 |
|
| 457 |
# Datasets
|
| 458 |
with gr.Tabs(elem_classes="tab-buttons"):
|
|
|
|
| 461 |
datasets_t,
|
| 462 |
) in enumerate(lb_matrix.datasets):
|
| 463 |
with gr.TabItem(
|
| 464 |
+
lb_matrix.get_name_for_lb(
|
| 465 |
+
"datasets", datasets_t
|
| 466 |
+
),
|
| 467 |
id=f"{impute_id}_{splits_id}_{tasks_id}_{datasets_id}",
|
| 468 |
) as t_dataset:
|
| 469 |
+
# UPDATE STATE
|
| 470 |
+
t_dataset.select(
|
| 471 |
+
lambda x=datasets_t: x,
|
| 472 |
+
outputs=datasets_state,
|
|
|
|
|
|
|
| 473 |
)
|
| 474 |
|
| 475 |
+
# 2. DEFINE RENDER LOGIC
|
| 476 |
+
# We define a helper function to bind the current loop variables
|
| 477 |
+
# (context_i, context_s, etc.) so they don't get overwritten.
|
| 478 |
+
def define_render(
|
| 479 |
+
context_i,
|
| 480 |
+
context_s,
|
| 481 |
+
context_t,
|
| 482 |
+
context_d,
|
| 483 |
+
):
|
| 484 |
+
# This triggers whenever ANY of the 4 states change
|
| 485 |
+
@gr.render(
|
| 486 |
+
inputs=[
|
| 487 |
+
impute_state,
|
| 488 |
+
splits_state,
|
| 489 |
+
tasks_state,
|
| 490 |
+
datasets_state,
|
| 491 |
+
]
|
| 492 |
+
)
|
| 493 |
+
def reactive_render(
|
| 494 |
+
sel_i,
|
| 495 |
+
sel_s,
|
| 496 |
+
sel_t,
|
| 497 |
+
sel_d,
|
| 498 |
+
):
|
| 499 |
+
# 3. CONDITIONAL CHECK
|
| 500 |
+
# We only render if the Selected State matches THIS Tab's Context.
|
| 501 |
+
# This ensures we don't render the wrong data in the wrong tab.
|
| 502 |
+
if (
|
| 503 |
+
sel_i == context_i
|
| 504 |
+
and sel_s
|
| 505 |
+
== context_s
|
| 506 |
+
and sel_t
|
| 507 |
+
== context_t
|
| 508 |
+
and sel_d
|
| 509 |
+
== context_d
|
| 510 |
+
):
|
| 511 |
+
render_details(
|
| 512 |
+
imputation=sel_i,
|
| 513 |
+
splits=sel_s,
|
| 514 |
+
tasks=sel_t,
|
| 515 |
+
datasets=sel_d,
|
| 516 |
+
lb_matrix=lb_matrix,
|
| 517 |
+
)
|
| 518 |
+
|
| 519 |
+
# Call the helper to attach the render logic to this specific tab
|
| 520 |
+
define_render(impute_t, splits_t, tasks_t, datasets_t)
|
| 521 |
|
| 522 |
with gr.Row(), gr.Accordion("π Version History", open=False):
|
| 523 |
gr.Markdown(VERSION_HISTORY_BUTTON_TEXT, elem_classes="markdown-text")
|