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

Refactor init_leaderboard function to use default textbox and checkbox values

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -71,12 +71,15 @@ except Exception:
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):
@@ -85,8 +88,8 @@ def init_leaderboard(dataframes):
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
 
@@ -99,7 +102,7 @@ def init_leaderboard(dataframes):
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)
 
71
 
72
  LEADERBOARD_DF = get_leaderboard_df(RESULTS_REPO)
73
 
74
+ def GET_DEFAULT_TEXTBOX():
75
+ return gr.Textbox("", placeholder="πŸ” Search Models... [press enter]", label="Filter Models by Name")
76
+
77
+ def GET_DEFAULT_CHECKBOX():
78
+ return gr.CheckboxGroup(
79
+ choices=[c.name for c in fields(AutoEvalColumn) if not c.hidden],
80
+ label="Select Columns to Display",
81
+ value=[c.name for c in fields(AutoEvalColumn) if c.displayed_by_default],
82
+ )
83
 
84
 
85
  def init_leaderboard(dataframes):
 
88
 
89
  with gr.Row():
90
  selected_subset = gr.Dropdown(choices=subsets, label="Select Dataset Subset", value=subsets[-1])
91
+ research_textbox = GET_DEFAULT_TEXTBOX()
92
+ selected_columns = GET_DEFAULT_CHECKBOX()
93
 
94
  data = dataframes[subsets[-1]]
95
 
 
102
  LEADERBOARD_DF = get_leaderboard_df(RESULTS_REPO)
103
  default_columns = [c.name for c in fields(AutoEvalColumn) if c.displayed_by_default]
104
 
105
+ return update_data(subset, None, default_columns), GET_DEFAULT_TEXTBOX(), GET_DEFAULT_CHECKBOX()
106
 
107
  def update_data(subset, search_term, selected_columns):
108
  print("Subset:", subset)