Skip to content

chore: Revert custom handling for multiple Unstructured base urls #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions .genignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ _test_unstructured_client
# ignore Makefile
Makefile

# Ignore the base resource classes while we're patching in our own server url logic
# If we add a new endpoint, we need to:
# - Comment out the ignore for the right file
# Ignore general.py so we can patch in our partitioning url
# If we ever have a new endpoint under /general, we need to:
# - Comment out this ignore line
# - Generate locally, watch the new endpoint appear
# - Adjust the custom url snippets in the file
# - Bring back the ignore line and commit
src/unstructured_client/destinations.py
src/unstructured_client/general.py
src/unstructured_client/jobs.py
src/unstructured_client/sources.py
src/unstructured_client/workflows.py
72 changes: 15 additions & 57 deletions _test_unstructured_client/unit/test_server_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,61 +67,33 @@ class URLTestCase:
"case",
[
URLTestCase(
description="non UNST domain client-level URL, no path",
description="custom client-level URL, no path",
sdk_endpoint_name="general.partition_async",
client_url="http://localhost:8000/",
endpoint_url=None,
expected_url="http://localhost:8000"
),
URLTestCase(
description="non UNST domain client-level URL, with path",
description="custom client-level URL, with path",
sdk_endpoint_name="general.partition_async",
client_url="http://localhost:8000/my/endpoint/",
endpoint_url=None,
expected_url="http://localhost:8000/my/endpoint"
),
URLTestCase(
description="non UNST domain endpoint-level URL, no path",
description="custom endpoint-level URL, no path",
sdk_endpoint_name="general.partition_async",
client_url=None,
endpoint_url="http://localhost:8000/",
expected_url="http://localhost:8000"
),
URLTestCase(
description="non UNST domain endpoint-level URL, with path",
description="custom endpoint-level URL, with path",
sdk_endpoint_name="general.partition_async",
client_url=None,
endpoint_url="http://localhost:8000/my/endpoint/",
expected_url="http://localhost:8000/my/endpoint"
),
URLTestCase(
description="UNST domain client-level URL, no path",
sdk_endpoint_name="general.partition_async",
client_url="https://unstructured-000mock.api.unstructuredapp.io",
endpoint_url=None,
expected_url="https://unstructured-000mock.api.unstructuredapp.io"
),
URLTestCase(
description="UNST domain client-level URL, with path",
sdk_endpoint_name="general.partition_async",
client_url="https://unstructured-000mock.api.unstructuredapp.io/my/endpoint/",
endpoint_url=None,
expected_url="https://unstructured-000mock.api.unstructuredapp.io"
),
URLTestCase(
description="UNST domain endpoint-level URL, no path",
sdk_endpoint_name="general.partition_async",
client_url=None,
endpoint_url="https://unstructured-000mock.api.unstructuredapp.io",
expected_url="https://unstructured-000mock.api.unstructuredapp.io"
),
URLTestCase(
description="UNST domain endpoint-level URL, with path",
sdk_endpoint_name="general.partition_async",
client_url=None,
endpoint_url="https://unstructured-000mock.api.unstructuredapp.io/my/endpoint/",
expected_url="https://unstructured-000mock.api.unstructuredapp.io"
),
URLTestCase(
description="default URL fallback",
sdk_endpoint_name="general.partition_async",
Expand Down Expand Up @@ -161,63 +133,49 @@ async def test_async_endpoint_uses_correct_url(monkeypatch, case: URLTestCase):
"case",
[
URLTestCase(
description="non UNST domain client-level URL, no path",
description="custom client-level URL, no path",
sdk_endpoint_name="destinations.create_destination",
client_url="http://localhost:8000/",
endpoint_url=None,
expected_url="http://localhost:8000"
),
URLTestCase(
description="non UNST domain client-level URL, with path",
description="custom client-level URL, with path",
sdk_endpoint_name="sources.create_source",
client_url="http://localhost:8000/my/endpoint/",
endpoint_url=None,
expected_url="http://localhost:8000/my/endpoint"
),
URLTestCase(
description="non UNST domain endpoint-level URL, no path",
description="custom endpoint-level URL, no path",
sdk_endpoint_name="jobs.get_job",
client_url=None,
endpoint_url="http://localhost:8000",
expected_url="http://localhost:8000"
),
URLTestCase(
description="non UNST domain endpoint-level URL, with path",
description="custom endpoint-level URL, with path",
sdk_endpoint_name="workflows.create_workflow",
client_url=None,
endpoint_url="http://localhost:8000/my/endpoint",
expected_url="http://localhost:8000/my/endpoint"
),
URLTestCase(
description="UNST domain client-level URL, no path",
description="partition client level with path",
sdk_endpoint_name="general.partition",
client_url="https://unstructured-000mock.api.unstructuredapp.io",
client_url="https://api.unstructuredapp.io/general/v0/general",
endpoint_url=None,
expected_url="https://unstructured-000mock.api.unstructuredapp.io"
),
URLTestCase(
description="UNST domain client-level URL, with path",
sdk_endpoint_name="general.partition",
client_url="https://unstructured-000mock.api.unstructuredapp.io/my/endpoint/",
endpoint_url=None,
expected_url="https://unstructured-000mock.api.unstructuredapp.io"
),
URLTestCase(
description="UNST domain endpoint-level URL, no path",
sdk_endpoint_name="general.partition",
client_url=None,
endpoint_url="https://unstructured-000mock.api.unstructuredapp.io",
expected_url="https://unstructured-000mock.api.unstructuredapp.io"
expected_url="https://api.unstructuredapp.io"
),
URLTestCase(
description="UNST domain endpoint-level URL, with path",
description="partition endpoint level with path",
sdk_endpoint_name="general.partition",
client_url=None,
endpoint_url="https://unstructured-000mock.api.unstructuredapp.io/my/endpoint/",
expected_url="https://unstructured-000mock.api.unstructuredapp.io"
endpoint_url="https://api.unstructuredapp.io/general/v0/general",
expected_url="https://api.unstructuredapp.io"
),
URLTestCase(
description="default URL fallback",
description="partition default url",
sdk_endpoint_name="general.partition",
client_url=None,
endpoint_url=None,
Expand Down
7 changes: 0 additions & 7 deletions docs/sdks/destinations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ with UnstructuredClient() as uc_client:
| -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `request` | [operations.CreateConnectionCheckDestinationsRequest](../../models/operations/createconnectioncheckdestinationsrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
| `server_url` | *Optional[str]* | :heavy_minus_sign: | An optional server URL to use. |

### Response

Expand Down Expand Up @@ -93,7 +92,6 @@ with UnstructuredClient() as uc_client:
| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
| `request` | [operations.CreateDestinationRequest](../../models/operations/createdestinationrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
| `server_url` | *Optional[str]* | :heavy_minus_sign: | An optional server URL to use. |

### Response

Expand Down Expand Up @@ -135,7 +133,6 @@ with UnstructuredClient() as uc_client:
| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
| `request` | [operations.DeleteDestinationRequest](../../models/operations/deletedestinationrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
| `server_url` | *Optional[str]* | :heavy_minus_sign: | An optional server URL to use. |

### Response

Expand Down Expand Up @@ -177,7 +174,6 @@ with UnstructuredClient() as uc_client:
| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `request` | [operations.GetConnectionCheckDestinationsRequest](../../models/operations/getconnectioncheckdestinationsrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
| `server_url` | *Optional[str]* | :heavy_minus_sign: | An optional server URL to use. |

### Response

Expand Down Expand Up @@ -219,7 +215,6 @@ with UnstructuredClient() as uc_client:
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
| `request` | [operations.GetDestinationRequest](../../models/operations/getdestinationrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
| `server_url` | *Optional[str]* | :heavy_minus_sign: | An optional server URL to use. |

### Response

Expand Down Expand Up @@ -259,7 +254,6 @@ with UnstructuredClient() as uc_client:
| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| `request` | [operations.ListDestinationsRequest](../../models/operations/listdestinationsrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
| `server_url` | *Optional[str]* | :heavy_minus_sign: | An optional server URL to use. |

### Response

Expand Down Expand Up @@ -311,7 +305,6 @@ with UnstructuredClient() as uc_client:
| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
| `request` | [operations.UpdateDestinationRequest](../../models/operations/updatedestinationrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
| `server_url` | *Optional[str]* | :heavy_minus_sign: | An optional server URL to use. |

### Response

Expand Down
Loading