sh1gechan commited on
Commit
2c38c9a
1 Parent(s): 4a39b37

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -7
app.py CHANGED
@@ -105,16 +105,24 @@ def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
105
  return df[(df[AutoEvalColumn.dummy.name].str.contains(query, case=False))]
106
 
107
 
 
 
 
 
 
 
 
 
 
 
 
108
  def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
109
  always_here_cols = [
110
  AutoEvalColumn.model_type_symbol.name,
111
  AutoEvalColumn.model.name,
112
  ]
113
- # We use COLS to maintain sorting
114
- filtered_df = df[
115
- always_here_cols + [c for c in COLS if c in df.columns and c in columns]# + [AutoEvalColumn.dummy.name]
116
- ]
117
- return filtered_df
118
 
119
  def filter_queries(query: str, filtered_df: pd.DataFrame):
120
  """Added by Abishek"""
@@ -263,10 +271,18 @@ with demo:
263
  initial_columns = [c.name for c in fields(AutoEvalColumn) if c.never_hidden or c.displayed_by_default]
264
  leaderboard_df_filtered = select_columns(leaderboard_df_filtered, initial_columns)
265
 
 
 
 
 
 
 
 
 
266
  leaderboard_table = gr.components.Dataframe(
267
  value=leaderboard_df_filtered,
268
- headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
269
- datatype=TYPES,
270
  elem_id="leaderboard-table",
271
  interactive=False,
272
  visible=True,
 
105
  return df[(df[AutoEvalColumn.dummy.name].str.contains(query, case=False))]
106
 
107
 
108
+ # def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
109
+ # always_here_cols = [
110
+ # AutoEvalColumn.model_type_symbol.name,
111
+ # AutoEvalColumn.model.name,
112
+ # ]
113
+ # # We use COLS to maintain sorting
114
+ # filtered_df = df[
115
+ # always_here_cols + [c for c in COLS if c in df.columns and c in columns]# + [AutoEvalColumn.dummy.name]
116
+ # ]
117
+ # return filtered_df
118
+
119
  def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
120
  always_here_cols = [
121
  AutoEvalColumn.model_type_symbol.name,
122
  AutoEvalColumn.model.name,
123
  ]
124
+ selected_cols = list(dict.fromkeys(always_here_cols + [c for c in COLS if c in df.columns and c in columns]))
125
+ return df[selected_cols]
 
 
 
126
 
127
  def filter_queries(query: str, filtered_df: pd.DataFrame):
128
  """Added by Abishek"""
 
271
  initial_columns = [c.name for c in fields(AutoEvalColumn) if c.never_hidden or c.displayed_by_default]
272
  leaderboard_df_filtered = select_columns(leaderboard_df_filtered, initial_columns)
273
 
274
+ # leaderboard_table = gr.components.Dataframe(
275
+ # value=leaderboard_df_filtered,
276
+ # headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
277
+ # datatype=TYPES,
278
+ # elem_id="leaderboard-table",
279
+ # interactive=False,
280
+ # visible=True,
281
+ # )
282
  leaderboard_table = gr.components.Dataframe(
283
  value=leaderboard_df_filtered,
284
+ headers=list(leaderboard_df_filtered.columns),
285
+ datatype={col: "markdown" if col == "Model" else "str" for col in leaderboard_df_filtered.columns},
286
  elem_id="leaderboard-table",
287
  interactive=False,
288
  visible=True,