Clémentine commited on
Commit
bf23d2b
1 Parent(s): b4ba8b7

update timer

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import os
2
  import logging
3
  import time
 
4
  import gradio as gr
5
  import datasets
6
  from huggingface_hub import snapshot_download, WebhooksServer, WebhookPayload, RepoCard
@@ -356,10 +357,16 @@ async def update_leaderboard(payload: WebhookPayload) -> None:
356
  verification_mode="no_checks"
357
  )
358
 
 
359
  @webhooks_server.add_webhook
360
  async def update_queue(payload: WebhookPayload) -> None:
361
  """Redownloads the queue dataset each time it updates"""
362
  if payload.repo.type == "dataset" and payload.event.action == "update":
363
- download_dataset(QUEUE_REPO, EVAL_REQUESTS_PATH)
 
 
 
 
 
364
 
365
  webhooks_server.launch()
 
1
  import os
2
  import logging
3
  import time
4
+ import datetime
5
  import gradio as gr
6
  import datasets
7
  from huggingface_hub import snapshot_download, WebhooksServer, WebhookPayload, RepoCard
 
357
  verification_mode="no_checks"
358
  )
359
 
360
+ LAST_UPDATE_QUEUE = datetime.datetime.now()
361
  @webhooks_server.add_webhook
362
  async def update_queue(payload: WebhookPayload) -> None:
363
  """Redownloads the queue dataset each time it updates"""
364
  if payload.repo.type == "dataset" and payload.event.action == "update":
365
+ current_time = datetime.datetime.now()
366
+ if current_time - LAST_UPDATE_QUEUE > datetime.timedelta(minutes=10):
367
+ # We only redownload is last update was more than 10 minutes ago, as the queue is
368
+ # updated regularly and heavy to download
369
+ download_dataset(QUEUE_REPO, EVAL_REQUESTS_PATH)
370
+ LAST_UPDATE_QUEUE = datetime.datetime.now()
371
 
372
  webhooks_server.launch()