Skip to content

Commit

Permalink
fix: fix partition_via_api retry mechanism when the default SDK's ret…
Browse files Browse the repository at this point in the history
…ry config is empty. (#3746)
  • Loading branch information
pawel-kmiecik authored Oct 24, 2024
1 parent 0b4c72a commit bdfcc14
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 19 additions & 0 deletions test_unstructured/partition/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion unstructured/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.16.1" # pragma: no cover
__version__ = "0.16.2-dev1" # pragma: no cover
3 changes: 2 additions & 1 deletion unstructured/partition/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down

0 comments on commit bdfcc14

Please sign in to comment.