idolezal commited on
Commit
1c921ec
1 Parent(s): 2ddb0f5

In dropdowns changed "submission_id" to "team_name/model_name"

Browse files
Files changed (2) hide show
  1. app.py +44 -21
  2. server.py +2 -0
app.py CHANGED
@@ -97,6 +97,17 @@ def process_submission(*inputs):
97
  ),
98
  )
99
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  def submit_results():
102
  leaderboard_server.save_pre_submit()
@@ -105,7 +116,7 @@ def submit_results():
105
 
106
  with leaderboard_server.var_lock.ro:
107
  leaderboard = leaderboard_server.get_leaderboard(category=leaderboard_server.TASKS_CATEGORY_OVERALL)
108
- submission_ids = leaderboard_server.submission_ids
109
 
110
  return (
111
  gr.update(value='Pre-submit model', visible=True, interactive=True),
@@ -116,8 +127,9 @@ def submit_results():
116
  gr.update(visible=False),
117
  gr.DataFrame(value=leaderboard, visible=True),
118
  gr.update(visible=False),
119
- gr.update(choices=submission_ids),
120
  gr.update(value=leaderboard_server.TASKS_CATEGORY_OVERALL),
 
121
  )
122
 
123
 
@@ -207,12 +219,20 @@ def hide_modal():
207
 
208
  def on_application_load():
209
  leaderboard_server.update_leaderboard()
 
210
  with leaderboard_server.var_lock.ro:
211
- return (
212
- gr.DataFrame(value=leaderboard_server.get_leaderboard(category=leaderboard_server.TASKS_CATEGORY_OVERALL), visible=True),
213
- gr.update(choices=leaderboard_server.submission_ids),
214
- gr.update(value=leaderboard_server.TASKS_CATEGORY_OVERALL),
215
- )
 
 
 
 
 
 
 
216
 
217
 
218
  custom_css = """
@@ -283,6 +303,9 @@ with gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css=custom_css) as main:
283
  gr.Markdown(HEADER_MARKDOWN)
284
 
285
  with gr.Tabs():
 
 
 
286
  with gr.TabItem('Leaderboard'):
287
  with gr.Column():
288
  gr.Markdown(LEADERBOARD_TAB_TITLE_MARKDOWN)
@@ -327,14 +350,13 @@ with gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css=custom_css) as main:
327
  )
328
 
329
  with gr.Row():
330
- with leaderboard_server.var_lock.ro:
331
- tournament_results_dropdown = gr.Dropdown(
332
- value=None,
333
- choices=leaderboard_server.submission_ids, # TODO: team_name/model_name
334
- label="Select model",
335
- visible=False,
336
- interactive=True,
337
- )
338
 
339
  with gr.Row():
340
  model_tournament_results_table = gr.DataFrame(
@@ -370,12 +392,11 @@ with gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css=custom_css) as main:
370
  with gr.TabItem('Model details'):
371
  gr.Markdown(MORE_DETAILS_MARKDOWN)
372
 
373
- with leaderboard_server.var_lock.ro:
374
- detail_dropdown = gr.Dropdown(
375
- choices=leaderboard_server.submission_ids, # TODO: team_name/model_name
376
- label="Select model",
377
- interactive=True,
378
- )
379
 
380
  with gr.Row():
381
  model_description = gr.Text(value='', label='Model description', visible=False, interactive=False)
@@ -477,6 +498,7 @@ with gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css=custom_css) as main:
477
  modal_submit,
478
  detail_dropdown,
479
  category_of_tasks,
 
480
  ],
481
  )
482
 
@@ -504,6 +526,7 @@ with gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css=custom_css) as main:
504
  results_table,
505
  detail_dropdown,
506
  category_of_tasks,
 
507
  ]
508
  )
509
 
 
97
  ),
98
  )
99
 
100
+ def get_submission_ids_and_titles():
101
+ with leaderboard_server.var_lock.ro:
102
+ submission_ids_and_titles = [
103
+ (
104
+ leaderboard_server.submission_id_to_model_title[submission_id],
105
+ submission_id,
106
+ )
107
+ for submission_id in leaderboard_server.submission_ids
108
+ ]
109
+
110
+ return submission_ids_and_titles
111
 
112
  def submit_results():
113
  leaderboard_server.save_pre_submit()
 
116
 
117
  with leaderboard_server.var_lock.ro:
118
  leaderboard = leaderboard_server.get_leaderboard(category=leaderboard_server.TASKS_CATEGORY_OVERALL)
119
+ submission_ids_and_titles = get_submission_ids_and_titles()
120
 
121
  return (
122
  gr.update(value='Pre-submit model', visible=True, interactive=True),
 
127
  gr.update(visible=False),
128
  gr.DataFrame(value=leaderboard, visible=True),
129
  gr.update(visible=False),
130
+ gr.update(choices=submission_ids_and_titles),
131
  gr.update(value=leaderboard_server.TASKS_CATEGORY_OVERALL),
132
+ gr.update(choices=submission_ids_and_titles),
133
  )
134
 
135
 
 
219
 
220
  def on_application_load():
221
  leaderboard_server.update_leaderboard()
222
+
223
  with leaderboard_server.var_lock.ro:
224
+ leaderboard = leaderboard_server.get_leaderboard(category=leaderboard_server.TASKS_CATEGORY_OVERALL)
225
+ submission_ids_and_titles = get_submission_ids_and_titles()
226
+
227
+ return (
228
+ gr.update(
229
+ value=leaderboard,
230
+ visible=True,
231
+ ),
232
+ gr.update(choices=submission_ids_and_titles),
233
+ gr.update(value=leaderboard_server.TASKS_CATEGORY_OVERALL),
234
+ gr.update(choices=submission_ids_and_titles),
235
+ )
236
 
237
 
238
  custom_css = """
 
303
  gr.Markdown(HEADER_MARKDOWN)
304
 
305
  with gr.Tabs():
306
+ with leaderboard_server.var_lock.ro:
307
+ submission_ids_and_titles = get_submission_ids_and_titles()
308
+
309
  with gr.TabItem('Leaderboard'):
310
  with gr.Column():
311
  gr.Markdown(LEADERBOARD_TAB_TITLE_MARKDOWN)
 
350
  )
351
 
352
  with gr.Row():
353
+ tournament_results_dropdown = gr.Dropdown(
354
+ value=None,
355
+ choices=submission_ids_and_titles,
356
+ label="Select model",
357
+ visible=False,
358
+ interactive=True,
359
+ )
 
360
 
361
  with gr.Row():
362
  model_tournament_results_table = gr.DataFrame(
 
392
  with gr.TabItem('Model details'):
393
  gr.Markdown(MORE_DETAILS_MARKDOWN)
394
 
395
+ detail_dropdown = gr.Dropdown(
396
+ choices=submission_ids_and_titles,
397
+ label="Select model",
398
+ interactive=True,
399
+ )
 
400
 
401
  with gr.Row():
402
  model_description = gr.Text(value='', label='Model description', visible=False, interactive=False)
 
498
  modal_submit,
499
  detail_dropdown,
500
  category_of_tasks,
501
+ tournament_results_dropdown,
502
  ],
503
  )
504
 
 
526
  results_table,
527
  detail_dropdown,
528
  category_of_tasks,
529
+ tournament_results_dropdown,
530
  ]
531
  )
532
 
server.py CHANGED
@@ -160,6 +160,7 @@ class LeaderboardServer:
160
  self.var_lock = ReadWriteLock()
161
  self.submission_ids = set()
162
  self.submission_id_to_file = {} # Map submission ids to file paths
 
163
  self.fetch_existing_models()
164
  self.tournament_results = self.load_tournament_results()
165
 
@@ -213,6 +214,7 @@ class LeaderboardServer:
213
  with self.var_lock.rw:
214
  self.submission_ids.add(submission_id)
215
  self.submission_id_to_file[submission_id] = submission_file
 
216
 
217
  def get_model_tournament_table(self, submission_id, category):
218
  if category == self.TASKS_CATEGORY_OVERALL:
 
160
  self.var_lock = ReadWriteLock()
161
  self.submission_ids = set()
162
  self.submission_id_to_file = {} # Map submission ids to file paths
163
+ self.submission_id_to_model_title = {}
164
  self.fetch_existing_models()
165
  self.tournament_results = self.load_tournament_results()
166
 
 
214
  with self.var_lock.rw:
215
  self.submission_ids.add(submission_id)
216
  self.submission_id_to_file[submission_id] = submission_file
217
+ self.submission_id_to_model_title[submission_id] = metadata["team_name"] + "/" + metadata["model_name"]
218
 
219
  def get_model_tournament_table(self, submission_id, category):
220
  if category == self.TASKS_CATEGORY_OVERALL: