Skip to content

Commit 801c4a0

Browse files
feat(api): manual updates
1 parent 19fa5e7 commit 801c4a0

3 files changed

Lines changed: 28 additions & 42 deletions

File tree

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 2
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/landingai%2Fade-f08049b74d593128128837d1e62b642bf68ee132184fddadc45d19fbc6d9f263.yml
33
openapi_spec_hash: 1cf6912d5249120cb222db3890587aab
4-
config_hash: b5cab0bc5fca3bf0bcf2cd89cfe1b134
4+
config_hash: 5cb437dd50d7cfb93e1a7d70a825794e

README.md

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,7 @@ from landingai_ade import LandingAIADE
172172
client = LandingAIADE()
173173

174174
try:
175-
client.extract(
176-
schema="schema",
177-
)
175+
client.parse()
178176
except landingai_ade.APIConnectionError as e:
179177
print("The server could not be reached")
180178
print(e.__cause__) # an underlying Exception, likely raised within httpx.
@@ -217,9 +215,7 @@ client = LandingAIADE(
217215
)
218216

219217
# Or, configure per-request:
220-
client.with_options(max_retries=5).extract(
221-
schema="schema",
222-
)
218+
client.with_options(max_retries=5).parse()
223219
```
224220

225221
### Timeouts
@@ -242,9 +238,7 @@ client = LandingAIADE(
242238
)
243239

244240
# Override per-request:
245-
client.with_options(timeout=5.0).extract(
246-
schema="schema",
247-
)
241+
client.with_options(timeout=5.0).parse()
248242
```
249243

250244
On timeout, an `APITimeoutError` is thrown.
@@ -285,13 +279,11 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
285279
from landingai_ade import LandingAIADE
286280

287281
client = LandingAIADE()
288-
response = client.with_raw_response.extract(
289-
schema="schema",
290-
)
282+
response = client.with_raw_response.parse()
291283
print(response.headers.get('X-My-Header'))
292284

293-
client = response.parse() # get the object that `extract()` would have returned
294-
print(client.extraction)
285+
client = response.parse() # get the object that `parse()` would have returned
286+
print(client.chunks)
295287
```
296288

297289
These methods return an [`APIResponse`](https://github.com/landing-ai/ade-python/tree/main/src/landingai_ade/_response.py) object.
@@ -305,9 +297,7 @@ The above interface eagerly reads the full response body when you make the reque
305297
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
306298

307299
```python
308-
with client.with_streaming_response.extract(
309-
schema="schema",
310-
) as response:
300+
with client.with_streaming_response.parse() as response:
311301
print(response.headers.get("X-My-Header"))
312302

313303
for line in response.iter_lines():

tests/test_client.py

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -732,20 +732,20 @@ def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str
732732
@mock.patch("landingai_ade._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
733733
@pytest.mark.respx(base_url=base_url)
734734
def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, client: LandingAIADE) -> None:
735-
respx_mock.post("/v1/ade/extract").mock(side_effect=httpx.TimeoutException("Test timeout error"))
735+
respx_mock.post("/v1/ade/parse").mock(side_effect=httpx.TimeoutException("Test timeout error"))
736736

737737
with pytest.raises(APITimeoutError):
738-
client.with_streaming_response.extract(schema="schema").__enter__()
738+
client.with_streaming_response.parse().__enter__()
739739

740740
assert _get_open_connections(self.client) == 0
741741

742742
@mock.patch("landingai_ade._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
743743
@pytest.mark.respx(base_url=base_url)
744744
def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client: LandingAIADE) -> None:
745-
respx_mock.post("/v1/ade/extract").mock(return_value=httpx.Response(500))
745+
respx_mock.post("/v1/ade/parse").mock(return_value=httpx.Response(500))
746746

747747
with pytest.raises(APIStatusError):
748-
client.with_streaming_response.extract(schema="schema").__enter__()
748+
client.with_streaming_response.parse().__enter__()
749749
assert _get_open_connections(self.client) == 0
750750

751751
@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@@ -772,9 +772,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
772772
return httpx.Response(500)
773773
return httpx.Response(200)
774774

775-
respx_mock.post("/v1/ade/extract").mock(side_effect=retry_handler)
775+
respx_mock.post("/v1/ade/parse").mock(side_effect=retry_handler)
776776

777-
response = client.with_raw_response.extract(schema="schema")
777+
response = client.with_raw_response.parse()
778778

779779
assert response.retries_taken == failures_before_success
780780
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
@@ -796,9 +796,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
796796
return httpx.Response(500)
797797
return httpx.Response(200)
798798

799-
respx_mock.post("/v1/ade/extract").mock(side_effect=retry_handler)
799+
respx_mock.post("/v1/ade/parse").mock(side_effect=retry_handler)
800800

801-
response = client.with_raw_response.extract(schema="schema", extra_headers={"x-stainless-retry-count": Omit()})
801+
response = client.with_raw_response.parse(extra_headers={"x-stainless-retry-count": Omit()})
802802

803803
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
804804

@@ -819,9 +819,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
819819
return httpx.Response(500)
820820
return httpx.Response(200)
821821

822-
respx_mock.post("/v1/ade/extract").mock(side_effect=retry_handler)
822+
respx_mock.post("/v1/ade/parse").mock(side_effect=retry_handler)
823823

824-
response = client.with_raw_response.extract(schema="schema", extra_headers={"x-stainless-retry-count": "42"})
824+
response = client.with_raw_response.parse(extra_headers={"x-stainless-retry-count": "42"})
825825

826826
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
827827

@@ -1559,10 +1559,10 @@ async def test_parse_retry_after_header(self, remaining_retries: int, retry_afte
15591559
async def test_retrying_timeout_errors_doesnt_leak(
15601560
self, respx_mock: MockRouter, async_client: AsyncLandingAIADE
15611561
) -> None:
1562-
respx_mock.post("/v1/ade/extract").mock(side_effect=httpx.TimeoutException("Test timeout error"))
1562+
respx_mock.post("/v1/ade/parse").mock(side_effect=httpx.TimeoutException("Test timeout error"))
15631563

15641564
with pytest.raises(APITimeoutError):
1565-
await async_client.with_streaming_response.extract(schema="schema").__aenter__()
1565+
await async_client.with_streaming_response.parse().__aenter__()
15661566

15671567
assert _get_open_connections(self.client) == 0
15681568

@@ -1571,10 +1571,10 @@ async def test_retrying_timeout_errors_doesnt_leak(
15711571
async def test_retrying_status_errors_doesnt_leak(
15721572
self, respx_mock: MockRouter, async_client: AsyncLandingAIADE
15731573
) -> None:
1574-
respx_mock.post("/v1/ade/extract").mock(return_value=httpx.Response(500))
1574+
respx_mock.post("/v1/ade/parse").mock(return_value=httpx.Response(500))
15751575

15761576
with pytest.raises(APIStatusError):
1577-
await async_client.with_streaming_response.extract(schema="schema").__aenter__()
1577+
await async_client.with_streaming_response.parse().__aenter__()
15781578
assert _get_open_connections(self.client) == 0
15791579

15801580
@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@@ -1602,9 +1602,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
16021602
return httpx.Response(500)
16031603
return httpx.Response(200)
16041604

1605-
respx_mock.post("/v1/ade/extract").mock(side_effect=retry_handler)
1605+
respx_mock.post("/v1/ade/parse").mock(side_effect=retry_handler)
16061606

1607-
response = await client.with_raw_response.extract(schema="schema")
1607+
response = await client.with_raw_response.parse()
16081608

16091609
assert response.retries_taken == failures_before_success
16101610
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
@@ -1627,11 +1627,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
16271627
return httpx.Response(500)
16281628
return httpx.Response(200)
16291629

1630-
respx_mock.post("/v1/ade/extract").mock(side_effect=retry_handler)
1630+
respx_mock.post("/v1/ade/parse").mock(side_effect=retry_handler)
16311631

1632-
response = await client.with_raw_response.extract(
1633-
schema="schema", extra_headers={"x-stainless-retry-count": Omit()}
1634-
)
1632+
response = await client.with_raw_response.parse(extra_headers={"x-stainless-retry-count": Omit()})
16351633

16361634
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
16371635

@@ -1653,11 +1651,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
16531651
return httpx.Response(500)
16541652
return httpx.Response(200)
16551653

1656-
respx_mock.post("/v1/ade/extract").mock(side_effect=retry_handler)
1654+
respx_mock.post("/v1/ade/parse").mock(side_effect=retry_handler)
16571655

1658-
response = await client.with_raw_response.extract(
1659-
schema="schema", extra_headers={"x-stainless-retry-count": "42"}
1660-
)
1656+
response = await client.with_raw_response.parse(extra_headers={"x-stainless-retry-count": "42"})
16611657

16621658
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
16631659

0 commit comments

Comments
 (0)