Spaces:
Runtime error
Runtime error
User managed solution for a new tournament creation
Browse files
app.py
CHANGED
@@ -288,6 +288,33 @@ def enable_submit_buttons():
|
|
288 |
gr.update(interactive=True),
|
289 |
)
|
290 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
def on_application_load():
|
292 |
with leaderboard_server.var_lock.ro:
|
293 |
leaderboard = gr.update(
|
@@ -340,7 +367,57 @@ tr.row_odd {
|
|
340 |
def gradio_app():
|
341 |
with gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css=custom_css) as main:
|
342 |
gr.Markdown(HEADER_MARKDOWN)
|
343 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
with gr.Tabs():
|
345 |
with leaderboard_server.var_lock.ro:
|
346 |
submission_ids_and_titles = get_submission_ids_and_titles()
|
|
|
288 |
gr.update(interactive=True),
|
289 |
)
|
290 |
|
291 |
+
def results_dataset_integrity_check():
|
292 |
+
leaderboard_server.results_dataset_integrity_check(solve=True)
|
293 |
+
|
294 |
+
def on_tournament_results_corrupted():
|
295 |
+
if leaderboard_server.tournament_results_corrupted and not leaderboard_server.tournament_results_integrity_solving:
|
296 |
+
results_dataset_integrity_check_btn = gr.update(
|
297 |
+
interactive=True,
|
298 |
+
visible=True,
|
299 |
+
)
|
300 |
+
results_dataset_integrity_solving_progress = gr.update(
|
301 |
+
visible=False,
|
302 |
+
)
|
303 |
+
else:
|
304 |
+
results_dataset_integrity_check_btn = gr.update(
|
305 |
+
interactive=False,
|
306 |
+
visible=False,
|
307 |
+
)
|
308 |
+
results_dataset_integrity_solving_progress = gr.update(
|
309 |
+
value=leaderboard_server.tournament_results_integrity_solving_progress * 100,
|
310 |
+
visible=True,
|
311 |
+
)
|
312 |
+
|
313 |
+
return (
|
314 |
+
results_dataset_integrity_check_btn,
|
315 |
+
results_dataset_integrity_solving_progress,
|
316 |
+
)
|
317 |
+
|
318 |
def on_application_load():
|
319 |
with leaderboard_server.var_lock.ro:
|
320 |
leaderboard = gr.update(
|
|
|
367 |
def gradio_app():
|
368 |
with gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css=custom_css) as main:
|
369 |
gr.Markdown(HEADER_MARKDOWN)
|
370 |
+
|
371 |
+
if leaderboard_server.tournament_results_corrupted:
|
372 |
+
results_dataset_integrity_check_btn = gr.Button(
|
373 |
+
value='Check integrity of results dataset',
|
374 |
+
interactive=True,
|
375 |
+
visible=False,
|
376 |
+
)
|
377 |
+
|
378 |
+
results_dataset_integrity_solving_progress = gr.Slider(
|
379 |
+
minimum=0,
|
380 |
+
maximum=100,
|
381 |
+
value=leaderboard_server.tournament_results_integrity_solving_progress * 100,
|
382 |
+
label="Tournament results is preparing, please wait…",
|
383 |
+
interactive=False,
|
384 |
+
visible=False,
|
385 |
+
)
|
386 |
+
|
387 |
+
results_dataset_integrity_solving_progress_timer = gr.Timer(
|
388 |
+
value=2,
|
389 |
+
)
|
390 |
+
|
391 |
+
results_dataset_integrity_solving_progress_timer.tick(
|
392 |
+
fn=lambda: gr.update(
|
393 |
+
value=leaderboard_server.tournament_results_integrity_solving_progress * 100
|
394 |
+
),
|
395 |
+
outputs=results_dataset_integrity_solving_progress
|
396 |
+
)
|
397 |
+
|
398 |
+
results_dataset_integrity_check_btn.click(
|
399 |
+
fn=lambda: (
|
400 |
+
gr.update(interactive=False, visible=False),
|
401 |
+
gr.update(visible=True),
|
402 |
+
),
|
403 |
+
outputs=[
|
404 |
+
results_dataset_integrity_check_btn,
|
405 |
+
results_dataset_integrity_solving_progress,
|
406 |
+
]
|
407 |
+
).then(
|
408 |
+
fn=results_dataset_integrity_check
|
409 |
+
)
|
410 |
+
|
411 |
+
main.load(
|
412 |
+
fn=on_tournament_results_corrupted,
|
413 |
+
outputs=[
|
414 |
+
results_dataset_integrity_check_btn,
|
415 |
+
results_dataset_integrity_solving_progress,
|
416 |
+
]
|
417 |
+
)
|
418 |
+
|
419 |
+
return main
|
420 |
+
|
421 |
with gr.Tabs():
|
422 |
with leaderboard_server.var_lock.ro:
|
423 |
submission_ids_and_titles = get_submission_ids_and_titles()
|
server.py
CHANGED
@@ -187,6 +187,9 @@ class LeaderboardServer:
|
|
187 |
self.submission_id_to_model_title = {}
|
188 |
self.submission_id_to_data = {} # Only data (results and metadata) using by leaderboard
|
189 |
self.tournament_results = None
|
|
|
|
|
|
|
190 |
|
191 |
self.leaderboard_dataframes = {} # For each category
|
192 |
self.tournament_dataframes = {} # For each submission_id and category
|
@@ -223,7 +226,7 @@ class LeaderboardServer:
|
|
223 |
categories = [self.TASKS_CATEGORY_OVERALL] + sorted(self.TASKS_CATEGORIES)
|
224 |
|
225 |
leaderboard_dataframes = {
|
226 |
-
category: self._get_leaderboard(category=category)
|
227 |
for category in categories
|
228 |
}
|
229 |
|
@@ -232,7 +235,7 @@ class LeaderboardServer:
|
|
232 |
|
233 |
tournament_dataframes = {
|
234 |
submission_id: {
|
235 |
-
category: self._get_model_tournament_table(submission_id, category)
|
236 |
for category in categories
|
237 |
}
|
238 |
for submission_id in submission_ids
|
@@ -243,7 +246,10 @@ class LeaderboardServer:
|
|
243 |
self.tournament_dataframes = tournament_dataframes
|
244 |
|
245 |
leaderboard_dataframes_csv = {
|
246 |
-
category: self._dataframe_to_csv(
|
|
|
|
|
|
|
247 |
for category in categories
|
248 |
}
|
249 |
|
@@ -251,7 +257,7 @@ class LeaderboardServer:
|
|
251 |
tournament_dataframes_csv = {
|
252 |
submission_id: {
|
253 |
category: self._dataframe_to_csv(
|
254 |
-
self._get_model_tournament_table(submission_id, category, to_csv=True),
|
255 |
f"Tournament table - {self.submission_id_to_data[submission_id]['submission_metadata']['model_name'][:self.MAX_LENGTH_OF_MODEL_TITLE].replace('/', '_')} - {category}.csv",
|
256 |
)
|
257 |
for category in sorted(self.TASKS_CATEGORIES)
|
@@ -326,7 +332,7 @@ class LeaderboardServer:
|
|
326 |
self.submission_id_to_model_title = submission_id_to_model_title
|
327 |
self.submission_id_to_data = submission_id_to_data
|
328 |
|
329 |
-
def results_dataset_integrity_check(self):
|
330 |
"""
|
331 |
Zkontroluje, že:
|
332 |
- všechny modely byly v duelu se všemi
|
@@ -361,31 +367,48 @@ class LeaderboardServer:
|
|
361 |
):
|
362 |
pass
|
363 |
else:
|
|
|
364 |
break
|
365 |
-
|
366 |
-
renew_tournament_began_datetime = datetime.now(timezone.utc)
|
367 |
-
datetime2str = lambda d: d.strftime("%Y-%m-%dT%H:%M:%S %Z")
|
368 |
-
print(f"Renew tournament began at {datetime2str(renew_tournament_began_datetime)}")
|
369 |
-
gr.Info('Running tournament...', duration=15)
|
370 |
-
with self.var_lock.rw:
|
371 |
-
self.tournament_results = {}
|
372 |
-
submission_ids_backup = self.submission_ids
|
373 |
-
self.submission_ids = set()
|
374 |
-
for submission_id in submission_ids_backup:
|
375 |
-
with self.var_lock.ro:
|
376 |
-
file = self.submission_id_to_file[submission_id]
|
377 |
-
tournament_results = self.start_tournament(submission_id, file)
|
378 |
-
with self.var_lock.rw:
|
379 |
-
self.tournament_results = tournament_results
|
380 |
-
self.submission_ids.add(submission_id)
|
381 |
-
renew_tournament_ended_datetime = datetime.now(timezone.utc)
|
382 |
-
print(f"Renew tournament ended at {datetime2str(renew_tournament_ended_datetime)}")
|
383 |
-
renew_tournament_ended_time_elapsed = renew_tournament_ended_datetime - renew_tournament_began_datetime
|
384 |
-
print(f"Time elapsed: {renew_tournament_ended_time_elapsed}")
|
385 |
|
386 |
-
|
387 |
-
|
388 |
-
self.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
|
390 |
break
|
391 |
gr.Info("Waiting in queue...", duration=5)
|
|
|
187 |
self.submission_id_to_model_title = {}
|
188 |
self.submission_id_to_data = {} # Only data (results and metadata) using by leaderboard
|
189 |
self.tournament_results = None
|
190 |
+
self.tournament_results_corrupted = False
|
191 |
+
self.tournament_results_integrity_solving = False
|
192 |
+
self.tournament_results_integrity_solving_progress = 0
|
193 |
|
194 |
self.leaderboard_dataframes = {} # For each category
|
195 |
self.tournament_dataframes = {} # For each submission_id and category
|
|
|
226 |
categories = [self.TASKS_CATEGORY_OVERALL] + sorted(self.TASKS_CATEGORIES)
|
227 |
|
228 |
leaderboard_dataframes = {
|
229 |
+
category: self._get_leaderboard(category=category) if not self.tournament_results_corrupted else pd.DataFrame(columns=['Corrupted, please check integrity'])
|
230 |
for category in categories
|
231 |
}
|
232 |
|
|
|
235 |
|
236 |
tournament_dataframes = {
|
237 |
submission_id: {
|
238 |
+
category: self._get_model_tournament_table(submission_id, category) if not self.tournament_results_corrupted else pd.DataFrame(columns=['Corrupted, please check integrity'])
|
239 |
for category in categories
|
240 |
}
|
241 |
for submission_id in submission_ids
|
|
|
246 |
self.tournament_dataframes = tournament_dataframes
|
247 |
|
248 |
leaderboard_dataframes_csv = {
|
249 |
+
category: self._dataframe_to_csv(
|
250 |
+
self._get_leaderboard(category=category, to_csv=True) if not self.tournament_results_corrupted else pd.DataFrame(columns=['Corrupted, please check integrity']),
|
251 |
+
f"Leaderboard - {category}.csv"
|
252 |
+
)
|
253 |
for category in categories
|
254 |
}
|
255 |
|
|
|
257 |
tournament_dataframes_csv = {
|
258 |
submission_id: {
|
259 |
category: self._dataframe_to_csv(
|
260 |
+
self._get_model_tournament_table(submission_id, category, to_csv=True) if not self.tournament_results_corrupted else pd.DataFrame(columns=['Corrupted, please check integrity']),
|
261 |
f"Tournament table - {self.submission_id_to_data[submission_id]['submission_metadata']['model_name'][:self.MAX_LENGTH_OF_MODEL_TITLE].replace('/', '_')} - {category}.csv",
|
262 |
)
|
263 |
for category in sorted(self.TASKS_CATEGORIES)
|
|
|
332 |
self.submission_id_to_model_title = submission_id_to_model_title
|
333 |
self.submission_id_to_data = submission_id_to_data
|
334 |
|
335 |
+
def results_dataset_integrity_check(self, solve=False):
|
336 |
"""
|
337 |
Zkontroluje, že:
|
338 |
- všechny modely byly v duelu se všemi
|
|
|
367 |
):
|
368 |
pass
|
369 |
else:
|
370 |
+
self.tournament_results_corrupted = False
|
371 |
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
|
373 |
+
if solve:
|
374 |
+
self.tournament_results_integrity_solving = True
|
375 |
+
self.tournament_results_integrity_solving_progress = 0
|
376 |
+
|
377 |
+
renew_tournament_began_datetime = datetime.now(timezone.utc)
|
378 |
+
datetime2str = lambda d: d.strftime("%Y-%m-%dT%H:%M:%S %Z")
|
379 |
+
print(f"Renew tournament began at {datetime2str(renew_tournament_began_datetime)}")
|
380 |
+
gr.Info('Running tournament...', duration=15)
|
381 |
+
|
382 |
+
with self.var_lock.rw:
|
383 |
+
self.tournament_results = {}
|
384 |
+
submission_ids_backup = self.submission_ids
|
385 |
+
self.submission_ids = set()
|
386 |
+
|
387 |
+
for i, submission_id in enumerate(submission_ids_backup):
|
388 |
+
self.tournament_results_integrity_solving_progress = i / len(submission_ids_backup)
|
389 |
+
|
390 |
+
with self.var_lock.ro:
|
391 |
+
file = self.submission_id_to_file[submission_id]
|
392 |
+
tournament_results = self.start_tournament(submission_id, file)
|
393 |
+
with self.var_lock.rw:
|
394 |
+
self.tournament_results = tournament_results
|
395 |
+
self.submission_ids.add(submission_id)
|
396 |
+
|
397 |
+
self.tournament_results_integrity_solving_progress = 1
|
398 |
+
|
399 |
+
renew_tournament_ended_datetime = datetime.now(timezone.utc)
|
400 |
+
print(f"Renew tournament ended at {datetime2str(renew_tournament_ended_datetime)}")
|
401 |
+
renew_tournament_ended_time_elapsed = renew_tournament_ended_datetime - renew_tournament_began_datetime
|
402 |
+
print(f"Time elapsed: {renew_tournament_ended_time_elapsed}")
|
403 |
+
|
404 |
+
gr.Info('Uploading tournament results...', duration=5)
|
405 |
+
if self.tournament_results:
|
406 |
+
self._upload_tournament_results(self.tournament_results)
|
407 |
+
|
408 |
+
self.tournament_results_integrity_solving = False
|
409 |
+
self.tournament_results_corrupted = False
|
410 |
+
else:
|
411 |
+
self.tournament_results_corrupted = True
|
412 |
|
413 |
break
|
414 |
gr.Info("Waiting in queue...", duration=5)
|