datalab-python-sdk 0.11.0__tar.gz → 0.13.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/CHANGELOG.md +63 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/PKG-INFO +14 -3
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/README.md +13 -2
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/datalab_sdk/__init__.py +4 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/datalab_sdk/client.py +589 -262
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/datalab_sdk/exceptions.py +49 -4
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/datalab_sdk/models.py +19 -2
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/pyproject.toml +1 -1
- datalab_python_sdk-0.13.0/tests/test_results.py +329 -0
- datalab_python_sdk-0.13.0/tests/test_streaming_retries.py +653 -0
- datalab_python_sdk-0.13.0/tests/test_timeout_recovery.py +396 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/uv.lock +1 -1
- datalab_python_sdk-0.11.0/tests/test_results.py +0 -153
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/.github/workflows/ci.yml +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/.gitignore +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/.pre-commit-config.yaml +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/.python-version +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/LICENSE +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/data/08-Lambda-Calculus.pptx +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/data/adversarial.pdf +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/data/bid_evaluation.docx +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/data/book_review.ppt +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/data/book_store.xls +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/data/chi_hind.png +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/data/how_to_read.doc +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/data/normandy.epub +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/data/sample-1-sheet.xlsx +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/data/thinkpython.pdf +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/data/vibe.html +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/datalab_sdk/auth.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/datalab_sdk/cli.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/datalab_sdk/mimetypes.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/datalab_sdk/settings.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/integration/README.md +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/integration/__init__.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/integration/test_live_api.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/integration/test_readme_examples.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/pytest.ini +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/recipes/workflows/README.md +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/recipes/workflows/end_to_end_workflow.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/recipes/workflows/workflow_api_tutorial/1_get_step_types.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/recipes/workflows/workflow_api_tutorial/2_get_workflows.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/recipes/workflows/workflow_api_tutorial/3_create_workflow.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/recipes/workflows/workflow_api_tutorial/4_execute_workflow.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/recipes/workflows/workflow_api_tutorial/5_poll_workflow.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/recipes/workflows/workflow_api_tutorial/README.md +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/recipes/workflows/workflow_definitions/README.md +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/recipes/workflows/workflow_definitions/eval_segmentation.json +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/recipes/workflows/workflow_definitions/parse_segment.json +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/recipes/workflows/workflow_definitions/segment_parallel_extract.json +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/recipes/workflows/workflow_definitions/slack_alert.json +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/tests/__init__.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/tests/conftest.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/tests/test_api_consistency.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/tests/test_cli_options.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/tests/test_cli_simple.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/tests/test_client_methods.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/tests/test_comparisons.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/tests/test_device_login.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/tests/test_errors.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/tests/test_new_endpoints.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/tests/test_progress.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/tests/test_transport_audit.py +0 -0
- {datalab_python_sdk-0.11.0 → datalab_python_sdk-0.13.0}/tests/test_workflows.py +0 -0
|
@@ -3,6 +3,69 @@
|
|
|
3
3
|
The newest release is at the top. Each export to this repository uses the
|
|
4
4
|
top section as its commit message.
|
|
5
5
|
|
|
6
|
+
## 0.13.0
|
|
7
|
+
|
|
8
|
+
New:
|
|
9
|
+
|
|
10
|
+
- `get_result()` fetches the result of a request that was already
|
|
11
|
+
submitted, without submitting the document again. Pass the check URL, or a
|
|
12
|
+
request ID and its `endpoint`. It returns the same result type as the
|
|
13
|
+
method that submitted the request, and accepts `save_output`,
|
|
14
|
+
`stream_response_to`, `max_polls`, `poll_interval` and `on_progress`.
|
|
15
|
+
- An error that a document-processing method or `get_result()` raises after
|
|
16
|
+
the API accepted the request has `request_id` and `check_url`. Before, a
|
|
17
|
+
timeout or failure gave no way to find the running request, which kept
|
|
18
|
+
running and was charged. For `run_pipeline()`, `request_id` holds the
|
|
19
|
+
execution ID; resume with `get_pipeline_execution()`.
|
|
20
|
+
- `DatalabPollingTimeoutError`: the polling budget ran out and the request
|
|
21
|
+
is still running. It has the `status` and `progress_percent` of the last
|
|
22
|
+
poll.
|
|
23
|
+
- `DatalabTransferTimeoutError`: the request finished, but its result timed
|
|
24
|
+
out while it downloaded.
|
|
25
|
+
|
|
26
|
+
Both subclass `DatalabTimeoutError`, so existing `except` clauses still
|
|
27
|
+
catch them.
|
|
28
|
+
|
|
29
|
+
Fixed:
|
|
30
|
+
|
|
31
|
+
- With `stream_response_to`, a signed `result_url` download that timed out
|
|
32
|
+
was retried with the poll, up to 10 polls and 10 downloads, even with
|
|
33
|
+
`max_polls=1`. With the default timeout, that could take about an hour
|
|
34
|
+
before an error. It now raises `DatalabTransferTimeoutError` at once, as
|
|
35
|
+
the call without `stream_response_to` does.
|
|
36
|
+
|
|
37
|
+
## 0.12.0
|
|
38
|
+
|
|
39
|
+
New:
|
|
40
|
+
|
|
41
|
+
- `FileResult`, the result of a call with `stream_response_to`, now has
|
|
42
|
+
`request_id`, `page_count`, `parse_quality_score`, `versions`, `runtime`,
|
|
43
|
+
and `cost_breakdown`. They come from the poll response and are `None` when
|
|
44
|
+
it does not send them; `request_id` falls back to the submit response. For
|
|
45
|
+
a result from a signed `result_url`, the poll response has no `versions`,
|
|
46
|
+
and `runtime` or cost can be unset on an early poll. The saved file can
|
|
47
|
+
contain `versions` and `runtime`.
|
|
48
|
+
|
|
49
|
+
Fixed:
|
|
50
|
+
|
|
51
|
+
- With `stream_response_to`, a result from a signed `result_url` (for example
|
|
52
|
+
with `processing_location`) lost the cost, page count and quality score,
|
|
53
|
+
because the download does not contain them. `FileResult` now returns them
|
|
54
|
+
from the poll response. The download is still copied to disk without
|
|
55
|
+
parsing.
|
|
56
|
+
- With `stream_response_to`, a connection that dropped while the result
|
|
57
|
+
streamed ended the call without a retry. The SDK now retries the poll as it
|
|
58
|
+
does for other poll errors; it does not submit the document again. An error
|
|
59
|
+
response whose body is cut off or stalls keeps its HTTP status, so a 404
|
|
60
|
+
still fails at once.
|
|
61
|
+
- With `stream_response_to`, a timeout while the result streamed surfaced as
|
|
62
|
+
a raw `asyncio.CancelledError`. It now raises `DatalabTimeoutError`. As
|
|
63
|
+
before, it is not retried: `timeout` limits the whole request, so a result
|
|
64
|
+
too large to transfer within it would time out again.
|
|
65
|
+
- Without `stream_response_to`, a failed download of a signed `result_url` is
|
|
66
|
+
now retried on a connection error or HTTP 408, 429 or 5xx, and honors
|
|
67
|
+
`Retry-After`. A timeout, or an expired URL (HTTP 403), still fails at once.
|
|
68
|
+
|
|
6
69
|
## 0.11.0
|
|
7
70
|
|
|
8
71
|
Comparisons (open beta):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: datalab-python-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
4
4
|
Summary: SDK for the Datalab document intelligence API
|
|
5
5
|
Project-URL: Homepage, https://www.datalab.to
|
|
6
6
|
Project-URL: Documentation, https://documentation.datalab.to
|
|
@@ -182,8 +182,19 @@ Published-agent execution is in open beta; the API may change. Processor design
|
|
|
182
182
|
## Inputs, polling and errors
|
|
183
183
|
|
|
184
184
|
- Send a local file with `file_path`, or a URL or a `datalab://file-...` reference with `file_url`. When you set `processing_location`, send the document as `file_url`.
|
|
185
|
-
- Processing methods poll until the result is ready. The first 8 seconds poll every 0.3 seconds. Set `max_polls` and `poll_interval` to change the limit (default: 300 polls, 1 second apart). Use `stream_response_to` to write a large result straight to disk.
|
|
186
|
-
- The SDK retries a submission that gets HTTP 429 or 503, and polls that get 408, 429, 5xx or a connection error. It waits for the `Retry-After` header when the API sends one.
|
|
185
|
+
- Processing methods poll until the result is ready. The first 8 seconds poll every 0.3 seconds. Set `max_polls` and `poll_interval` to change the limit (default: 300 polls, 1 second apart). Use `stream_response_to` to write a large result straight to disk. It returns a `FileResult` with the status, `output_path` and, when the poll response sends them, `request_id`, `page_count`, `parse_quality_score`, `versions`, `runtime` and `cost_breakdown`.
|
|
186
|
+
- The SDK retries a submission that gets HTTP 429 or 503, and polls or result downloads that get 408, 429, 5xx or a connection error, including one that happens while a result streams. It tries each request at most 10 times, and waits for the `Retry-After` header when the API sends one. `timeout` applies to each request, including the whole download of a result. A finished result that times out while it downloads from a signed `result_url`, or streams with `stream_response_to`, is not retried.
|
|
187
|
+
- Timeouts raise `DatalabTimeoutError`. `DatalabPollingTimeoutError` means the polling budget ran out and the request is still running; `DatalabTransferTimeoutError` means the request finished but its result timed out while it downloaded, so raise `timeout` before you fetch it again. An error that a document-processing method raises after the API accepted the request has `request_id` and `check_url`. Pass `check_url` to `get_result()` to fetch the result without submitting the document again. For `run_pipeline()`, `request_id` holds the execution ID for `get_pipeline_execution()`.
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
from datalab_sdk import DatalabClient, DatalabPollingTimeoutError
|
|
191
|
+
|
|
192
|
+
client = DatalabClient()
|
|
193
|
+
try:
|
|
194
|
+
result = client.convert("big.pdf", max_polls=60)
|
|
195
|
+
except DatalabPollingTimeoutError as e:
|
|
196
|
+
result = client.get_result(e.check_url, max_polls=600)
|
|
197
|
+
```
|
|
187
198
|
- API errors raise `DatalabAPIError` (with `status_code` and `response_data`) or one of its subclasses: `DatalabAuthenticationError` (401, 403), `DatalabPaymentRequiredError` (402), `DatalabNotFoundError` (404), `DatalabRateLimitError` (429) and `DatalabServerError` (5xx). Invalid arguments raise `DatalabValidationError`, which is also a `ValueError`.
|
|
188
199
|
|
|
189
200
|
With SDK 0.9.0, `upload_files(paths, max_concurrency=5)` streams
|
|
@@ -161,8 +161,19 @@ Published-agent execution is in open beta; the API may change. Processor design
|
|
|
161
161
|
## Inputs, polling and errors
|
|
162
162
|
|
|
163
163
|
- Send a local file with `file_path`, or a URL or a `datalab://file-...` reference with `file_url`. When you set `processing_location`, send the document as `file_url`.
|
|
164
|
-
- Processing methods poll until the result is ready. The first 8 seconds poll every 0.3 seconds. Set `max_polls` and `poll_interval` to change the limit (default: 300 polls, 1 second apart). Use `stream_response_to` to write a large result straight to disk.
|
|
165
|
-
- The SDK retries a submission that gets HTTP 429 or 503, and polls that get 408, 429, 5xx or a connection error. It waits for the `Retry-After` header when the API sends one.
|
|
164
|
+
- Processing methods poll until the result is ready. The first 8 seconds poll every 0.3 seconds. Set `max_polls` and `poll_interval` to change the limit (default: 300 polls, 1 second apart). Use `stream_response_to` to write a large result straight to disk. It returns a `FileResult` with the status, `output_path` and, when the poll response sends them, `request_id`, `page_count`, `parse_quality_score`, `versions`, `runtime` and `cost_breakdown`.
|
|
165
|
+
- The SDK retries a submission that gets HTTP 429 or 503, and polls or result downloads that get 408, 429, 5xx or a connection error, including one that happens while a result streams. It tries each request at most 10 times, and waits for the `Retry-After` header when the API sends one. `timeout` applies to each request, including the whole download of a result. A finished result that times out while it downloads from a signed `result_url`, or streams with `stream_response_to`, is not retried.
|
|
166
|
+
- Timeouts raise `DatalabTimeoutError`. `DatalabPollingTimeoutError` means the polling budget ran out and the request is still running; `DatalabTransferTimeoutError` means the request finished but its result timed out while it downloaded, so raise `timeout` before you fetch it again. An error that a document-processing method raises after the API accepted the request has `request_id` and `check_url`. Pass `check_url` to `get_result()` to fetch the result without submitting the document again. For `run_pipeline()`, `request_id` holds the execution ID for `get_pipeline_execution()`.
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
from datalab_sdk import DatalabClient, DatalabPollingTimeoutError
|
|
170
|
+
|
|
171
|
+
client = DatalabClient()
|
|
172
|
+
try:
|
|
173
|
+
result = client.convert("big.pdf", max_polls=60)
|
|
174
|
+
except DatalabPollingTimeoutError as e:
|
|
175
|
+
result = client.get_result(e.check_url, max_polls=600)
|
|
176
|
+
```
|
|
166
177
|
- API errors raise `DatalabAPIError` (with `status_code` and `response_data`) or one of its subclasses: `DatalabAuthenticationError` (401, 403), `DatalabPaymentRequiredError` (402), `DatalabNotFoundError` (404), `DatalabRateLimitError` (429) and `DatalabServerError` (5xx). Invalid arguments raise `DatalabValidationError`, which is also a `ValueError`.
|
|
167
178
|
|
|
168
179
|
With SDK 0.9.0, `upload_files(paths, max_concurrency=5)` streams
|
|
@@ -15,6 +15,8 @@ from .exceptions import (
|
|
|
15
15
|
DatalabRateLimitError,
|
|
16
16
|
DatalabServerError,
|
|
17
17
|
DatalabTimeoutError,
|
|
18
|
+
DatalabTransferTimeoutError,
|
|
19
|
+
DatalabPollingTimeoutError,
|
|
18
20
|
DatalabFileError,
|
|
19
21
|
DatalabValidationError,
|
|
20
22
|
)
|
|
@@ -86,6 +88,8 @@ __all__ = [
|
|
|
86
88
|
"DatalabRateLimitError",
|
|
87
89
|
"DatalabServerError",
|
|
88
90
|
"DatalabTimeoutError",
|
|
91
|
+
"DatalabTransferTimeoutError",
|
|
92
|
+
"DatalabPollingTimeoutError",
|
|
89
93
|
"DatalabFileError",
|
|
90
94
|
"DatalabValidationError",
|
|
91
95
|
"ConversionResult",
|