Spaces:
Running
Running
Add show_all_labels to check_and_refresh_data and check_and_refresh_all functions
#20
by juan-all-hands - opened
- ui_components.py +27 -49
ui_components.py
CHANGED
|
@@ -705,7 +705,7 @@ def create_leaderboard_display(
|
|
| 705 |
primary_runtime_col = f"{category_name} Runtime"
|
| 706 |
|
| 707 |
# Function to create cost/performance scatter plot from data
|
| 708 |
-
def create_cost_scatter_plot(df_data, mark_by=MARK_BY_DEFAULT
|
| 709 |
return _plot_scatter_plotly(
|
| 710 |
data=df_data,
|
| 711 |
x=primary_cost_col if primary_cost_col in df_data.columns else None,
|
|
@@ -713,12 +713,11 @@ def create_leaderboard_display(
|
|
| 713 |
agent_col="SDK Version",
|
| 714 |
name=category_name,
|
| 715 |
plot_type='cost',
|
| 716 |
-
mark_by=mark_by
|
| 717 |
-
show_all_labels=show_all_labels
|
| 718 |
)
|
| 719 |
|
| 720 |
# Function to create runtime/performance scatter plot from data
|
| 721 |
-
def create_runtime_scatter_plot(df_data, mark_by=MARK_BY_DEFAULT
|
| 722 |
return _plot_scatter_plotly(
|
| 723 |
data=df_data,
|
| 724 |
x=primary_runtime_col if primary_runtime_col in df_data.columns else None,
|
|
@@ -726,8 +725,7 @@ def create_leaderboard_display(
|
|
| 726 |
agent_col="SDK Version",
|
| 727 |
name=category_name,
|
| 728 |
plot_type='runtime',
|
| 729 |
-
mark_by=mark_by
|
| 730 |
-
show_all_labels=show_all_labels
|
| 731 |
)
|
| 732 |
|
| 733 |
# Create initial cost scatter plots for all filter combinations
|
|
@@ -774,7 +772,7 @@ def create_leaderboard_display(
|
|
| 774 |
|
| 775 |
# Add toggle checkboxes and dropdown ABOVE the plot
|
| 776 |
with gr.Row():
|
| 777 |
-
with gr.Column(scale=3):
|
| 778 |
if has_complete_entries:
|
| 779 |
show_incomplete_checkbox = gr.Checkbox(
|
| 780 |
label=f"Show incomplete entries ({num_incomplete} entries with fewer than 5 categories)",
|
|
@@ -794,13 +792,6 @@ def create_leaderboard_display(
|
|
| 794 |
)
|
| 795 |
else:
|
| 796 |
show_open_only_checkbox = None
|
| 797 |
-
|
| 798 |
-
# Add checkbox for showing all labels on scatter plot
|
| 799 |
-
show_all_labels_checkbox = gr.Checkbox(
|
| 800 |
-
label="Show all labels on scatter plots",
|
| 801 |
-
value=False,
|
| 802 |
-
elem_id="show-all-labels-toggle"
|
| 803 |
-
)
|
| 804 |
|
| 805 |
with gr.Column(scale=1):
|
| 806 |
mark_by_dropdown = gr.Dropdown(
|
|
@@ -844,7 +835,7 @@ def create_leaderboard_display(
|
|
| 844 |
)
|
| 845 |
|
| 846 |
# Update function for filters - handles checkboxes and mark_by dropdown
|
| 847 |
-
def update_display(show_incomplete, show_open_only, mark_by
|
| 848 |
# Determine which dataframe to show based on checkbox states
|
| 849 |
if show_open_only:
|
| 850 |
df_to_show = df_display_open if show_incomplete else df_display_complete_open
|
|
@@ -853,9 +844,9 @@ def create_leaderboard_display(
|
|
| 853 |
df_to_show = df_display_all if show_incomplete else df_display_complete
|
| 854 |
view_df = df_view_full if show_incomplete else df_view_complete
|
| 855 |
|
| 856 |
-
# Regenerate plots with current mark_by
|
| 857 |
-
cost_plot = create_cost_scatter_plot(view_df, mark_by
|
| 858 |
-
runtime_plot = create_runtime_scatter_plot(view_df, mark_by
|
| 859 |
return df_to_show, cost_plot, runtime_plot
|
| 860 |
|
| 861 |
# Connect checkboxes and dropdown to the update function
|
|
@@ -866,7 +857,6 @@ def create_leaderboard_display(
|
|
| 866 |
# Add a dummy value for show_open_only when checkbox doesn't exist
|
| 867 |
filter_inputs = [show_incomplete_checkbox, gr.State(value=False)]
|
| 868 |
filter_inputs.append(mark_by_dropdown)
|
| 869 |
-
filter_inputs.append(show_all_labels_checkbox)
|
| 870 |
|
| 871 |
show_incomplete_checkbox.change(
|
| 872 |
fn=update_display,
|
|
@@ -884,11 +874,6 @@ def create_leaderboard_display(
|
|
| 884 |
inputs=filter_inputs,
|
| 885 |
outputs=[dataframe_component, cost_plot_component, runtime_plot_component]
|
| 886 |
)
|
| 887 |
-
show_all_labels_checkbox.change(
|
| 888 |
-
fn=update_display,
|
| 889 |
-
inputs=filter_inputs,
|
| 890 |
-
outputs=[dataframe_component, cost_plot_component, runtime_plot_component]
|
| 891 |
-
)
|
| 892 |
else:
|
| 893 |
dataframe_component = gr.DataFrame(
|
| 894 |
headers=df_headers,
|
|
@@ -903,15 +888,15 @@ def create_leaderboard_display(
|
|
| 903 |
)
|
| 904 |
|
| 905 |
# Update function for mark_by and optional open_only checkbox
|
| 906 |
-
def update_display_no_complete(show_open_only, mark_by
|
| 907 |
if show_open_only:
|
| 908 |
df_to_show = df_display_open
|
| 909 |
view_df = df_view_open
|
| 910 |
else:
|
| 911 |
df_to_show = df_display_all
|
| 912 |
view_df = df_view_full
|
| 913 |
-
cost_plot = create_cost_scatter_plot(view_df, mark_by
|
| 914 |
-
runtime_plot = create_runtime_scatter_plot(view_df, mark_by
|
| 915 |
return df_to_show, cost_plot, runtime_plot
|
| 916 |
|
| 917 |
filter_inputs_no_complete = []
|
|
@@ -920,7 +905,6 @@ def create_leaderboard_display(
|
|
| 920 |
else:
|
| 921 |
filter_inputs_no_complete.append(gr.State(value=False))
|
| 922 |
filter_inputs_no_complete.append(mark_by_dropdown)
|
| 923 |
-
filter_inputs_no_complete.append(show_all_labels_checkbox)
|
| 924 |
|
| 925 |
if show_open_only_checkbox is not None:
|
| 926 |
show_open_only_checkbox.change(
|
|
@@ -933,11 +917,6 @@ def create_leaderboard_display(
|
|
| 933 |
inputs=filter_inputs_no_complete,
|
| 934 |
outputs=[dataframe_component, cost_plot_component, runtime_plot_component]
|
| 935 |
)
|
| 936 |
-
show_all_labels_checkbox.change(
|
| 937 |
-
fn=update_display_no_complete,
|
| 938 |
-
inputs=filter_inputs_no_complete,
|
| 939 |
-
outputs=[dataframe_component, cost_plot_component, runtime_plot_component]
|
| 940 |
-
)
|
| 941 |
|
| 942 |
legend_markdown = create_legend_markdown(category_name)
|
| 943 |
gr.HTML(value=legend_markdown, elem_id="legend-markdown")
|
|
@@ -974,16 +953,16 @@ def create_leaderboard_display(
|
|
| 974 |
new_df_display_open = prepare_df_for_display(new_df_view_open)
|
| 975 |
new_df_display_complete_open = prepare_df_for_display(new_df_view_complete_open)
|
| 976 |
|
| 977 |
-
# Create new scatter plots for all combinations (with current mark_by
|
| 978 |
-
new_cost_scatter_complete = create_cost_scatter_plot(new_df_view_complete, mark_by
|
| 979 |
-
new_cost_scatter_all = create_cost_scatter_plot(new_df_view_full, mark_by
|
| 980 |
-
new_cost_scatter_open = create_cost_scatter_plot(new_df_view_open, mark_by
|
| 981 |
-
new_cost_scatter_complete_open = create_cost_scatter_plot(new_df_view_complete_open, mark_by
|
| 982 |
|
| 983 |
-
new_runtime_scatter_complete = create_runtime_scatter_plot(new_df_view_complete, mark_by
|
| 984 |
-
new_runtime_scatter_all = create_runtime_scatter_plot(new_df_view_full, mark_by
|
| 985 |
-
new_runtime_scatter_open = create_runtime_scatter_plot(new_df_view_open, mark_by
|
| 986 |
-
new_runtime_scatter_complete_open = create_runtime_scatter_plot(new_df_view_complete_open, mark_by
|
| 987 |
|
| 988 |
# Return the appropriate data based on checkbox states
|
| 989 |
if show_open_only:
|
|
@@ -1018,7 +997,6 @@ def create_leaderboard_display(
|
|
| 1018 |
if show_open_only_checkbox is not None:
|
| 1019 |
timer_inputs.append(show_open_only_checkbox)
|
| 1020 |
timer_inputs.append(mark_by_dropdown) # Always include mark_by
|
| 1021 |
-
timer_inputs.append(show_all_labels_checkbox)
|
| 1022 |
refresh_timer.tick(
|
| 1023 |
fn=check_and_refresh_data,
|
| 1024 |
inputs=timer_inputs,
|
|
@@ -1039,8 +1017,8 @@ def create_leaderboard_display(
|
|
| 1039 |
new_df_view_full = new_df_view_full[new_df_view_full['Openness'].str.lower() == 'open'].copy()
|
| 1040 |
|
| 1041 |
new_df_display_all = prepare_df_for_display(new_df_view_full)
|
| 1042 |
-
new_cost_scatter_all = create_cost_scatter_plot(new_df_view_full, mark_by
|
| 1043 |
-
new_runtime_scatter_all = create_runtime_scatter_plot(new_df_view_full, mark_by
|
| 1044 |
return new_df_display_all, new_cost_scatter_all, new_runtime_scatter_all
|
| 1045 |
|
| 1046 |
if show_open_only:
|
|
@@ -1050,15 +1028,15 @@ def create_leaderboard_display(
|
|
| 1050 |
if show_open_only_checkbox is not None:
|
| 1051 |
refresh_timer.tick(
|
| 1052 |
fn=check_and_refresh_all,
|
| 1053 |
-
inputs=[show_open_only_checkbox, mark_by_dropdown
|
| 1054 |
outputs=[dataframe_component, cost_plot_component, runtime_plot_component]
|
| 1055 |
)
|
| 1056 |
else:
|
| 1057 |
-
def check_and_refresh_simple(mark_by=MARK_BY_DEFAULT
|
| 1058 |
-
return check_and_refresh_all(False, mark_by
|
| 1059 |
refresh_timer.tick(
|
| 1060 |
fn=check_and_refresh_simple,
|
| 1061 |
-
inputs=[mark_by_dropdown
|
| 1062 |
outputs=[dataframe_component, cost_plot_component, runtime_plot_component]
|
| 1063 |
)
|
| 1064 |
|
|
|
|
| 705 |
primary_runtime_col = f"{category_name} Runtime"
|
| 706 |
|
| 707 |
# Function to create cost/performance scatter plot from data
|
| 708 |
+
def create_cost_scatter_plot(df_data, mark_by=MARK_BY_DEFAULT):
|
| 709 |
return _plot_scatter_plotly(
|
| 710 |
data=df_data,
|
| 711 |
x=primary_cost_col if primary_cost_col in df_data.columns else None,
|
|
|
|
| 713 |
agent_col="SDK Version",
|
| 714 |
name=category_name,
|
| 715 |
plot_type='cost',
|
| 716 |
+
mark_by=mark_by
|
|
|
|
| 717 |
)
|
| 718 |
|
| 719 |
# Function to create runtime/performance scatter plot from data
|
| 720 |
+
def create_runtime_scatter_plot(df_data, mark_by=MARK_BY_DEFAULT):
|
| 721 |
return _plot_scatter_plotly(
|
| 722 |
data=df_data,
|
| 723 |
x=primary_runtime_col if primary_runtime_col in df_data.columns else None,
|
|
|
|
| 725 |
agent_col="SDK Version",
|
| 726 |
name=category_name,
|
| 727 |
plot_type='runtime',
|
| 728 |
+
mark_by=mark_by
|
|
|
|
| 729 |
)
|
| 730 |
|
| 731 |
# Create initial cost scatter plots for all filter combinations
|
|
|
|
| 772 |
|
| 773 |
# Add toggle checkboxes and dropdown ABOVE the plot
|
| 774 |
with gr.Row():
|
| 775 |
+
with gr.Column(scale=3, elem_classes=["oh-leaderboard-filter-col"]):
|
| 776 |
if has_complete_entries:
|
| 777 |
show_incomplete_checkbox = gr.Checkbox(
|
| 778 |
label=f"Show incomplete entries ({num_incomplete} entries with fewer than 5 categories)",
|
|
|
|
| 792 |
)
|
| 793 |
else:
|
| 794 |
show_open_only_checkbox = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 795 |
|
| 796 |
with gr.Column(scale=1):
|
| 797 |
mark_by_dropdown = gr.Dropdown(
|
|
|
|
| 835 |
)
|
| 836 |
|
| 837 |
# Update function for filters - handles checkboxes and mark_by dropdown
|
| 838 |
+
def update_display(show_incomplete, show_open_only, mark_by):
|
| 839 |
# Determine which dataframe to show based on checkbox states
|
| 840 |
if show_open_only:
|
| 841 |
df_to_show = df_display_open if show_incomplete else df_display_complete_open
|
|
|
|
| 844 |
df_to_show = df_display_all if show_incomplete else df_display_complete
|
| 845 |
view_df = df_view_full if show_incomplete else df_view_complete
|
| 846 |
|
| 847 |
+
# Regenerate plots with current mark_by setting
|
| 848 |
+
cost_plot = create_cost_scatter_plot(view_df, mark_by)
|
| 849 |
+
runtime_plot = create_runtime_scatter_plot(view_df, mark_by)
|
| 850 |
return df_to_show, cost_plot, runtime_plot
|
| 851 |
|
| 852 |
# Connect checkboxes and dropdown to the update function
|
|
|
|
| 857 |
# Add a dummy value for show_open_only when checkbox doesn't exist
|
| 858 |
filter_inputs = [show_incomplete_checkbox, gr.State(value=False)]
|
| 859 |
filter_inputs.append(mark_by_dropdown)
|
|
|
|
| 860 |
|
| 861 |
show_incomplete_checkbox.change(
|
| 862 |
fn=update_display,
|
|
|
|
| 874 |
inputs=filter_inputs,
|
| 875 |
outputs=[dataframe_component, cost_plot_component, runtime_plot_component]
|
| 876 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 877 |
else:
|
| 878 |
dataframe_component = gr.DataFrame(
|
| 879 |
headers=df_headers,
|
|
|
|
| 888 |
)
|
| 889 |
|
| 890 |
# Update function for mark_by and optional open_only checkbox
|
| 891 |
+
def update_display_no_complete(show_open_only, mark_by):
|
| 892 |
if show_open_only:
|
| 893 |
df_to_show = df_display_open
|
| 894 |
view_df = df_view_open
|
| 895 |
else:
|
| 896 |
df_to_show = df_display_all
|
| 897 |
view_df = df_view_full
|
| 898 |
+
cost_plot = create_cost_scatter_plot(view_df, mark_by)
|
| 899 |
+
runtime_plot = create_runtime_scatter_plot(view_df, mark_by)
|
| 900 |
return df_to_show, cost_plot, runtime_plot
|
| 901 |
|
| 902 |
filter_inputs_no_complete = []
|
|
|
|
| 905 |
else:
|
| 906 |
filter_inputs_no_complete.append(gr.State(value=False))
|
| 907 |
filter_inputs_no_complete.append(mark_by_dropdown)
|
|
|
|
| 908 |
|
| 909 |
if show_open_only_checkbox is not None:
|
| 910 |
show_open_only_checkbox.change(
|
|
|
|
| 917 |
inputs=filter_inputs_no_complete,
|
| 918 |
outputs=[dataframe_component, cost_plot_component, runtime_plot_component]
|
| 919 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 920 |
|
| 921 |
legend_markdown = create_legend_markdown(category_name)
|
| 922 |
gr.HTML(value=legend_markdown, elem_id="legend-markdown")
|
|
|
|
| 953 |
new_df_display_open = prepare_df_for_display(new_df_view_open)
|
| 954 |
new_df_display_complete_open = prepare_df_for_display(new_df_view_complete_open)
|
| 955 |
|
| 956 |
+
# Create new scatter plots for all combinations (with current mark_by)
|
| 957 |
+
new_cost_scatter_complete = create_cost_scatter_plot(new_df_view_complete, mark_by) if len(new_df_display_complete) > 0 else go.Figure()
|
| 958 |
+
new_cost_scatter_all = create_cost_scatter_plot(new_df_view_full, mark_by)
|
| 959 |
+
new_cost_scatter_open = create_cost_scatter_plot(new_df_view_open, mark_by) if len(new_df_view_open) > 0 else go.Figure()
|
| 960 |
+
new_cost_scatter_complete_open = create_cost_scatter_plot(new_df_view_complete_open, mark_by) if len(new_df_view_complete_open) > 0 else go.Figure()
|
| 961 |
|
| 962 |
+
new_runtime_scatter_complete = create_runtime_scatter_plot(new_df_view_complete, mark_by) if len(new_df_display_complete) > 0 else go.Figure()
|
| 963 |
+
new_runtime_scatter_all = create_runtime_scatter_plot(new_df_view_full, mark_by)
|
| 964 |
+
new_runtime_scatter_open = create_runtime_scatter_plot(new_df_view_open, mark_by) if len(new_df_view_open) > 0 else go.Figure()
|
| 965 |
+
new_runtime_scatter_complete_open = create_runtime_scatter_plot(new_df_view_complete_open, mark_by) if len(new_df_view_complete_open) > 0 else go.Figure()
|
| 966 |
|
| 967 |
# Return the appropriate data based on checkbox states
|
| 968 |
if show_open_only:
|
|
|
|
| 997 |
if show_open_only_checkbox is not None:
|
| 998 |
timer_inputs.append(show_open_only_checkbox)
|
| 999 |
timer_inputs.append(mark_by_dropdown) # Always include mark_by
|
|
|
|
| 1000 |
refresh_timer.tick(
|
| 1001 |
fn=check_and_refresh_data,
|
| 1002 |
inputs=timer_inputs,
|
|
|
|
| 1017 |
new_df_view_full = new_df_view_full[new_df_view_full['Openness'].str.lower() == 'open'].copy()
|
| 1018 |
|
| 1019 |
new_df_display_all = prepare_df_for_display(new_df_view_full)
|
| 1020 |
+
new_cost_scatter_all = create_cost_scatter_plot(new_df_view_full, mark_by)
|
| 1021 |
+
new_runtime_scatter_all = create_runtime_scatter_plot(new_df_view_full, mark_by)
|
| 1022 |
return new_df_display_all, new_cost_scatter_all, new_runtime_scatter_all
|
| 1023 |
|
| 1024 |
if show_open_only:
|
|
|
|
| 1028 |
if show_open_only_checkbox is not None:
|
| 1029 |
refresh_timer.tick(
|
| 1030 |
fn=check_and_refresh_all,
|
| 1031 |
+
inputs=[show_open_only_checkbox, mark_by_dropdown],
|
| 1032 |
outputs=[dataframe_component, cost_plot_component, runtime_plot_component]
|
| 1033 |
)
|
| 1034 |
else:
|
| 1035 |
+
def check_and_refresh_simple(mark_by=MARK_BY_DEFAULT):
|
| 1036 |
+
return check_and_refresh_all(False, mark_by)
|
| 1037 |
refresh_timer.tick(
|
| 1038 |
fn=check_and_refresh_simple,
|
| 1039 |
+
inputs=[mark_by_dropdown],
|
| 1040 |
outputs=[dataframe_component, cost_plot_component, runtime_plot_component]
|
| 1041 |
)
|
| 1042 |
|