pufanyi commited on
Commit
fc52117
β€’
1 Parent(s): ed4dea2

Refactor init_leaderboard function to use default textbox and checkbox values

Browse files
Files changed (1) hide show
  1. app.py +11 -13
app.py CHANGED
@@ -71,18 +71,22 @@ except Exception:
71
 
72
  LEADERBOARD_DF = get_leaderboard_df(RESULTS_REPO)
73
 
 
 
 
 
 
 
 
74
 
75
  def init_leaderboard(dataframes):
76
  subsets = list(dataframes.keys())
77
 
 
78
  with gr.Row():
79
  selected_subset = gr.Dropdown(choices=subsets, label="Select Dataset Subset", value=subsets[-1])
80
- research_textbox = gr.Textbox(placeholder="πŸ” Search Models... [press enter]", label="Filter Models by Name")
81
- selected_columns = gr.CheckboxGroup(
82
- choices=[c.name for c in fields(AutoEvalColumn) if not c.hidden],
83
- label="Select Columns to Display",
84
- value=[c.name for c in fields(AutoEvalColumn) if c.displayed_by_default],
85
- )
86
 
87
  data = dataframes[subsets[-1]]
88
 
@@ -94,14 +98,8 @@ def init_leaderboard(dataframes):
94
  global LEADERBOARD_DF
95
  LEADERBOARD_DF = get_leaderboard_df(RESULTS_REPO)
96
  default_columns = [c.name for c in fields(AutoEvalColumn) if c.displayed_by_default]
97
- default_textbox = gr.Textbox("", placeholder="πŸ” Search Models... [press enter]", label="Filter Models by Name")
98
- default_checkbox = gr.CheckboxGroup(
99
- choices=[c.name for c in fields(AutoEvalColumn) if not c.hidden],
100
- label="Select Columns to Display",
101
- value=[c.name for c in fields(AutoEvalColumn) if c.displayed_by_default],
102
- )
103
 
104
- return update_data(subset, None, default_columns), default_textbox, default_checkbox
105
 
106
  def update_data(subset, search_term, selected_columns):
107
  print("Subset:", subset)
 
71
 
72
  LEADERBOARD_DF = get_leaderboard_df(RESULTS_REPO)
73
 
74
+ DEFAULT_TEXTBOX = gr.Textbox("", placeholder="πŸ” Search Models... [press enter]", label="Filter Models by Name")
75
+ DEFAULT_CHECKBOX = gr.CheckboxGroup(
76
+ choices=[c.name for c in fields(AutoEvalColumn) if not c.hidden],
77
+ label="Select Columns to Display",
78
+ value=[c.name for c in fields(AutoEvalColumn) if c.displayed_by_default],
79
+ )
80
+
81
 
82
  def init_leaderboard(dataframes):
83
  subsets = list(dataframes.keys())
84
 
85
+
86
  with gr.Row():
87
  selected_subset = gr.Dropdown(choices=subsets, label="Select Dataset Subset", value=subsets[-1])
88
+ research_textbox = DEFAULT_TEXTBOX
89
+ selected_columns = DEFAULT_CHECKBOX
 
 
 
 
90
 
91
  data = dataframes[subsets[-1]]
92
 
 
98
  global LEADERBOARD_DF
99
  LEADERBOARD_DF = get_leaderboard_df(RESULTS_REPO)
100
  default_columns = [c.name for c in fields(AutoEvalColumn) if c.displayed_by_default]
 
 
 
 
 
 
101
 
102
+ return update_data(subset, None, default_columns), DEFAULT_TEXTBOX, DEFAULT_CHECKBOX
103
 
104
  def update_data(subset, search_term, selected_columns):
105
  print("Subset:", subset)