Spaces:
Running
Running
openhands
commited on
Commit
·
361b5c2
1
Parent(s):
6bddf26
Move 'Show incomplete entries' checkbox above plot and apply filter to both
Browse files- Moved the checkbox above the scatter plot for better UX
- The checkbox now filters both the scatter plot AND the table
- Pre-computed both complete and all entries scatter plots for fast toggling
- When checkbox is toggled, both plot and table update simultaneously
- ui_components.py +46 -22
ui_components.py
CHANGED
|
@@ -551,7 +551,27 @@ def create_leaderboard_display(
|
|
| 551 |
# If no complete entries exist, show all entries by default
|
| 552 |
has_complete_entries = len(df_display_complete) > 0
|
| 553 |
|
| 554 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 555 |
|
| 556 |
# Now get headers from the renamed dataframe (use all entries to ensure headers are present)
|
| 557 |
df_headers = df_display_all.columns.tolist()
|
|
@@ -576,27 +596,34 @@ def create_leaderboard_display(
|
|
| 576 |
# 5. Combine all the lists to create the final, fully dynamic list.
|
| 577 |
final_column_widths = fixed_start_widths + dynamic_widths + fixed_end_widths
|
| 578 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 579 |
plot_component = gr.Plot(
|
| 580 |
-
value=
|
| 581 |
show_label=False,
|
| 582 |
)
|
| 583 |
gr.Markdown(value=SCATTER_DISCLAIMER, elem_id="scatter-disclaimer")
|
| 584 |
|
| 585 |
# Put table and key into an accordion
|
| 586 |
with gr.Accordion("Show / Hide Table View", open=True, elem_id="leaderboard-accordion"):
|
| 587 |
-
# Add toggle for showing incomplete entries
|
| 588 |
-
num_complete = len(df_display_complete)
|
| 589 |
-
num_total = len(df_display_all)
|
| 590 |
-
num_incomplete = num_total - num_complete
|
| 591 |
-
|
| 592 |
# If there are complete entries, show toggle. If not, show all entries.
|
| 593 |
if has_complete_entries:
|
| 594 |
-
show_incomplete_checkbox = gr.Checkbox(
|
| 595 |
-
label=f"Show incomplete entries ({num_incomplete} entries with fewer than 5 categories)",
|
| 596 |
-
value=False,
|
| 597 |
-
elem_id="show-incomplete-toggle"
|
| 598 |
-
)
|
| 599 |
-
|
| 600 |
# Start with complete entries only (default)
|
| 601 |
dataframe_component = gr.DataFrame(
|
| 602 |
headers=df_headers,
|
|
@@ -610,22 +637,19 @@ def create_leaderboard_display(
|
|
| 610 |
elem_id="main-leaderboard"
|
| 611 |
)
|
| 612 |
|
| 613 |
-
# Update function for the toggle
|
| 614 |
-
def
|
| 615 |
if show_incomplete:
|
| 616 |
-
return df_display_all
|
| 617 |
else:
|
| 618 |
-
return df_display_complete
|
| 619 |
|
| 620 |
show_incomplete_checkbox.change(
|
| 621 |
-
fn=
|
| 622 |
inputs=[show_incomplete_checkbox],
|
| 623 |
-
outputs=[dataframe_component]
|
| 624 |
)
|
| 625 |
else:
|
| 626 |
-
# No complete entries - show all entries and a note
|
| 627 |
-
gr.Markdown(f"*No entries with all 5 categories completed yet. Showing all {num_total} entries.*")
|
| 628 |
-
|
| 629 |
dataframe_component = gr.DataFrame(
|
| 630 |
headers=df_headers,
|
| 631 |
value=df_display_all,
|
|
|
|
| 551 |
# If no complete entries exist, show all entries by default
|
| 552 |
has_complete_entries = len(df_display_complete) > 0
|
| 553 |
|
| 554 |
+
# Determine primary score/cost columns for scatter plot
|
| 555 |
+
if category_name == "Overall":
|
| 556 |
+
primary_score_col = "Average Score"
|
| 557 |
+
primary_cost_col = "Average Cost"
|
| 558 |
+
else:
|
| 559 |
+
primary_score_col = f"{category_name} Score"
|
| 560 |
+
primary_cost_col = f"{category_name} Cost"
|
| 561 |
+
|
| 562 |
+
# Function to create scatter plot from data
|
| 563 |
+
def create_scatter_plot(df_data):
|
| 564 |
+
return _plot_scatter_plotly(
|
| 565 |
+
data=df_data,
|
| 566 |
+
x=primary_cost_col if primary_cost_col in df_data.columns else None,
|
| 567 |
+
y=primary_score_col if primary_score_col in df_data.columns else "Average Score",
|
| 568 |
+
agent_col="SDK Version",
|
| 569 |
+
name=category_name
|
| 570 |
+
)
|
| 571 |
+
|
| 572 |
+
# Create initial scatter plots for both complete and all data
|
| 573 |
+
scatter_plot_complete = create_scatter_plot(df_view_complete) if has_complete_entries else go.Figure()
|
| 574 |
+
scatter_plot_all = create_scatter_plot(df_view_full)
|
| 575 |
|
| 576 |
# Now get headers from the renamed dataframe (use all entries to ensure headers are present)
|
| 577 |
df_headers = df_display_all.columns.tolist()
|
|
|
|
| 596 |
# 5. Combine all the lists to create the final, fully dynamic list.
|
| 597 |
final_column_widths = fixed_start_widths + dynamic_widths + fixed_end_widths
|
| 598 |
|
| 599 |
+
# Calculate counts for the checkbox label
|
| 600 |
+
num_complete = len(df_display_complete)
|
| 601 |
+
num_total = len(df_display_all)
|
| 602 |
+
num_incomplete = num_total - num_complete
|
| 603 |
+
|
| 604 |
+
# Add toggle for showing incomplete entries ABOVE the plot
|
| 605 |
+
if has_complete_entries:
|
| 606 |
+
show_incomplete_checkbox = gr.Checkbox(
|
| 607 |
+
label=f"Show incomplete entries ({num_incomplete} entries with fewer than 5 categories)",
|
| 608 |
+
value=False,
|
| 609 |
+
elem_id="show-incomplete-toggle"
|
| 610 |
+
)
|
| 611 |
+
else:
|
| 612 |
+
show_incomplete_checkbox = None
|
| 613 |
+
gr.Markdown(f"*No entries with all 5 categories completed yet. Showing all {num_total} entries.*")
|
| 614 |
+
|
| 615 |
+
# Plot component - show complete entries by default if available
|
| 616 |
+
initial_plot = scatter_plot_complete if has_complete_entries else scatter_plot_all
|
| 617 |
plot_component = gr.Plot(
|
| 618 |
+
value=initial_plot,
|
| 619 |
show_label=False,
|
| 620 |
)
|
| 621 |
gr.Markdown(value=SCATTER_DISCLAIMER, elem_id="scatter-disclaimer")
|
| 622 |
|
| 623 |
# Put table and key into an accordion
|
| 624 |
with gr.Accordion("Show / Hide Table View", open=True, elem_id="leaderboard-accordion"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 625 |
# If there are complete entries, show toggle. If not, show all entries.
|
| 626 |
if has_complete_entries:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 627 |
# Start with complete entries only (default)
|
| 628 |
dataframe_component = gr.DataFrame(
|
| 629 |
headers=df_headers,
|
|
|
|
| 637 |
elem_id="main-leaderboard"
|
| 638 |
)
|
| 639 |
|
| 640 |
+
# Update function for the toggle - updates both table and plot
|
| 641 |
+
def update_display(show_incomplete):
|
| 642 |
if show_incomplete:
|
| 643 |
+
return df_display_all, scatter_plot_all
|
| 644 |
else:
|
| 645 |
+
return df_display_complete, scatter_plot_complete
|
| 646 |
|
| 647 |
show_incomplete_checkbox.change(
|
| 648 |
+
fn=update_display,
|
| 649 |
inputs=[show_incomplete_checkbox],
|
| 650 |
+
outputs=[dataframe_component, plot_component]
|
| 651 |
)
|
| 652 |
else:
|
|
|
|
|
|
|
|
|
|
| 653 |
dataframe_component = gr.DataFrame(
|
| 654 |
headers=df_headers,
|
| 655 |
value=df_display_all,
|