Skip to content

Commit

Permalink
Added sleep to Zenodo retry
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddavo committed Oct 16, 2023
1 parent 9140604 commit 04ecc5d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/utils/uploadDataWarehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import shutil
import json
import requests
from time import sleep

from tqdm import tqdm

Expand Down Expand Up @@ -51,7 +52,7 @@ def uploadToZenodo(paths):
z = Zenodo(None, sandbox=ZENODO_SANDBOX)
z.update(ZENODO_DEPOSITION_ID, paths)

def archiveToZenodo(tmpdir, max_retries: int):
def archiveToZenodo(tmpdir, max_retries: int, sleep_seconds: int = 60):
with tempfile.TemporaryDirectory() as zpath:
zpath = Path(zpath)
shutil.make_archive(zpath / 'archive', 'zip', tmpdir)
Expand All @@ -65,6 +66,7 @@ def archiveToZenodo(tmpdir, max_retries: int):
except requests.exceptions.HTTPError as e:
if e.errno == 504:
print(f"Retrying upload to Zenodo {i}/{max_retries}")
sleep(sleep_seconds)
else:
raise e
i += 1
Expand Down

0 comments on commit 04ecc5d

Please sign in to comment.