osanseviero HF staff commited on
Commit
c08739f
1 Parent(s): cb7f33f

Automatically refresh the leaderboard when loading the space

Browse files

With the current implementation, upon load, the leaderboard is outdated and users need to click refresh to update the results. This button does not actually update the original data (`leaderboard` and `eval_queue`), so upon refresh it's lost. This is also the reason why the `BackgroundScheduler` was not working. So either the background scheduler updates the variables, or we update the data at load time.

Files changed (1) hide show
  1. app.py +1 -14
app.py CHANGED
@@ -251,19 +251,6 @@ We chose these benchmarks as they test a variety of reasoning and general knowle
251
  submit_button = gr.Button("Submit Eval")
252
  submit_button.click(add_new_eval, [model_name_textbox, base_model_name_textbox, revision_name_textbox, is_8bit_toggle, private, is_delta_weight])
253
 
254
-
255
-
256
-
257
-
258
-
259
- print("adding refresh leaderboard")
260
- def refresh_leaderboard():
261
- leaderboard_table = get_leaderboard()
262
- eval_table = get_eval_table()
263
- print("refreshing leaderboard")
264
-
265
- scheduler = BackgroundScheduler()
266
- scheduler.add_job(func=refresh_leaderboard, trigger="interval", seconds=300) # refresh every 5 mins
267
- scheduler.start()
268
 
 
269
  block.launch()
251
  submit_button = gr.Button("Submit Eval")
252
  submit_button.click(add_new_eval, [model_name_textbox, base_model_name_textbox, revision_name_textbox, is_8bit_toggle, private, is_delta_weight])
253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
 
255
+ block.load(refresh, inputs=[], outputs=[leaderboard_table, eval_table])
256
  block.launch()