Skip to content

Commit 600555e

Browse files
committed
🐛 Add base timeout value of 10s for upload/download
1 parent c0a1ed1 commit 600555e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

simvue/api/objects/artifact/base.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
Category = typing.Literal["code", "input", "output"]
3333

34+
BASE_TIMEOUT: int = 10
3435
UPLOAD_TIMEOUT_PER_MB: int = 1
3536
DOWNLOAD_TIMEOUT_PER_MB: int = 1
3637
DOWNLOAD_CHUNK_SIZE: int = 8192
@@ -117,10 +118,10 @@ def _upload(self, file: io.BytesIO, timeout: int, file_size: int) -> None:
117118
return
118119

119120
if not timeout:
120-
timeout = UPLOAD_TIMEOUT_PER_MB * file_size / 1024 / 1024
121+
timeout = BASE_TIMEOUT + UPLOAD_TIMEOUT_PER_MB * file_size / 1024 / 1024
121122

122123
self._logger.debug(
123-
f"Will wait for a period of {timeout}s for upload of file to complete."
124+
f"Will wait for a period of {timeout:.0f}s for upload of file for {file_size}B file to complete."
124125
)
125126

126127
_name = self._staging["name"]
@@ -332,9 +333,16 @@ def download_content(self) -> typing.Generator[bytes, None, None]:
332333
raise ValueError(
333334
f"Could not retrieve URL for artifact '{self._identifier}'"
334335
)
336+
337+
_timeout = BASE_TIMEOUT + DOWNLOAD_TIMEOUT_PER_MB * self.size / 1024 / 1024
338+
339+
self._logger.debug(
340+
f"Will wait {_timeout:.0f}s for download of file {self.name} of size {self.size}B"
341+
)
342+
335343
_response = sv_get(
336344
f"{self.download_url}",
337-
timeout=DOWNLOAD_TIMEOUT_PER_MB * self.size / 1024 / 1024,
345+
timeout=_timeout,
338346
headers=None,
339347
)
340348

0 commit comments

Comments
 (0)