From 02cddf4d62b19169811ac278f9c3d24a341947a6 Mon Sep 17 00:00:00 2001 From: Austin Walker Date: Mon, 10 Feb 2025 15:31:37 -0500 Subject: [PATCH] fix/NEXUS-777: Fix breaking change in upcoming unstructured-client In the unreleased 0.30.0 of `unstructured-client`, handling of the `server_url` is changing. We need to do this to integrate the platform API functions. Now, different parts of the SDK are talking to different backend services, and so it's preferred that we set the `server_url` per endpoint. Note that for compatibility with the current SDK, we need to strip the `/general/v0/general` path off of the URL. We have logic to do this in the SDK, but in versions before 0.30.0 this doesn't take effect when you pass the URL in the endpoint like this. --- CHANGELOG.md | 6 +++++- unstructured_ingest/__version__.py | 2 +- unstructured_ingest/v2/unstructured_api.py | 14 ++++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e2b1e073..4dd2cbfba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,13 @@ -## 0.5.2-dev0 +## 0.5.2-dev1 ### Enhancements * **Only embed elements with text** - Only embed elements with text to avoid errors from embedders and optimize calls to APIs. +### Fixes + +* **Address forward compatibility issue in unstructured-client** - As of unstructured-client==0.30.0, the `server_url` is passed to the method rather than the client instance. + ## 0.5.1 ### Fixes diff --git a/unstructured_ingest/__version__.py b/unstructured_ingest/__version__.py index f617ee1a1..e42bb33db 100644 --- a/unstructured_ingest/__version__.py +++ b/unstructured_ingest/__version__.py @@ -1 +1 @@ -__version__ = "0.5.2-dev0" # pragma: no cover +__version__ = "0.5.2-dev1" # pragma: no cover diff --git a/unstructured_ingest/v2/unstructured_api.py b/unstructured_ingest/v2/unstructured_api.py index 47b56f3db..1d27573c4 100644 --- a/unstructured_ingest/v2/unstructured_api.py +++ b/unstructured_ingest/v2/unstructured_api.py @@ -87,13 +87,16 @@ async def call_api_async( """ from unstructured_client import UnstructuredClient + # Note(austin) - the sdk takes the base url, but users may pass the full endpoint + # For consistency, strip off the path when it's given + base_url = server_url[:-19] if "/general/v0/general" in server_url else server_url + client = UnstructuredClient( - server_url=server_url, api_key_auth=api_key, ) partition_request = create_partition_request(filename=filename, parameters_dict=api_parameters) try: - res = await client.general.partition_async(request=partition_request) + res = await client.general.partition_async(server_url=base_url, request=partition_request) except Exception as e: raise wrap_error(e) @@ -115,13 +118,16 @@ def call_api( """ from unstructured_client import UnstructuredClient + # Note(austin) - the sdk takes the base url, but users may pass the full endpoint + # For consistency, strip off the path when it's given + base_url = server_url[:-19] if "/general/v0/general" in server_url else server_url + client = UnstructuredClient( - server_url=server_url, api_key_auth=api_key, ) partition_request = create_partition_request(filename=filename, parameters_dict=api_parameters) try: - res = client.general.partition(request=partition_request) + res = client.general.partition(server_url=base_url, request=partition_request) except Exception as e: raise wrap_error(e)