sh1gechan commited on
Commit
e36d99d
·
verified ·
1 Parent(s): 638d653

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -66
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,
@@ -125,13 +93,8 @@ def update_table(
125
  print(f"Final df shape: {df.shape}")
126
  print("Final dataframe head:")
127
  print(df.head())
128
- column_dtypes = {col: TYPES[COLS.index(col)] if col in COLS else "str" for col in df.columns}
129
-
130
- return gr.Dataframe.update(
131
- value=df.to_dict(orient="records"),
132
- headers=list(df.columns),
133
- datatype=column_dtypes
134
- )
135
 
136
  def load_query(request: gr.Request): # triggered only once at startup => read query parameter if it exists
137
  query = request.query_params.get("query") or ""
@@ -142,25 +105,16 @@ def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
142
  return df[(df[AutoEvalColumn.dummy.name].str.contains(query, case=False))]
143
 
144
 
145
- # def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
146
- # always_here_cols = [
147
- # AutoEvalColumn.model_type_symbol.name,
148
- # AutoEvalColumn.model.name,
149
- # ]
150
- # # We use COLS to maintain sorting
151
- # filtered_df = df[
152
- # always_here_cols + [c for c in COLS if c in df.columns and c in columns]# + [AutoEvalColumn.dummy.name]
153
- # ]
154
- # return filtered_df
155
-
156
  def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
157
  always_here_cols = [
158
  AutoEvalColumn.model_type_symbol.name,
159
  AutoEvalColumn.model.name,
160
  ]
161
-
162
- selected_cols = list(dict.fromkeys(always_here_cols + [c for c in columns if c in df.columns]))
163
- return df[selected_cols]
 
 
164
 
165
 
166
  def filter_queries(query: str, filtered_df: pd.DataFrame):
@@ -309,20 +263,11 @@ with demo:
309
  leaderboard_df_filtered = filter_models(leaderboard_df, [t.to_str(" : ") for t in ModelType], list(NUMERIC_INTERVALS.keys()), [i.value.name for i in Precision], [i.value.name for i in AddSpecialTokens], [i.value.name for i in NumFewShots], False, False, False)
310
  initial_columns = [c.name for c in fields(AutoEvalColumn) if c.never_hidden or c.displayed_by_default]
311
  leaderboard_df_filtered = select_columns(leaderboard_df_filtered, initial_columns)
312
- column_dtypes = {col: TYPES[COLS.index(col)] if col in COLS else "str" for col in leaderboard_df_filtered.columns}
313
-
314
- # leaderboard_table = gr.components.Dataframe(
315
- # value=leaderboard_df_filtered,
316
- # headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
317
- # datatype=TYPES,
318
- # elem_id="leaderboard-table",
319
- # interactive=False,
320
- # visible=True,
321
- # )
322
  leaderboard_table = gr.components.Dataframe(
323
- value=leaderboard_df_filtered.to_dict(orient="records"),
324
- headers=list(leaderboard_df_filtered.columns),
325
- datatype=column_dtypes,
326
  elem_id="leaderboard-table",
327
  interactive=False,
328
  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,
 
93
  print(f"Final df shape: {df.shape}")
94
  print("Final dataframe head:")
95
  print(df.head())
96
+ return df
97
+
 
 
 
 
 
98
 
99
  def load_query(request: gr.Request): # triggered only once at startup => read query parameter if it exists
100
  query = request.query_params.get("query") or ""
 
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
 
120
  def filter_queries(query: str, filtered_df: pd.DataFrame):
 
263
  leaderboard_df_filtered = filter_models(leaderboard_df, [t.to_str(" : ") for t in ModelType], list(NUMERIC_INTERVALS.keys()), [i.value.name for i in Precision], [i.value.name for i in AddSpecialTokens], [i.value.name for i in NumFewShots], False, False, False)
264
  initial_columns = [c.name for c in fields(AutoEvalColumn) if c.never_hidden or c.displayed_by_default]
265
  leaderboard_df_filtered = select_columns(leaderboard_df_filtered, initial_columns)
266
+
 
 
 
 
 
 
 
 
 
267
  leaderboard_table = gr.components.Dataframe(
268
+ value=leaderboard_df_filtered,
269
+ headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
270
+ datatype=TYPES,
271
  elem_id="leaderboard-table",
272
  interactive=False,
273
  visible=True,