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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -57
app.py CHANGED
@@ -63,38 +63,6 @@ leaderboard_df = original_df.copy()
63
  ) = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
64
 
65
  # Searching and filtering
66
- # def update_table(
67
- # hidden_df: pd.DataFrame,
68
- # columns: list,
69
- # type_query: list,
70
- # precision_query: str,
71
- # size_query: list,
72
- # add_special_tokens_query: list,
73
- # num_few_shots_query: list,
74
- # show_deleted: bool,
75
- # show_merges: bool,
76
- # show_flagged: bool,
77
- # query: str,
78
- # ):
79
- # print(f"Update table called with: type_query={type_query}, precision_query={precision_query}, size_query={size_query}")
80
- # print(f"hidden_df shape before filtering: {hidden_df.shape}")
81
-
82
- # filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, add_special_tokens_query, num_few_shots_query, show_deleted, show_merges, show_flagged)
83
- # print(f"filtered_df shape after filter_models: {filtered_df.shape}")
84
-
85
- # filtered_df = filter_queries(query, filtered_df)
86
- # print(f"filtered_df shape after filter_queries: {filtered_df.shape}")
87
-
88
- # print(f"Filter applied: query={query}, columns={columns}, type_query={type_query}, precision_query={precision_query}")
89
- # print("Filtered dataframe head:")
90
- # print(filtered_df.head())
91
-
92
- # df = select_columns(filtered_df, columns)
93
- # print(f"Final df shape: {df.shape}")
94
- # print("Final dataframe head:")
95
- # print(df.head())
96
- # return df
97
-
98
  def update_table(
99
  hidden_df: pd.DataFrame,
100
  columns: list,
@@ -108,9 +76,23 @@ def update_table(
108
  show_flagged: bool,
109
  query: str,
110
  ):
 
 
 
111
  filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, add_special_tokens_query, num_few_shots_query, show_deleted, show_merges, show_flagged)
 
 
112
  filtered_df = filter_queries(query, filtered_df)
 
 
 
 
 
 
113
  df = select_columns(filtered_df, columns)
 
 
 
114
  return df
115
 
116
 
@@ -123,26 +105,16 @@ def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
123
  return df[(df[AutoEvalColumn.dummy.name].str.contains(query, case=False))]
124
 
125
 
126
- # def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
127
- # always_here_cols = [
128
- # AutoEvalColumn.model_type_symbol.name,
129
- # AutoEvalColumn.model.name,
130
- # ]
131
- # # We use COLS to maintain sorting
132
- # filtered_df = df[
133
- # always_here_cols + [c for c in COLS if c in df.columns and c in columns]# + [AutoEvalColumn.dummy.name]
134
- # ]
135
- # return filtered_df
136
-
137
  def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
138
  always_here_cols = [
139
  AutoEvalColumn.model_type_symbol.name,
140
  AutoEvalColumn.model.name,
141
  ]
142
-
143
- selected_cols = always_here_cols + [c for c in columns if c in df.columns]
144
- return df[selected_cols]
145
-
 
146
 
147
  def filter_queries(query: str, filtered_df: pd.DataFrame):
148
  """Added by Abishek"""
@@ -291,18 +263,10 @@ with demo:
291
  initial_columns = [c.name for c in fields(AutoEvalColumn) if c.never_hidden or c.displayed_by_default]
292
  leaderboard_df_filtered = select_columns(leaderboard_df_filtered, initial_columns)
293
 
294
- # leaderboard_table = gr.components.Dataframe(
295
- # value=leaderboard_df_filtered,
296
- # headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
297
- # datatype=TYPES,
298
- # elem_id="leaderboard-table",
299
- # interactive=False,
300
- # visible=True,
301
- # )
302
  leaderboard_table = gr.components.Dataframe(
303
- value=select_columns(leaderboard_df_filtered, shown_columns.value),
304
  headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
305
- datatype={col: TYPES[COLS.index(col)] if col in COLS else "str" for col in shown_columns.value},
306
  elem_id="leaderboard-table",
307
  interactive=False,
308
  visible=True,
 
63
  ) = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
64
 
65
  # Searching and filtering
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  def update_table(
67
  hidden_df: pd.DataFrame,
68
  columns: list,
 
76
  show_flagged: bool,
77
  query: str,
78
  ):
79
+ print(f"Update table called with: type_query={type_query}, precision_query={precision_query}, size_query={size_query}")
80
+ print(f"hidden_df shape before filtering: {hidden_df.shape}")
81
+
82
  filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, add_special_tokens_query, num_few_shots_query, show_deleted, show_merges, show_flagged)
83
+ print(f"filtered_df shape after filter_models: {filtered_df.shape}")
84
+
85
  filtered_df = filter_queries(query, filtered_df)
86
+ print(f"filtered_df shape after filter_queries: {filtered_df.shape}")
87
+
88
+ print(f"Filter applied: query={query}, columns={columns}, type_query={type_query}, precision_query={precision_query}")
89
+ print("Filtered dataframe head:")
90
+ print(filtered_df.head())
91
+
92
  df = select_columns(filtered_df, columns)
93
+ print(f"Final df shape: {df.shape}")
94
+ print("Final dataframe head:")
95
+ print(df.head())
96
  return df
97
 
98
 
 
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
  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,