Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
refactor: refactor the listeners
Browse files
app.py
CHANGED
@@ -14,9 +14,9 @@ from src.display.css_html_js import custom_css
|
|
14 |
from src.display.utils import COL_NAME_IS_ANONYMOUS, COL_NAME_REVISION, COL_NAME_TIMESTAMP
|
15 |
from src.envs import API, EVAL_RESULTS_PATH, REPO_ID, RESULTS_REPO, TOKEN
|
16 |
from src.read_evals import get_raw_eval_results, get_leaderboard_df
|
17 |
-
from src.utils import
|
18 |
from src.display.gradio_formatting import get_version_dropdown, get_search_bar, get_reranking_dropdown, get_noreranker_button, get_metric_dropdown, get_domain_dropdown, get_language_dropdown, get_anonymous_checkbox, get_revision_and_ts_checkbox, get_leaderboard_table
|
19 |
-
|
20 |
|
21 |
def restart_space():
|
22 |
API.restart_space(repo_id=REPO_ID)
|
@@ -69,7 +69,6 @@ def update_metric_qa(
|
|
69 |
):
|
70 |
return update_metric(raw_data, 'qa', metric, domains, langs, reranking_model, query, show_anonymous, show_revision_and_timestamp)
|
71 |
|
72 |
-
|
73 |
def update_metric_long_doc(
|
74 |
metric: str,
|
75 |
domains: list,
|
@@ -121,39 +120,19 @@ with demo:
|
|
121 |
# Dummy leaderboard for handling the case when the user uses backspace key
|
122 |
hidden_leaderboard_table_for_search = get_leaderboard_table(original_df_qa, types_qa, visible=False)
|
123 |
|
124 |
-
|
125 |
-
|
126 |
-
update_table,
|
127 |
-
[
|
128 |
-
hidden_leaderboard_table_for_search,
|
129 |
-
selected_domains,
|
130 |
-
selected_langs,
|
131 |
-
selected_rerankings,
|
132 |
-
search_bar,
|
133 |
-
show_anonymous,
|
134 |
-
],
|
135 |
leaderboard_table,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
)
|
137 |
|
138 |
-
# Set column-wise listener
|
139 |
-
for selector in [
|
140 |
-
selected_domains, selected_langs, show_anonymous, show_revision_and_timestamp, selected_rerankings
|
141 |
-
]:
|
142 |
-
selector.change(
|
143 |
-
update_table,
|
144 |
-
[
|
145 |
-
hidden_leaderboard_table_for_search,
|
146 |
-
selected_domains,
|
147 |
-
selected_langs,
|
148 |
-
selected_rerankings,
|
149 |
-
search_bar,
|
150 |
-
show_anonymous,
|
151 |
-
show_revision_and_timestamp
|
152 |
-
],
|
153 |
-
leaderboard_table,
|
154 |
-
queue=True,
|
155 |
-
)
|
156 |
-
|
157 |
# set metric listener
|
158 |
selected_metric.change(
|
159 |
update_metric_qa,
|
@@ -169,11 +148,6 @@ with demo:
|
|
169 |
queue=True
|
170 |
)
|
171 |
|
172 |
-
select_noreranker_only_btn.click(
|
173 |
-
clear_reranking_selections,
|
174 |
-
outputs=selected_rerankings
|
175 |
-
)
|
176 |
-
|
177 |
with gr.TabItem("Long Doc", elem_id="long-doc-benchmark-tab-table", id=1):
|
178 |
with gr.Row():
|
179 |
with gr.Column():
|
@@ -203,7 +177,7 @@ with demo:
|
|
203 |
with gr.Row():
|
204 |
show_revision_and_timestamp = get_revision_and_ts_checkbox()
|
205 |
|
206 |
-
|
207 |
leaderboard_df_long_doc, types_long_doc
|
208 |
)
|
209 |
|
@@ -212,40 +186,19 @@ with demo:
|
|
212 |
original_df_long_doc, types_long_doc, visible=False
|
213 |
)
|
214 |
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
],
|
227 |
-
leaderboard_table_long_doc,
|
228 |
)
|
229 |
|
230 |
-
# Set column-wise listener
|
231 |
-
for selector in [
|
232 |
-
selected_domains, selected_langs, show_anonymous, show_revision_and_timestamp, selected_rerankings
|
233 |
-
]:
|
234 |
-
selector.change(
|
235 |
-
update_table_long_doc,
|
236 |
-
[
|
237 |
-
hidden_leaderboard_table_for_search,
|
238 |
-
selected_domains,
|
239 |
-
selected_langs,
|
240 |
-
selected_rerankings,
|
241 |
-
search_bar,
|
242 |
-
show_anonymous,
|
243 |
-
show_revision_and_timestamp
|
244 |
-
],
|
245 |
-
leaderboard_table_long_doc,
|
246 |
-
queue=True,
|
247 |
-
)
|
248 |
-
|
249 |
# set metric listener
|
250 |
selected_metric.change(
|
251 |
update_metric_long_doc,
|
@@ -258,15 +211,10 @@ with demo:
|
|
258 |
show_anonymous,
|
259 |
show_revision_and_timestamp
|
260 |
],
|
261 |
-
|
262 |
queue=True
|
263 |
)
|
264 |
|
265 |
-
select_noreranker_only_btn.click(
|
266 |
-
clear_reranking_selections,
|
267 |
-
outputs=selected_rerankings
|
268 |
-
)
|
269 |
-
|
270 |
with gr.TabItem("🚀Submit here!", elem_id="submit-tab-table", id=2):
|
271 |
with gr.Column():
|
272 |
with gr.Row():
|
|
|
14 |
from src.display.utils import COL_NAME_IS_ANONYMOUS, COL_NAME_REVISION, COL_NAME_TIMESTAMP
|
15 |
from src.envs import API, EVAL_RESULTS_PATH, REPO_ID, RESULTS_REPO, TOKEN
|
16 |
from src.read_evals import get_raw_eval_results, get_leaderboard_df
|
17 |
+
from src.utils import update_metric, upload_file, get_default_cols, submit_results
|
18 |
from src.display.gradio_formatting import get_version_dropdown, get_search_bar, get_reranking_dropdown, get_noreranker_button, get_metric_dropdown, get_domain_dropdown, get_language_dropdown, get_anonymous_checkbox, get_revision_and_ts_checkbox, get_leaderboard_table
|
19 |
+
from src.display.gradio_listener import set_listeners
|
20 |
|
21 |
def restart_space():
|
22 |
API.restart_space(repo_id=REPO_ID)
|
|
|
69 |
):
|
70 |
return update_metric(raw_data, 'qa', metric, domains, langs, reranking_model, query, show_anonymous, show_revision_and_timestamp)
|
71 |
|
|
|
72 |
def update_metric_long_doc(
|
73 |
metric: str,
|
74 |
domains: list,
|
|
|
120 |
# Dummy leaderboard for handling the case when the user uses backspace key
|
121 |
hidden_leaderboard_table_for_search = get_leaderboard_table(original_df_qa, types_qa, visible=False)
|
122 |
|
123 |
+
set_listeners(
|
124 |
+
"qa",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
leaderboard_table,
|
126 |
+
hidden_leaderboard_table_for_search,
|
127 |
+
search_bar,
|
128 |
+
select_noreranker_only_btn,
|
129 |
+
selected_domains,
|
130 |
+
selected_langs,
|
131 |
+
selected_rerankings,
|
132 |
+
show_anonymous,
|
133 |
+
show_revision_and_timestamp,
|
134 |
)
|
135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
# set metric listener
|
137 |
selected_metric.change(
|
138 |
update_metric_qa,
|
|
|
148 |
queue=True
|
149 |
)
|
150 |
|
|
|
|
|
|
|
|
|
|
|
151 |
with gr.TabItem("Long Doc", elem_id="long-doc-benchmark-tab-table", id=1):
|
152 |
with gr.Row():
|
153 |
with gr.Column():
|
|
|
177 |
with gr.Row():
|
178 |
show_revision_and_timestamp = get_revision_and_ts_checkbox()
|
179 |
|
180 |
+
leaderboard_table = get_leaderboard_table(
|
181 |
leaderboard_df_long_doc, types_long_doc
|
182 |
)
|
183 |
|
|
|
186 |
original_df_long_doc, types_long_doc, visible=False
|
187 |
)
|
188 |
|
189 |
+
set_listeners(
|
190 |
+
"long-doc",
|
191 |
+
leaderboard_table,
|
192 |
+
hidden_leaderboard_table_for_search,
|
193 |
+
search_bar,
|
194 |
+
select_noreranker_only_btn,
|
195 |
+
selected_domains,
|
196 |
+
selected_langs,
|
197 |
+
selected_rerankings,
|
198 |
+
show_anonymous,
|
199 |
+
show_revision_and_timestamp,
|
|
|
|
|
200 |
)
|
201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
# set metric listener
|
203 |
selected_metric.change(
|
204 |
update_metric_long_doc,
|
|
|
211 |
show_anonymous,
|
212 |
show_revision_and_timestamp
|
213 |
],
|
214 |
+
leaderboard_table,
|
215 |
queue=True
|
216 |
)
|
217 |
|
|
|
|
|
|
|
|
|
|
|
218 |
with gr.TabItem("🚀Submit here!", elem_id="submit-tab-table", id=2):
|
219 |
with gr.Column():
|
220 |
with gr.Row():
|