juan-all-hands commited on
Commit
8a121c1
·
verified ·
1 Parent(s): a8f1aa1

Keep show_all_labels checkbox from original (sync with main)

Browse files
Files changed (1) hide show
  1. ui_components.py +29 -45
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, show_all_labels=False):
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, show_all_labels=False):
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,7 +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",
@@ -844,7 +841,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, show_all_labels):
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 +850,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 and show_all_labels settings
857
- cost_plot = create_cost_scatter_plot(view_df, mark_by, show_all_labels)
858
- runtime_plot = create_runtime_scatter_plot(view_df, mark_by, show_all_labels)
859
  return df_to_show, cost_plot, runtime_plot
860
 
861
  # Connect checkboxes and dropdown to the update function
@@ -866,7 +863,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 +880,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 +894,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, show_all_labels):
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, show_all_labels)
914
- runtime_plot = create_runtime_scatter_plot(view_df, mark_by, show_all_labels)
915
  return df_to_show, cost_plot, runtime_plot
916
 
917
  filter_inputs_no_complete = []
@@ -920,7 +911,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,18 +923,13 @@ 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")
944
 
945
  # Add a timer to periodically check for data updates and refresh the UI
946
  # This runs every 60 seconds to check if new data is available
947
- def check_and_refresh_data(show_incomplete, show_open_only=False, mark_by=MARK_BY_DEFAULT, show_all_labels=False):
948
  """Check if data has been refreshed and return updated data if so."""
949
  current_version = get_data_version()
950
  if current_version > initial_data_version:
@@ -974,16 +959,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 and show_all_labels)
978
- new_cost_scatter_complete = create_cost_scatter_plot(new_df_view_complete, mark_by, show_all_labels) if len(new_df_display_complete) > 0 else go.Figure()
979
- new_cost_scatter_all = create_cost_scatter_plot(new_df_view_full, mark_by, show_all_labels)
980
- new_cost_scatter_open = create_cost_scatter_plot(new_df_view_open, mark_by, show_all_labels) if len(new_df_view_open) > 0 else go.Figure()
981
- new_cost_scatter_complete_open = create_cost_scatter_plot(new_df_view_complete_open, mark_by, show_all_labels) if len(new_df_view_complete_open) > 0 else go.Figure()
982
 
983
- new_runtime_scatter_complete = create_runtime_scatter_plot(new_df_view_complete, mark_by, show_all_labels) if len(new_df_display_complete) > 0 else go.Figure()
984
- new_runtime_scatter_all = create_runtime_scatter_plot(new_df_view_full, mark_by, show_all_labels)
985
- new_runtime_scatter_open = create_runtime_scatter_plot(new_df_view_open, mark_by, show_all_labels) if len(new_df_view_open) > 0 else go.Figure()
986
- new_runtime_scatter_complete_open = create_runtime_scatter_plot(new_df_view_complete_open, mark_by, show_all_labels) if len(new_df_view_complete_open) > 0 else go.Figure()
987
 
988
  # Return the appropriate data based on checkbox states
989
  if show_open_only:
@@ -1018,7 +1003,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,
@@ -1026,7 +1010,7 @@ def create_leaderboard_display(
1026
  )
1027
  else:
1028
  # If no incomplete checkbox, always show all data (but still filter by open if needed)
1029
- def check_and_refresh_all(show_open_only=False, mark_by=MARK_BY_DEFAULT, show_all_labels=False):
1030
  current_version = get_data_version()
1031
  if current_version > initial_data_version:
1032
  print(f"[REFRESH] Data version changed, reloading...")
@@ -1039,8 +1023,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, show_all_labels)
1043
- new_runtime_scatter_all = create_runtime_scatter_plot(new_df_view_full, mark_by, show_all_labels)
1044
  return new_df_display_all, new_cost_scatter_all, new_runtime_scatter_all
1045
 
1046
  if show_open_only:
@@ -1050,15 +1034,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, show_all_labels_checkbox],
1054
  outputs=[dataframe_component, cost_plot_component, runtime_plot_component]
1055
  )
1056
  else:
1057
- def check_and_refresh_simple(mark_by=MARK_BY_DEFAULT, show_all_labels=False):
1058
- return check_and_refresh_all(False, mark_by, show_all_labels)
1059
  refresh_timer.tick(
1060
  fn=check_and_refresh_simple,
1061
- inputs=[mark_by_dropdown, show_all_labels_checkbox],
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
  # Add checkbox for showing all labels on scatter plot
796
  show_all_labels_checkbox = gr.Checkbox(
797
  label="Show all labels on scatter plots",
 
841
  )
842
 
843
  # Update function for filters - handles checkboxes and mark_by dropdown
844
+ def update_display(show_incomplete, show_open_only, mark_by):
845
  # Determine which dataframe to show based on checkbox states
846
  if show_open_only:
847
  df_to_show = df_display_open if show_incomplete else df_display_complete_open
 
850
  df_to_show = df_display_all if show_incomplete else df_display_complete
851
  view_df = df_view_full if show_incomplete else df_view_complete
852
 
853
+ # Regenerate plots with current mark_by setting
854
+ cost_plot = create_cost_scatter_plot(view_df, mark_by)
855
+ runtime_plot = create_runtime_scatter_plot(view_df, mark_by)
856
  return df_to_show, cost_plot, runtime_plot
857
 
858
  # Connect checkboxes and dropdown to the update function
 
863
  # Add a dummy value for show_open_only when checkbox doesn't exist
864
  filter_inputs = [show_incomplete_checkbox, gr.State(value=False)]
865
  filter_inputs.append(mark_by_dropdown)
 
866
 
867
  show_incomplete_checkbox.change(
868
  fn=update_display,
 
880
  inputs=filter_inputs,
881
  outputs=[dataframe_component, cost_plot_component, runtime_plot_component]
882
  )
 
 
 
 
 
883
  else:
884
  dataframe_component = gr.DataFrame(
885
  headers=df_headers,
 
894
  )
895
 
896
  # Update function for mark_by and optional open_only checkbox
897
+ def update_display_no_complete(show_open_only, mark_by):
898
  if show_open_only:
899
  df_to_show = df_display_open
900
  view_df = df_view_open
901
  else:
902
  df_to_show = df_display_all
903
  view_df = df_view_full
904
+ cost_plot = create_cost_scatter_plot(view_df, mark_by)
905
+ runtime_plot = create_runtime_scatter_plot(view_df, mark_by)
906
  return df_to_show, cost_plot, runtime_plot
907
 
908
  filter_inputs_no_complete = []
 
911
  else:
912
  filter_inputs_no_complete.append(gr.State(value=False))
913
  filter_inputs_no_complete.append(mark_by_dropdown)
 
914
 
915
  if show_open_only_checkbox is not None:
916
  show_open_only_checkbox.change(
 
923
  inputs=filter_inputs_no_complete,
924
  outputs=[dataframe_component, cost_plot_component, runtime_plot_component]
925
  )
 
 
 
 
 
926
 
927
  legend_markdown = create_legend_markdown(category_name)
928
  gr.HTML(value=legend_markdown, elem_id="legend-markdown")
929
 
930
  # Add a timer to periodically check for data updates and refresh the UI
931
  # This runs every 60 seconds to check if new data is available
932
+ def check_and_refresh_data(show_incomplete, show_open_only=False, mark_by=MARK_BY_DEFAULT):
933
  """Check if data has been refreshed and return updated data if so."""
934
  current_version = get_data_version()
935
  if current_version > initial_data_version:
 
959
  new_df_display_open = prepare_df_for_display(new_df_view_open)
960
  new_df_display_complete_open = prepare_df_for_display(new_df_view_complete_open)
961
 
962
+ # Create new scatter plots for all combinations (with current mark_by)
963
+ new_cost_scatter_complete = create_cost_scatter_plot(new_df_view_complete, mark_by) if len(new_df_display_complete) > 0 else go.Figure()
964
+ new_cost_scatter_all = create_cost_scatter_plot(new_df_view_full, mark_by)
965
+ new_cost_scatter_open = create_cost_scatter_plot(new_df_view_open, mark_by) if len(new_df_view_open) > 0 else go.Figure()
966
+ 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()
967
 
968
+ new_runtime_scatter_complete = create_runtime_scatter_plot(new_df_view_complete, mark_by) if len(new_df_display_complete) > 0 else go.Figure()
969
+ new_runtime_scatter_all = create_runtime_scatter_plot(new_df_view_full, mark_by)
970
+ new_runtime_scatter_open = create_runtime_scatter_plot(new_df_view_open, mark_by) if len(new_df_view_open) > 0 else go.Figure()
971
+ 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()
972
 
973
  # Return the appropriate data based on checkbox states
974
  if show_open_only:
 
1003
  if show_open_only_checkbox is not None:
1004
  timer_inputs.append(show_open_only_checkbox)
1005
  timer_inputs.append(mark_by_dropdown) # Always include mark_by
 
1006
  refresh_timer.tick(
1007
  fn=check_and_refresh_data,
1008
  inputs=timer_inputs,
 
1010
  )
1011
  else:
1012
  # If no incomplete checkbox, always show all data (but still filter by open if needed)
1013
+ def check_and_refresh_all(show_open_only=False, mark_by=MARK_BY_DEFAULT):
1014
  current_version = get_data_version()
1015
  if current_version > initial_data_version:
1016
  print(f"[REFRESH] Data version changed, reloading...")
 
1023
  new_df_view_full = new_df_view_full[new_df_view_full['Openness'].str.lower() == 'open'].copy()
1024
 
1025
  new_df_display_all = prepare_df_for_display(new_df_view_full)
1026
+ new_cost_scatter_all = create_cost_scatter_plot(new_df_view_full, mark_by)
1027
+ new_runtime_scatter_all = create_runtime_scatter_plot(new_df_view_full, mark_by)
1028
  return new_df_display_all, new_cost_scatter_all, new_runtime_scatter_all
1029
 
1030
  if show_open_only:
 
1034
  if show_open_only_checkbox is not None:
1035
  refresh_timer.tick(
1036
  fn=check_and_refresh_all,
1037
+ inputs=[show_open_only_checkbox, mark_by_dropdown],
1038
  outputs=[dataframe_component, cost_plot_component, runtime_plot_component]
1039
  )
1040
  else:
1041
+ def check_and_refresh_simple(mark_by=MARK_BY_DEFAULT):
1042
+ return check_and_refresh_all(False, mark_by)
1043
  refresh_timer.tick(
1044
  fn=check_and_refresh_simple,
1045
+ inputs=[mark_by_dropdown],
1046
  outputs=[dataframe_component, cost_plot_component, runtime_plot_component]
1047
  )
1048