idolezal commited on
Commit
98748fe
1 Parent(s): 9d06372

Try update whole Leaderboard

Browse files
Files changed (1) hide show
  1. app.py +36 -29
app.py CHANGED
@@ -175,14 +175,41 @@ def get_submission_ids_and_titles():
175
 
176
  return submission_ids_and_titles
177
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  def submit_results():
179
  leaderboard_server.save_pre_submit()
180
  gr.Info('Submission successful!')
181
 
182
  with leaderboard_server.var_lock.ro:
183
- leaderboard = Leaderboard(
184
- value=leaderboard_server.get_leaderboard(category=leaderboard_server.TASKS_CATEGORY_OVERALL),
185
- visible=True,
186
  )
187
  leaderboard_csv = gr.update(
188
  value=leaderboard_server.get_leaderboard_csv(category=leaderboard_server.TASKS_CATEGORY_OVERALL),
@@ -302,9 +329,8 @@ def change_leaderboard_category(category, selected_submission_id):
302
  model_tournament_results_table = fetch_model_tournament_results_table(selected_submission_id, category)
303
  model_tournament_results_table_csv = fetch_model_tournament_results_table_csv(selected_submission_id, category)
304
 
305
- leaderboard = Leaderboard(
306
- value=leaderboard_server.get_leaderboard(category=category),
307
- visible=True,
308
  )
309
  leaderboard_csv = gr.update(
310
  value=leaderboard_server.get_leaderboard_csv(category=category),
@@ -409,9 +435,8 @@ def check_significance_is_reachable_hook():
409
 
410
  def on_application_load():
411
  with leaderboard_server.var_lock.ro:
412
- leaderboard = Leaderboard(
413
- value=leaderboard_server.get_leaderboard(category=leaderboard_server.TASKS_CATEGORY_OVERALL),
414
- visible=True,
415
  )
416
  leaderboard_csv = gr.update(
417
  value=leaderboard_server.get_leaderboard_csv(category=leaderboard_server.TASKS_CATEGORY_OVERALL),
@@ -636,26 +661,8 @@ def gradio_app():
636
  # for col in leaderboard_dataframe_number_cols:
637
  # leaderboard_dataframe[col] = leaderboard_dataframe[col].apply(lambda x: x.str.replace('.', ','))
638
 
639
- leaderboard_table = Leaderboard(
640
- value=leaderboard_dataframe,
641
- datatype=leaderboard_datatype,
642
- select_columns=SelectColumns(
643
- default_selection=None,
644
- cant_deselect=["Model"],
645
- label="Select Columns to Display:",
646
- ),
647
- search_columns=["model_title"],
648
- hide_columns=["model_title"],
649
- filter_columns=[
650
- ColumnFilter("Type", type="checkboxgroup", label="Model types"),
651
- ColumnFilter(
652
- "# θ (B)",
653
- type="slider",
654
- default=[-1, -1],
655
- label="Select the number of parameters (B)",
656
- ),
657
- ],
658
- elem_classes="leaderboard-table",
659
  )
660
 
661
  with gr.Row():
 
175
 
176
  return submission_ids_and_titles
177
 
178
+ def init_leaderboard(dataframe):
179
+ if dataframe is None or dataframe.empty:
180
+ raise ValueError("Leaderboard DataFrame is empty or None.")
181
+
182
+ datatype = ["markdown" if idx < 3 else "number" for idx, col in enumerate(dataframe)]
183
+
184
+ return Leaderboard(
185
+ value=dataframe,
186
+ datatype=datatype,
187
+ select_columns=SelectColumns(
188
+ default_selection=None,
189
+ cant_deselect=["Model"],
190
+ label="Select Columns to Display:",
191
+ ),
192
+ search_columns=["model_title"],
193
+ hide_columns=["model_title"],
194
+ filter_columns=[
195
+ ColumnFilter("Type", type="checkboxgroup", label="Model types"),
196
+ ColumnFilter(
197
+ "# θ (B)",
198
+ type="slider",
199
+ default=[-1, -1],
200
+ label="Select the number of parameters (B)",
201
+ ),
202
+ ],
203
+ elem_classes="leaderboard-table",
204
+ )
205
+
206
  def submit_results():
207
  leaderboard_server.save_pre_submit()
208
  gr.Info('Submission successful!')
209
 
210
  with leaderboard_server.var_lock.ro:
211
+ leaderboard = init_leaderboard(
212
+ leaderboard_server.get_leaderboard(category=leaderboard_server.TASKS_CATEGORY_OVERALL)
 
213
  )
214
  leaderboard_csv = gr.update(
215
  value=leaderboard_server.get_leaderboard_csv(category=leaderboard_server.TASKS_CATEGORY_OVERALL),
 
329
  model_tournament_results_table = fetch_model_tournament_results_table(selected_submission_id, category)
330
  model_tournament_results_table_csv = fetch_model_tournament_results_table_csv(selected_submission_id, category)
331
 
332
+ leaderboard = init_leaderboard(
333
+ leaderboard_server.get_leaderboard(category=category)
 
334
  )
335
  leaderboard_csv = gr.update(
336
  value=leaderboard_server.get_leaderboard_csv(category=category),
 
435
 
436
  def on_application_load():
437
  with leaderboard_server.var_lock.ro:
438
+ leaderboard = init_leaderboard(
439
+ leaderboard_server.get_leaderboard(category=leaderboard_server.TASKS_CATEGORY_OVERALL)
 
440
  )
441
  leaderboard_csv = gr.update(
442
  value=leaderboard_server.get_leaderboard_csv(category=leaderboard_server.TASKS_CATEGORY_OVERALL),
 
661
  # for col in leaderboard_dataframe_number_cols:
662
  # leaderboard_dataframe[col] = leaderboard_dataframe[col].apply(lambda x: x.str.replace('.', ','))
663
 
664
+ leaderboard_table = init_leaderboard(
665
+ leaderboard_server.get_leaderboard(category=leaderboard_server.TASKS_CATEGORY_OVERALL)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
666
  )
667
 
668
  with gr.Row():