From 04ecc5d4a3a1d14f2b21ff983bc10e28ceb4e419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Dav=C3=B3?= Date: Mon, 16 Oct 2023 11:55:25 +0200 Subject: [PATCH] Added sleep to Zenodo retry --- src/utils/uploadDataWarehouse.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/uploadDataWarehouse.py b/src/utils/uploadDataWarehouse.py index 0b25708..a85df35 100644 --- a/src/utils/uploadDataWarehouse.py +++ b/src/utils/uploadDataWarehouse.py @@ -5,6 +5,7 @@ import shutil import json import requests +from time import sleep from tqdm import tqdm @@ -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) @@ -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