From bdfcc14e3d2bdfe1916ddae251254bf587463d40 Mon Sep 17 00:00:00 2001 From: Pawel Kmiecik Date: Thu, 24 Oct 2024 11:37:22 +0200 Subject: [PATCH] fix: fix partition_via_api retry mechanism when the default SDK's retry config is empty. (#3746) --- CHANGELOG.md | 10 ++++++++++ test_unstructured/partition/test_api.py | 19 +++++++++++++++++++ unstructured/__version__.py | 2 +- unstructured/partition/api.py | 3 ++- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a76eedf888..5f062d1004 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 0.16.2-dev1 + +### Enhancements + +### Features + +### Fixes + +## **Fixed retry config settings for partition_via_api function** If the SDK's default retry config is not set the retry config getter function does not fail anymore. + ## 0.16.1 ### Enhancements diff --git a/test_unstructured/partition/test_api.py b/test_unstructured/partition/test_api.py index 6cb632315b..169f63bd6b 100644 --- a/test_unstructured/partition/test_api.py +++ b/test_unstructured/partition/test_api.py @@ -246,6 +246,25 @@ def test_retries_config_none_parameters_return_empty_config(): assert retries_config is None +def test_retry_config_with_empty_sdk_retry_config_returns_default(): + sdk = Mock() + sdk.sdk_configuration.retry_config = None + retries_config = get_retries_config( + retries_connection_errors=True, + retries_exponent=1.88, + retries_initial_interval=3000, + retries_max_elapsed_time=None, + retries_max_interval=None, + sdk=sdk, + ) + + assert retries_config.retry_connection_errors + assert retries_config.backoff.exponent == 1.88 + assert retries_config.backoff.initial_interval == 3000 + assert retries_config.backoff.max_elapsed_time == DEFAULT_RETRIES_MAX_ELAPSED_TIME_SEC + assert retries_config.backoff.max_interval == DEFAULT_RETRIES_MAX_INTERVAL_SEC + + def test_retries_config_with_no_parameters_set(): retry_config = retries.RetryConfig( "backoff", retries.BackoffStrategy(3000, 720000, 1.88, 1800000), True diff --git a/unstructured/__version__.py b/unstructured/__version__.py index f43e518484..ce553d47b1 100644 --- a/unstructured/__version__.py +++ b/unstructured/__version__.py @@ -1 +1 @@ -__version__ = "0.16.1" # pragma: no cover +__version__ = "0.16.2-dev1" # pragma: no cover diff --git a/unstructured/partition/api.py b/unstructured/partition/api.py index 7cd8f9dfc7..ee5ad4da8a 100644 --- a/unstructured/partition/api.py +++ b/unstructured/partition/api.py @@ -195,7 +195,8 @@ def get_backoff_default(setting_name: str, default_value: Any) -> Any: default_retries_connneciton_errors = ( sdk_default_retries_config.retry_connection_errors - if sdk_default_retries_config.retry_connection_errors is not None + if sdk_default_retries_config + and sdk_default_retries_config.retry_connection_errors is not None else DEFAULT_RETRIES_CONNECTION_ERRORS )