Skip to content

Commit

Permalink
fix/NEXUS-777: Fix breaking change in upcoming unstructured-client
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
awalker4 committed Feb 10, 2025
1 parent 399854f commit 1b0a8c4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.5.2-dev0

### 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.

### Enhancements

## 0.5.1

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion unstructured_ingest/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.1" # pragma: no cover
__version__ = "0.5.2-dev0" # pragma: no cover
14 changes: 10 additions & 4 deletions unstructured_ingest/v2/unstructured_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down

0 comments on commit 1b0a8c4

Please sign in to comment.