pufanyi commited on
Commit
f71c197
·
1 Parent(s): 4f5021e

Refactor GET_DEFAULT_CHECKBOX function in app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -79,11 +79,13 @@ def GET_DEFAULT_TEXTBOX():
79
 
80
 
81
  def GET_DEFAULT_CHECKBOX():
82
- print("Choices:", [c.name for c in fields(AutoEvalColumn) if not c.hidden])
 
 
83
  return gr.CheckboxGroup(
84
- choices=[c.name for c in fields(AutoEvalColumn) if not c.hidden],
85
  label="Select Columns to Display",
86
- value=[c.name for c in fields(AutoEvalColumn) if c.displayed_by_default],
87
  )
88
 
89
 
@@ -98,13 +100,15 @@ def init_leaderboard(dataframes):
98
  data = dataframes[NEWEST_VERSION]
99
 
100
  with gr.Row():
101
- datatype = [c.type for c in fields(AutoEvalColumn)]
102
- df = gr.Dataframe(data, datatype=datatype, type="pandas")
103
 
104
  def refresh(subset):
105
  global LEADERBOARD_DF
106
  LEADERBOARD_DF = get_leaderboard_df(RESULTS_REPO)
107
- default_columns = [c.name for c in fields(AutoEvalColumn) if c.displayed_by_default]
 
 
108
 
109
  return update_data(subset, None, default_columns), GET_DEFAULT_TEXTBOX(), GET_DEFAULT_CHECKBOX()
110
 
@@ -116,12 +120,12 @@ def init_leaderboard(dataframes):
116
  if search_term:
117
  filtered_data = filtered_data[dataframes[subset]["Model Name"].str.contains(search_term, case=False)]
118
  filtered_data.sort_values(by="Total", ascending=False, inplace=True)
119
- selected_columns = [c.name for c in fields(AutoEvalColumn) if c.name in selected_columns]
120
  selected_data = filtered_data[selected_columns]
121
  return gr.DataFrame(
122
  selected_data,
123
  type="pandas",
124
- datatype=[c.type for c in fields(AutoEvalColumn) if c.name in selected_columns],
125
  )
126
 
127
  with gr.Row():
 
79
 
80
 
81
  def GET_DEFAULT_CHECKBOX():
82
+ choices = list(LEADERBOARD_DF.columns)
83
+ choices.remove("Model Name")
84
+ # print("Choices:", [c.name for c in fields(AutoEvalColumn) if not c.hidden])
85
  return gr.CheckboxGroup(
86
+ choices=choices,
87
  label="Select Columns to Display",
88
+ value=choices,
89
  )
90
 
91
 
 
100
  data = dataframes[NEWEST_VERSION]
101
 
102
  with gr.Row():
103
+ # datatype =
104
+ df = gr.Dataframe(data, type="pandas")
105
 
106
  def refresh(subset):
107
  global LEADERBOARD_DF
108
  LEADERBOARD_DF = get_leaderboard_df(RESULTS_REPO)
109
+ # default_columns = [c.name for c in fields(AutoEvalColumn) if c.displayed_by_default]
110
+ default_columns = list(LEADERBOARD_DF.columns)
111
+ default_columns.remove("Model Name")
112
 
113
  return update_data(subset, None, default_columns), GET_DEFAULT_TEXTBOX(), GET_DEFAULT_CHECKBOX()
114
 
 
120
  if search_term:
121
  filtered_data = filtered_data[dataframes[subset]["Model Name"].str.contains(search_term, case=False)]
122
  filtered_data.sort_values(by="Total", ascending=False, inplace=True)
123
+ # selected_columns = [c.name for c in fields(AutoEvalColumn) if c.name in selected_columns]
124
  selected_data = filtered_data[selected_columns]
125
  return gr.DataFrame(
126
  selected_data,
127
  type="pandas",
128
+ # datatype=[c.type for c in fields(AutoEvalColumn) if c.name in selected_columns],
129
  )
130
 
131
  with gr.Row():