Skip to content
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 0.26.1

### Enhancements

### Features

### Fixes
* Use the configured server_url for our split page "dummy" request

## 0.26.0

### Enhancements
Expand Down
6 changes: 4 additions & 2 deletions _test_unstructured_client/integration/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,14 @@ async def mock_send(_, request: httpx.Request, **kwargs):

We want to make sure both code paths are retried.
"""
# Assert that the SDK issues our no-op request
# Assert that the SDK issues our dummy request
# returned by the BeforeRequestHook
nonlocal mock_endpoint_called
if request.url.host == "no-op" or "docs" in request.url.path:
if request.url.host == "localhost" and "docs" in request.url.path:
mock_endpoint_called = True
return Response(200, request=request)
elif "docs" in request.url.path:
assert False, "The server URL was not set in the dummy request"

request_body = request.read()

Expand Down
2 changes: 1 addition & 1 deletion gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ generation:
auth:
oAuth2ClientCredentialsEnabled: false
python:
version: 0.26.0
version: 0.26.1
additionalDependencies:
dev:
deepdiff: '>=6.0'
Expand Down
6 changes: 5 additions & 1 deletion src/unstructured_client/_hooks/custom/split_pdf_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class SplitPdfHook(SDKInitHook, BeforeRequestHook, AfterSuccessHook, AfterErrorH

def __init__(self) -> None:
self.client: Optional[HttpClient] = None
self.base_url: Optional[str] = None
self.async_client: Optional[AsyncHttpClient] = None
self.coroutines_to_execute: dict[
str, list[Coroutine[Any, Any, httpx.Response]]
Expand Down Expand Up @@ -156,6 +157,9 @@ def handle_request(self, request: httpx.Request) -> httpx.Response:
# # Otherwise, pass the request to the default transport
# return await self.base_transport.handle_async_request(request)

# Instead, save the base url so we can use it for our dummy request
self.base_url = base_url

# Explicit cast to httpx.Client to avoid a typing error
httpx_client = cast(httpx.Client, client)
# async_httpx_client = cast(httpx.AsyncClient, async_client)
Expand Down Expand Up @@ -346,7 +350,7 @@ async def call_api_partial(page):
# dummy_request = httpx.Request("GET", "http://no-op")
return httpx.Request(
"GET",
"https://api.unstructuredapp.io/general/docs",
f"{self.base_url}/general/docs",
headers={"operation_id": operation_id},
)

Expand Down