multimodalart HF staff commited on
Commit
fb79844
1 Parent(s): 6b17493

Upload to different folders and every 20 minutes

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -233,10 +233,11 @@ def upload_files():
233
  """
234
  if os.path.exists("tmp/results") and os.path.isdir("tmp/results"):
235
  try:
 
236
  shutil.make_archive("tmp/results", 'zip', "tmp/results")
237
  hf_api.upload_file(
238
  path_or_fileobj="tmp/results.zip",
239
- path_in_repo=f"results_{shortuuid.uuid()}.zip",
240
  repo_id=UPLOAD_REPO_ID,
241
  repo_type="dataset",
242
  )
@@ -694,7 +695,7 @@ with gr.Blocks(css='style.css') as demo:
694
 
695
  if UPLOAD_REPO_ID:
696
  scheduler = BackgroundScheduler()
697
- scheduler.add_job(func=upload_files, trigger="interval", seconds=60*5)
698
  scheduler.start()
699
 
700
  demo.queue(api_open=False, max_size=MAX_QUEUE_SIZE).launch(debug=DEBUG)
 
233
  """
234
  if os.path.exists("tmp/results") and os.path.isdir("tmp/results"):
235
  try:
236
+ random_folder = random.randint(0,1000)
237
  shutil.make_archive("tmp/results", 'zip', "tmp/results")
238
  hf_api.upload_file(
239
  path_or_fileobj="tmp/results.zip",
240
+ path_in_repo=f"{random_folder}/results_{shortuuid.uuid()}.zip",
241
  repo_id=UPLOAD_REPO_ID,
242
  repo_type="dataset",
243
  )
 
695
 
696
  if UPLOAD_REPO_ID:
697
  scheduler = BackgroundScheduler()
698
+ scheduler.add_job(func=upload_files, trigger="interval", seconds=60*20)
699
  scheduler.start()
700
 
701
  demo.queue(api_open=False, max_size=MAX_QUEUE_SIZE).launch(debug=DEBUG)