Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -79,17 +79,28 @@ def update_table(
|
|
79 |
size_query: list,
|
80 |
show_deleted: bool,
|
81 |
query: str,
|
82 |
-
request: gr.Request,
|
83 |
):
|
84 |
-
if not query: # if None or "", check if query parameter is set
|
85 |
-
query_from_params = request.query_params.get("query")
|
86 |
-
if query_from_params is not None:
|
87 |
-
query = query_from_params
|
88 |
filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, show_deleted)
|
89 |
filtered_df = filter_queries(query, filtered_df)
|
90 |
df = select_columns(filtered_df, columns)
|
91 |
return df
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
|
95 |
return df[(df[AutoEvalColumn.dummy.name].str.contains(query, case=False))]
|
@@ -241,6 +252,18 @@ with demo:
|
|
241 |
],
|
242 |
leaderboard_table,
|
243 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
for selector in [shown_columns, filter_columns_type, filter_columns_precision, filter_columns_size, deleted_models_visibility]:
|
245 |
selector.change(
|
246 |
update_table,
|
|
|
79 |
size_query: list,
|
80 |
show_deleted: bool,
|
81 |
query: str,
|
|
|
82 |
):
|
|
|
|
|
|
|
|
|
83 |
filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, show_deleted)
|
84 |
filtered_df = filter_queries(query, filtered_df)
|
85 |
df = select_columns(filtered_df, columns)
|
86 |
return df
|
87 |
|
88 |
+
def update_table_from_query( # triggered only once at startup => read query parameter if it exists
|
89 |
+
hidden_df: pd.DataFrame,
|
90 |
+
columns: list,
|
91 |
+
type_query: list,
|
92 |
+
precision_query: str,
|
93 |
+
size_query: list,
|
94 |
+
show_deleted: bool,
|
95 |
+
request: gr.Request,
|
96 |
+
):
|
97 |
+
query_from_params = request.query_params.get("query") or ""
|
98 |
+
return (
|
99 |
+
# Update search bar
|
100 |
+
query_from_params,
|
101 |
+
# Update dataframe
|
102 |
+
update_table(hidden_df, columns, type_query, precision_query, size_query, show_deleted, query_from_params),
|
103 |
+
)
|
104 |
|
105 |
def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
|
106 |
return df[(df[AutoEvalColumn.dummy.name].str.contains(query, case=False))]
|
|
|
252 |
],
|
253 |
leaderboard_table,
|
254 |
)
|
255 |
+
demo.load(
|
256 |
+
fn=update_table_from_query,
|
257 |
+
inputs=[
|
258 |
+
hidden_leaderboard_table_for_search,
|
259 |
+
shown_columns,
|
260 |
+
filter_columns_type,
|
261 |
+
filter_columns_precision,
|
262 |
+
filter_columns_size,
|
263 |
+
deleted_models_visibility,
|
264 |
+
],
|
265 |
+
outputs=[search_bar, leaderboard_table],
|
266 |
+
)
|
267 |
for selector in [shown_columns, filter_columns_type, filter_columns_precision, filter_columns_size, deleted_models_visibility]:
|
268 |
selector.change(
|
269 |
update_table,
|