Skip to content

Commit 02cddf4

Browse files
committed
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.
1 parent 56e69a4 commit 02cddf4

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
## 0.5.2-dev0
1+
## 0.5.2-dev1
22

33
### Enhancements
44

55
* **Only embed elements with text** - Only embed elements with text to avoid errors from embedders and optimize calls to APIs.
66

7+
### Fixes
8+
9+
* **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.
10+
711
## 0.5.1
812

913
### Fixes

unstructured_ingest/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.5.2-dev0" # pragma: no cover
1+
__version__ = "0.5.2-dev1" # pragma: no cover

unstructured_ingest/v2/unstructured_api.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,16 @@ async def call_api_async(
8787
"""
8888
from unstructured_client import UnstructuredClient
8989

90+
# Note(austin) - the sdk takes the base url, but users may pass the full endpoint
91+
# For consistency, strip off the path when it's given
92+
base_url = server_url[:-19] if "/general/v0/general" in server_url else server_url
93+
9094
client = UnstructuredClient(
91-
server_url=server_url,
9295
api_key_auth=api_key,
9396
)
9497
partition_request = create_partition_request(filename=filename, parameters_dict=api_parameters)
9598
try:
96-
res = await client.general.partition_async(request=partition_request)
99+
res = await client.general.partition_async(server_url=base_url, request=partition_request)
97100
except Exception as e:
98101
raise wrap_error(e)
99102

@@ -115,13 +118,16 @@ def call_api(
115118
"""
116119
from unstructured_client import UnstructuredClient
117120

121+
# Note(austin) - the sdk takes the base url, but users may pass the full endpoint
122+
# For consistency, strip off the path when it's given
123+
base_url = server_url[:-19] if "/general/v0/general" in server_url else server_url
124+
118125
client = UnstructuredClient(
119-
server_url=server_url,
120126
api_key_auth=api_key,
121127
)
122128
partition_request = create_partition_request(filename=filename, parameters_dict=api_parameters)
123129
try:
124-
res = client.general.partition(request=partition_request)
130+
res = client.general.partition(server_url=base_url, request=partition_request)
125131
except Exception as e:
126132
raise wrap_error(e)
127133

0 commit comments

Comments
 (0)