Spaces:
Running
Running
It is possible to download leaderboard Overall in CSV format
Browse files
app.py
CHANGED
@@ -321,6 +321,12 @@ def gradio_app():
|
|
321 |
elem_classes="leaderboard-table",
|
322 |
)
|
323 |
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
with gr.Row():
|
325 |
leaderboard_table_legend = gr.DataFrame(
|
326 |
value=None,
|
|
|
321 |
elem_classes="leaderboard-table",
|
322 |
)
|
323 |
|
324 |
+
with gr.Row():
|
325 |
+
leaderboard_table_csv = gr.DownloadButton(
|
326 |
+
label="Download leaderboard in CSV format",
|
327 |
+
value=leaderboard_server.get_leaderboard_csv(category=leaderboard_server.TASKS_CATEGORY_OVERALL),
|
328 |
+
)
|
329 |
+
|
330 |
with gr.Row():
|
331 |
leaderboard_table_legend = gr.DataFrame(
|
332 |
value=None,
|
server.py
CHANGED
@@ -157,6 +157,7 @@ class LeaderboardServer:
|
|
157 |
self.TASKS_CATEGORY_OVERALL = "Overall"
|
158 |
self.CATEGORY_TO_TASK_ABBREVIATION_TO_DETAILS = self._prepare_category_to_task_abbr_to_details()
|
159 |
self.MAX_LENGTH_OF_MODEL_TITLE = 28
|
|
|
160 |
|
161 |
self.var_lock = ReadWriteLock()
|
162 |
self.submission_ids = set()
|
@@ -167,6 +168,9 @@ class LeaderboardServer:
|
|
167 |
self.leaderboard_dataframes = {} # For each category
|
168 |
self.tournament_dataframes = {} # For each submission_id and category
|
169 |
|
|
|
|
|
|
|
170 |
self.results_dataset_local_snapshot_lock = ReadWriteLock()
|
171 |
self.results_dataset_local_snapshot = None
|
172 |
|
@@ -191,9 +195,11 @@ class LeaderboardServer:
|
|
191 |
with self.var_lock.rw:
|
192 |
self.tournament_results = tournament_results
|
193 |
|
|
|
|
|
194 |
leaderboard_dataframes = {
|
195 |
category: self._get_leaderboard(category=category)
|
196 |
-
for category in
|
197 |
}
|
198 |
|
199 |
with self.var_lock.ro:
|
@@ -202,7 +208,7 @@ class LeaderboardServer:
|
|
202 |
tournament_dataframes = {
|
203 |
submission_id: {
|
204 |
category: self._get_model_tournament_table(submission_id, category)
|
205 |
-
for category in
|
206 |
}
|
207 |
for submission_id in submission_ids
|
208 |
}
|
@@ -210,6 +216,27 @@ class LeaderboardServer:
|
|
210 |
with self.var_lock.rw:
|
211 |
self.leaderboard_dataframes = leaderboard_dataframes
|
212 |
self.tournament_dataframes = tournament_dataframes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
|
214 |
def load_tournament_results(self):
|
215 |
with self.results_dataset_local_snapshot_lock.ro:
|
@@ -409,6 +436,22 @@ class LeaderboardServer:
|
|
409 |
dataframe = dataframe.style.apply(self._model_tournament_table_highlight_true_and_false, axis=None)
|
410 |
return dataframe
|
411 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
412 |
def get_leaderboard(self, pre_submit=None, category=None):
|
413 |
if pre_submit == None:
|
414 |
category = category if category else self.TASKS_CATEGORY_OVERALL
|
|
|
157 |
self.TASKS_CATEGORY_OVERALL = "Overall"
|
158 |
self.CATEGORY_TO_TASK_ABBREVIATION_TO_DETAILS = self._prepare_category_to_task_abbr_to_details()
|
159 |
self.MAX_LENGTH_OF_MODEL_TITLE = 28
|
160 |
+
self.DIR_DATAFRAMES_CSV = "./dataframes_csv"
|
161 |
|
162 |
self.var_lock = ReadWriteLock()
|
163 |
self.submission_ids = set()
|
|
|
168 |
self.leaderboard_dataframes = {} # For each category
|
169 |
self.tournament_dataframes = {} # For each submission_id and category
|
170 |
|
171 |
+
self.leaderboard_dataframes_csv = {} # For each category
|
172 |
+
self.tournament_dataframes_csv = {} # For each submission_id and category
|
173 |
+
|
174 |
self.results_dataset_local_snapshot_lock = ReadWriteLock()
|
175 |
self.results_dataset_local_snapshot = None
|
176 |
|
|
|
195 |
with self.var_lock.rw:
|
196 |
self.tournament_results = tournament_results
|
197 |
|
198 |
+
categories = [self.TASKS_CATEGORY_OVERALL] + sorted(self.TASKS_CATEGORIES)
|
199 |
+
|
200 |
leaderboard_dataframes = {
|
201 |
category: self._get_leaderboard(category=category)
|
202 |
+
for category in categories
|
203 |
}
|
204 |
|
205 |
with self.var_lock.ro:
|
|
|
208 |
tournament_dataframes = {
|
209 |
submission_id: {
|
210 |
category: self._get_model_tournament_table(submission_id, category)
|
211 |
+
for category in categories
|
212 |
}
|
213 |
for submission_id in submission_ids
|
214 |
}
|
|
|
216 |
with self.var_lock.rw:
|
217 |
self.leaderboard_dataframes = leaderboard_dataframes
|
218 |
self.tournament_dataframes = tournament_dataframes
|
219 |
+
|
220 |
+
leaderboard_dataframes_csv = {
|
221 |
+
category: self._dataframe_to_csv(self.get_leaderboard(category=category), f"Leaderboard - {category}.csv")
|
222 |
+
for category in categories
|
223 |
+
}
|
224 |
+
|
225 |
+
with self.var_lock.ro:
|
226 |
+
tournament_dataframes_csv = {
|
227 |
+
submission_id: {
|
228 |
+
category: self._dataframe_to_csv(
|
229 |
+
self.get_model_tournament_table(submission_id, category).data,
|
230 |
+
f"Tournament table - {self.submission_id_to_data[submission_id]['metadata']['model_name'][:self.MAX_LENGTH_OF_MODEL_TITLE]} - {category}.csv",
|
231 |
+
)
|
232 |
+
for category in sorted(self.TASKS_CATEGORIES)
|
233 |
+
}
|
234 |
+
for submission_id in submission_ids
|
235 |
+
}
|
236 |
+
|
237 |
+
with self.var_lock.rw:
|
238 |
+
self.leaderboard_dataframes_csv = leaderboard_dataframes_csv
|
239 |
+
self.tournament_dataframes_csv = tournament_dataframes_csv
|
240 |
|
241 |
def load_tournament_results(self):
|
242 |
with self.results_dataset_local_snapshot_lock.ro:
|
|
|
436 |
dataframe = dataframe.style.apply(self._model_tournament_table_highlight_true_and_false, axis=None)
|
437 |
return dataframe
|
438 |
|
439 |
+
def _dataframe_to_csv(self, dataframe, filename):
|
440 |
+
try:
|
441 |
+
if not os.path.isdir(self.DIR_DATAFRAMES_CSV):
|
442 |
+
os.mkdir(self.DIR_DATAFRAMES_CSV)
|
443 |
+
except FileExistsError:
|
444 |
+
pass
|
445 |
+
|
446 |
+
filepath = os.path.join(self.DIR_DATAFRAMES_CSV, filename)
|
447 |
+
dataframe.to_csv(filepath)
|
448 |
+
return filepath
|
449 |
+
|
450 |
+
def get_leaderboard_csv(self, category=None):
|
451 |
+
category = category if category else self.TASKS_CATEGORY_OVERALL
|
452 |
+
with self.var_lock.ro:
|
453 |
+
return self.leaderboard_dataframes_csv[category]
|
454 |
+
|
455 |
def get_leaderboard(self, pre_submit=None, category=None):
|
456 |
if pre_submit == None:
|
457 |
category = category if category else self.TASKS_CATEGORY_OVERALL
|