Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
•
8b63c4c
1
Parent(s):
c4d8606
Deeplink to autoselect a model when opening the leaderboard (#462)
Browse files- [WIP] (091d1c2eb535d89bcdfb9be857d8f16e04708617)
- Update app.py (06e2ae973ab3944fb61c3115f6c5ddb36217a04f)
- Update app.py (2573a659d4410bba25b41dfc66ea2b487ab3dd19)
- Update app.py (7b45f9d7ead2a12052ce3656eedc1b3cb123c887)
- Update app.py (a7a14155badc16ed55045fa51c7aa687b600a8a7)
Co-authored-by: Lucain Pouget <[email protected]>
app.py
CHANGED
@@ -86,6 +86,11 @@ def update_table(
|
|
86 |
return df
|
87 |
|
88 |
|
|
|
|
|
|
|
|
|
|
|
89 |
def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
|
90 |
return df[(df[AutoEvalColumn.dummy.name].str.contains(query, case=False))]
|
91 |
|
@@ -236,6 +241,25 @@ with demo:
|
|
236 |
],
|
237 |
leaderboard_table,
|
238 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
for selector in [shown_columns, filter_columns_type, filter_columns_precision, filter_columns_size, deleted_models_visibility]:
|
240 |
selector.change(
|
241 |
update_table,
|
|
|
86 |
return df
|
87 |
|
88 |
|
89 |
+
def load_query(request: gr.Request): # triggered only once at startup => read query parameter if it exists
|
90 |
+
query = request.query_params.get("query") or ""
|
91 |
+
return query, query # return one for the "search_bar", one for a hidden component that triggers a reload only if value has changed
|
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))]
|
96 |
|
|
|
241 |
],
|
242 |
leaderboard_table,
|
243 |
)
|
244 |
+
|
245 |
+
# Define a hidden component that will trigger a reload only if a query parameter has be set
|
246 |
+
hidden_search_bar = gr.Textbox(value="", visible=False)
|
247 |
+
hidden_search_bar.change(
|
248 |
+
update_table,
|
249 |
+
[
|
250 |
+
hidden_leaderboard_table_for_search,
|
251 |
+
shown_columns,
|
252 |
+
filter_columns_type,
|
253 |
+
filter_columns_precision,
|
254 |
+
filter_columns_size,
|
255 |
+
deleted_models_visibility,
|
256 |
+
search_bar,
|
257 |
+
],
|
258 |
+
leaderboard_table,
|
259 |
+
)
|
260 |
+
# Check query parameter once at startup and update search bar + hidden component
|
261 |
+
demo.load(load_query, inputs=[], outputs=[search_bar, hidden_search_bar])
|
262 |
+
|
263 |
for selector in [shown_columns, filter_columns_type, filter_columns_precision, filter_columns_size, deleted_models_visibility]:
|
264 |
selector.change(
|
265 |
update_table,
|