diff --git a/.pyproject_generation/pyproject_custom.toml b/.pyproject_generation/pyproject_custom.toml index c7da1eb..395506f 100644 --- a/.pyproject_generation/pyproject_custom.toml +++ b/.pyproject_generation/pyproject_custom.toml @@ -1,6 +1,6 @@ [project] name = "ghga_datasteward_kit" -version = "4.1.1" +version = "4.1.2" description = "GHGA Data Steward Kit - A utils package for GHGA data stewards." dependencies = [ "crypt4gh >=1.6, <2", diff --git a/pyproject.toml b/pyproject.toml index f729057..43478fd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ classifiers = [ "Intended Audience :: Developers", ] name = "ghga_datasteward_kit" -version = "4.1.1" +version = "4.1.2" description = "GHGA Data Steward Kit - A utils package for GHGA data stewards." dependencies = [ "crypt4gh >=1.6, <2", diff --git a/src/ghga_datasteward_kit/s3_upload/config.py b/src/ghga_datasteward_kit/s3_upload/config.py index 2abd798..227a14e 100644 --- a/src/ghga_datasteward_kit/s3_upload/config.py +++ b/src/ghga_datasteward_kit/s3_upload/config.py @@ -103,7 +103,7 @@ class LegacyConfig(S3ObjectStoragesConfig): default="https://data.ghga.de/.well-known", description="URL to the root of the WKVS API. Should start with https://.", ) - client_timeout: NonNegativeInt = Field( + client_timeout: NonNegativeInt | None = Field( default=60, description="Timeout for client requests in seconds" ) client_num_retries: NonNegativeInt = Field( diff --git a/src/ghga_datasteward_kit/s3_upload/uploader.py b/src/ghga_datasteward_kit/s3_upload/uploader.py index f18186e..bdc8501 100644 --- a/src/ghga_datasteward_kit/s3_upload/uploader.py +++ b/src/ghga_datasteward_kit/s3_upload/uploader.py @@ -162,7 +162,7 @@ async def send_part(self, part: bytes, part_number: int): num_retries = HttpxClientConfig.num_retries timeout = HttpxClientConfig.timeout - while True: + while True and timeout is not None: LOG.info( f"Attempting upload of part {part_number} ({len(part)} bytes) with a timeout of { timeout} seconds." diff --git a/src/ghga_datasteward_kit/s3_upload/utils.py b/src/ghga_datasteward_kit/s3_upload/utils.py index 2531e2e..fa4b206 100644 --- a/src/ghga_datasteward_kit/s3_upload/utils.py +++ b/src/ghga_datasteward_kit/s3_upload/utils.py @@ -34,11 +34,11 @@ class HttpxClientConfig: """Helper for user configurable httpx request parameters.""" - num_retries: int = 5 - timeout: int = 60 + num_retries: int + timeout: int | None @classmethod - def configure(cls, num_retries: int, timeout: int): + def configure(cls, num_retries: int, timeout: int | None): """Set timeout in seconds""" cls.num_retries = num_retries cls.timeout = timeout diff --git a/tests/test_s3_upload.py b/tests/test_s3_upload.py index cf0956a..6c303ad 100644 --- a/tests/test_s3_upload.py +++ b/tests/test_s3_upload.py @@ -26,6 +26,7 @@ from ghga_datasteward_kit.s3_upload import Config, LegacyConfig from ghga_datasteward_kit.s3_upload.entrypoint import async_main, legacy_async_main from ghga_datasteward_kit.s3_upload.utils import ( + HttpxClientConfig, StorageCleaner, get_bucket_id, get_object_storage, @@ -53,6 +54,8 @@ async def test_legacy_process( httpx_mock: HTTPXMock, ): """Test whole upload/download process for s3_upload script""" + HttpxClientConfig.configure(num_retries=5, timeout=60) + with S3ContainerFixture() as container: s3_config = container.s3_config @@ -84,6 +87,7 @@ async def test_legacy_process( @pytest.mark.asyncio async def test_process(config_fixture: Config, monkeypatch, httpx_mock: HTTPXMock): # noqa: F811 """Test whole upload/download process for s3_upload script""" + HttpxClientConfig.configure(num_retries=5, timeout=60) async def secret_exchange_dummy( *,