Clémentine commited on
Commit
7a427c5
1 Parent(s): 8f7c1b2

some comments + simplified queue update - uses leaderboard updates as trigger

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -90,7 +90,7 @@ def download_dataset(repo_id, local_dir, repo_type="dataset", max_attempts=3, ba
90
  attempt += 1
91
  raise Exception(f"Failed to download {repo_id} after {max_attempts} attempts")
92
 
93
- def get_latest_data_leaderboard(leaderboard_initial_df):
94
  current_time = datetime.datetime.now()
95
  global LAST_UPDATE_LEADERBOARD
96
  if current_time - LAST_UPDATE_LEADERBOARD < datetime.timedelta(minutes=10) and leaderboard_initial_df is not None:
@@ -127,7 +127,7 @@ def init_space():
127
  restart_space()
128
 
129
  # Always redownload the leaderboard DataFrame
130
- leaderboard_df = get_latest_data_leaderboard(None)
131
 
132
  # Evaluation queue DataFrame retrieval is independent of initialization detail level
133
  eval_queue_dfs = get_latest_data_queue()
@@ -312,7 +312,7 @@ with demo:
312
  )
313
 
314
  demo.load(fn=get_latest_data_leaderboard, inputs=[leaderboard], outputs=[leaderboard])
315
- #demo.load(fn=get_latest_data_queue, inputs=None, outputs=[finished_eval_table, running_eval_table, pending_eval_table])
316
 
317
 
318
  demo.queue(default_concurrency_limit=40)
@@ -363,6 +363,7 @@ def update_leaderboard(payload: WebhookPayload) -> None:
363
  verification_mode="no_checks"
364
  )
365
 
 
366
  LAST_UPDATE_QUEUE = datetime.datetime.now()
367
  @webhooks_server.add_webhook
368
  def update_queue(payload: WebhookPayload) -> None:
@@ -371,7 +372,7 @@ def update_queue(payload: WebhookPayload) -> None:
371
  current_time = datetime.datetime.now()
372
  global LAST_UPDATE_QUEUE
373
  if current_time - LAST_UPDATE_QUEUE > datetime.timedelta(minutes=10):
374
- print("would have updated")
375
  # We only redownload is last update was more than 10 minutes ago, as the queue is
376
  # updated regularly and heavy to download
377
  #download_dataset(QUEUE_REPO, EVAL_REQUESTS_PATH)
 
90
  attempt += 1
91
  raise Exception(f"Failed to download {repo_id} after {max_attempts} attempts")
92
 
93
+ def get_latest_data_leaderboard(leaderboard_initial_df = None):
94
  current_time = datetime.datetime.now()
95
  global LAST_UPDATE_LEADERBOARD
96
  if current_time - LAST_UPDATE_LEADERBOARD < datetime.timedelta(minutes=10) and leaderboard_initial_df is not None:
 
127
  restart_space()
128
 
129
  # Always redownload the leaderboard DataFrame
130
+ leaderboard_df = get_latest_data_leaderboard()
131
 
132
  # Evaluation queue DataFrame retrieval is independent of initialization detail level
133
  eval_queue_dfs = get_latest_data_queue()
 
312
  )
313
 
314
  demo.load(fn=get_latest_data_leaderboard, inputs=[leaderboard], outputs=[leaderboard])
315
+ leaderboard.change(fn=get_latest_data_queue, inputs=None, outputs=[finished_eval_table, running_eval_table, pending_eval_table])
316
 
317
 
318
  demo.queue(default_concurrency_limit=40)
 
363
  verification_mode="no_checks"
364
  )
365
 
366
+ # The below code is not used at the moment, as we can manage the queue file locally
367
  LAST_UPDATE_QUEUE = datetime.datetime.now()
368
  @webhooks_server.add_webhook
369
  def update_queue(payload: WebhookPayload) -> None:
 
372
  current_time = datetime.datetime.now()
373
  global LAST_UPDATE_QUEUE
374
  if current_time - LAST_UPDATE_QUEUE > datetime.timedelta(minutes=10):
375
+ print("Would have updated the queue")
376
  # We only redownload is last update was more than 10 minutes ago, as the queue is
377
  # updated regularly and heavy to download
378
  #download_dataset(QUEUE_REPO, EVAL_REQUESTS_PATH)