datalab-python-sdk 0.7.1__tar.gz → 0.9.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.7.1 → datalab_python_sdk-0.9.0}/CHANGELOG.md +34 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/PKG-INFO +55 -2
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/README.md +54 -1
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/datalab_sdk/__init__.py +4 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/datalab_sdk/client.py +344 -24
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/datalab_sdk/models.py +65 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/pyproject.toml +4 -1
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/tests/test_api_consistency.py +10 -0
- datalab_python_sdk-0.9.0/tests/test_progress.py +319 -0
- datalab_python_sdk-0.9.0/tests/test_transport_audit.py +346 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/uv.lock +8 -4
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/.github/workflows/ci.yml +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/.gitignore +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/.pre-commit-config.yaml +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/.python-version +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/LICENSE +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/data/08-Lambda-Calculus.pptx +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/data/adversarial.pdf +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/data/bid_evaluation.docx +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/data/book_review.ppt +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/data/book_store.xls +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/data/chi_hind.png +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/data/how_to_read.doc +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/data/normandy.epub +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/data/sample-1-sheet.xlsx +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/data/thinkpython.pdf +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/data/vibe.html +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/datalab_sdk/auth.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/datalab_sdk/cli.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/datalab_sdk/exceptions.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/datalab_sdk/mimetypes.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/datalab_sdk/settings.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/integration/README.md +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/integration/__init__.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/integration/test_live_api.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/integration/test_readme_examples.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/pytest.ini +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/recipes/workflows/README.md +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/recipes/workflows/end_to_end_workflow.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/recipes/workflows/workflow_api_tutorial/1_get_step_types.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/recipes/workflows/workflow_api_tutorial/2_get_workflows.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/recipes/workflows/workflow_api_tutorial/3_create_workflow.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/recipes/workflows/workflow_api_tutorial/4_execute_workflow.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/recipes/workflows/workflow_api_tutorial/5_poll_workflow.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/recipes/workflows/workflow_api_tutorial/README.md +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/recipes/workflows/workflow_definitions/README.md +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/recipes/workflows/workflow_definitions/eval_segmentation.json +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/recipes/workflows/workflow_definitions/parse_segment.json +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/recipes/workflows/workflow_definitions/segment_parallel_extract.json +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/recipes/workflows/workflow_definitions/slack_alert.json +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/tests/__init__.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/tests/conftest.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/tests/test_cli_options.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/tests/test_cli_simple.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/tests/test_client_methods.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/tests/test_device_login.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/tests/test_errors.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/tests/test_new_endpoints.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/tests/test_results.py +0 -0
- {datalab_python_sdk-0.7.1 → datalab_python_sdk-0.9.0}/tests/test_workflows.py +0 -0
|
@@ -3,6 +3,40 @@
|
|
|
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.9.0
|
|
7
|
+
|
|
8
|
+
New:
|
|
9
|
+
|
|
10
|
+
- **Open beta:** `redact()` and `get_redaction_presets()` on both clients,
|
|
11
|
+
with `RedactOptions` and `RedactResult`. Results preserve the verification
|
|
12
|
+
verdict and failed checks, including when a completed run returns an
|
|
13
|
+
available PDF with failed verification. Regional signed results use the same
|
|
14
|
+
verified result contract. Use save_output to save the PDF; streaming redaction
|
|
15
|
+
results is not supported. The redaction API may change.
|
|
16
|
+
- `upload_files(..., max_concurrency=5)` bounds active uploads, streams
|
|
17
|
+
files from disk, and reuses storage connections within a batch. Results
|
|
18
|
+
retain input order. Uploads respect the configured request timeout.
|
|
19
|
+
|
|
20
|
+
Fixed:
|
|
21
|
+
|
|
22
|
+
- Synchronous calls propagate an operation's `RuntimeError` without attempting
|
|
23
|
+
to rerun its coroutine. Calling the synchronous client inside an active event
|
|
24
|
+
loop now directs callers to `AsyncDatalabClient`.
|
|
25
|
+
|
|
26
|
+
## 0.8.0
|
|
27
|
+
|
|
28
|
+
New:
|
|
29
|
+
|
|
30
|
+
- Optional `on_progress` callbacks on synchronous and asynchronous document
|
|
31
|
+
processing helpers and pipeline polling. Callbacks receive increasing overall
|
|
32
|
+
percentages from existing polls; async callbacks are also supported. Missing
|
|
33
|
+
percentages are skipped, and 100 is reported only after successful completion
|
|
34
|
+
and any signed-result download. Callback exceptions propagate to the caller.
|
|
35
|
+
- Optional `progress_percent` on processing results, streamed `FileResult`,
|
|
36
|
+
pipeline executions and execution steps. Percentages are estimates, may be
|
|
37
|
+
unavailable, and are not an ETA or a replacement for status and success.
|
|
38
|
+
- Existing polling intervals and request counts are unchanged.
|
|
39
|
+
|
|
6
40
|
## 0.7.1
|
|
7
41
|
|
|
8
42
|
Fixed:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: datalab-python-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.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
|
|
@@ -63,6 +63,32 @@ print(result.markdown)
|
|
|
63
63
|
|
|
64
64
|
`AsyncDatalabClient` has the same methods as `DatalabClient`, as coroutines.
|
|
65
65
|
|
|
66
|
+
## Progress callbacks
|
|
67
|
+
|
|
68
|
+
With SDK 0.8.0 or later, pass `on_progress` to processing calls:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
result = client.convert(
|
|
72
|
+
"document.pdf",
|
|
73
|
+
on_progress=lambda percent: print(f"Processing: {percent}%"),
|
|
74
|
+
)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The same argument works with `extract`, `segment`, `run_agent`, `track_changes`,
|
|
78
|
+
`create_document`, `ocr`, `fill`, and `form_fields`, including `stream_response_to`.
|
|
79
|
+
`run_pipeline` and `get_pipeline_execution` also support it; set `max_polls`
|
|
80
|
+
above 1 to keep polling a pipeline. Result models expose `progress_percent`
|
|
81
|
+
when the API supplies it.
|
|
82
|
+
|
|
83
|
+
Callbacks receive increasing integer percentages from existing polls, skipping
|
|
84
|
+
missing values and duplicates. Percentages may pause or jump and are not an ETA.
|
|
85
|
+
A callback receives 100 only after successful completion and any signed-result
|
|
86
|
+
download. Check the returned status and success to determine the outcome.
|
|
87
|
+
`AsyncDatalabClient` also accepts async callbacks, which it awaits. Keep callbacks
|
|
88
|
+
short: they run inline, and their exceptions propagate to your call. Callback
|
|
89
|
+
errors stop local polling; they do not cancel the server request. No extra API
|
|
90
|
+
requests are made, and polling intervals are unchanged.
|
|
91
|
+
|
|
66
92
|
## Conversion options
|
|
67
93
|
|
|
68
94
|
```python
|
|
@@ -99,6 +125,30 @@ print(result.extraction_schema_json, result.extraction_score_average)
|
|
|
99
125
|
|
|
100
126
|
When you do not set the parse `mode`, the API picks the parse mode that matches `extraction_mode`.
|
|
101
127
|
|
|
128
|
+
## Redaction
|
|
129
|
+
|
|
130
|
+
**Open beta (SDK 0.9.0):** the redaction API may change.
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from datalab_sdk import RedactOptions
|
|
134
|
+
|
|
135
|
+
result = client.redact(
|
|
136
|
+
"document.pdf",
|
|
137
|
+
options=RedactOptions(preset="personal_information"),
|
|
138
|
+
)
|
|
139
|
+
# A PDF can be returned even when verification fails. Review these first.
|
|
140
|
+
print(result.verdict, result.failing_checks)
|
|
141
|
+
if result.success and result.verdict == "PASS" and not result.withheld and result.output_base64:
|
|
142
|
+
result.save_output("redacted.pdf")
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`get_redaction_presets()` returns the built-in preset IDs and specifications.
|
|
146
|
+
Use `redaction_spec` to supply a custom spec. Redaction processes the whole
|
|
147
|
+
PDF or image; page subsets are not supported. Completed requests are charged
|
|
148
|
+
even if verification fails. `save_output` on `redact()` saves any available
|
|
149
|
+
PDF, including one with failed verification. Redaction returns a typed result;
|
|
150
|
+
`stream_response_to` is not supported for this helper.
|
|
151
|
+
|
|
102
152
|
## Other endpoints
|
|
103
153
|
|
|
104
154
|
| Method | Endpoint |
|
|
@@ -109,7 +159,6 @@ When you do not set the parse `mode`, the API picks the parse mode that matches
|
|
|
109
159
|
| `form_fields()` | Find the fillable fields in a PDF or image |
|
|
110
160
|
| `track_changes()` | Read tracked changes and comments from DOCX or PDF |
|
|
111
161
|
| `create_document()` | Make a DOCX from markdown with track changes markup |
|
|
112
|
-
| `generate_extraction_schemas()` | Suggest extraction schemas for a saved checkpoint |
|
|
113
162
|
| `delete_result()` | Result deletion, by `result.request_id` |
|
|
114
163
|
| `upload_files()`, `list_files()`, ... | File storage. Pass the returned `datalab://file-...` reference as `file_url` |
|
|
115
164
|
| `create_extraction_schema()`, ... | Saved extraction schemas |
|
|
@@ -126,6 +175,10 @@ Published-agent execution is in open beta; the API may change. Processor design
|
|
|
126
175
|
- 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.
|
|
127
176
|
- 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`.
|
|
128
177
|
|
|
178
|
+
With SDK 0.9.0, `upload_files(paths, max_concurrency=5)` streams
|
|
179
|
+
files from disk and limits the number of active uploads. Results retain the
|
|
180
|
+
input order. Use `AsyncDatalabClient` inside an existing async event loop.
|
|
181
|
+
|
|
129
182
|
## Workflows
|
|
130
183
|
|
|
131
184
|
The Datalab API removed the Workflows API. The workflow methods and CLI commands in this SDK are deprecated, and the API does not answer them. Use pipelines instead.
|
|
@@ -42,6 +42,32 @@ print(result.markdown)
|
|
|
42
42
|
|
|
43
43
|
`AsyncDatalabClient` has the same methods as `DatalabClient`, as coroutines.
|
|
44
44
|
|
|
45
|
+
## Progress callbacks
|
|
46
|
+
|
|
47
|
+
With SDK 0.8.0 or later, pass `on_progress` to processing calls:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
result = client.convert(
|
|
51
|
+
"document.pdf",
|
|
52
|
+
on_progress=lambda percent: print(f"Processing: {percent}%"),
|
|
53
|
+
)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The same argument works with `extract`, `segment`, `run_agent`, `track_changes`,
|
|
57
|
+
`create_document`, `ocr`, `fill`, and `form_fields`, including `stream_response_to`.
|
|
58
|
+
`run_pipeline` and `get_pipeline_execution` also support it; set `max_polls`
|
|
59
|
+
above 1 to keep polling a pipeline. Result models expose `progress_percent`
|
|
60
|
+
when the API supplies it.
|
|
61
|
+
|
|
62
|
+
Callbacks receive increasing integer percentages from existing polls, skipping
|
|
63
|
+
missing values and duplicates. Percentages may pause or jump and are not an ETA.
|
|
64
|
+
A callback receives 100 only after successful completion and any signed-result
|
|
65
|
+
download. Check the returned status and success to determine the outcome.
|
|
66
|
+
`AsyncDatalabClient` also accepts async callbacks, which it awaits. Keep callbacks
|
|
67
|
+
short: they run inline, and their exceptions propagate to your call. Callback
|
|
68
|
+
errors stop local polling; they do not cancel the server request. No extra API
|
|
69
|
+
requests are made, and polling intervals are unchanged.
|
|
70
|
+
|
|
45
71
|
## Conversion options
|
|
46
72
|
|
|
47
73
|
```python
|
|
@@ -78,6 +104,30 @@ print(result.extraction_schema_json, result.extraction_score_average)
|
|
|
78
104
|
|
|
79
105
|
When you do not set the parse `mode`, the API picks the parse mode that matches `extraction_mode`.
|
|
80
106
|
|
|
107
|
+
## Redaction
|
|
108
|
+
|
|
109
|
+
**Open beta (SDK 0.9.0):** the redaction API may change.
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from datalab_sdk import RedactOptions
|
|
113
|
+
|
|
114
|
+
result = client.redact(
|
|
115
|
+
"document.pdf",
|
|
116
|
+
options=RedactOptions(preset="personal_information"),
|
|
117
|
+
)
|
|
118
|
+
# A PDF can be returned even when verification fails. Review these first.
|
|
119
|
+
print(result.verdict, result.failing_checks)
|
|
120
|
+
if result.success and result.verdict == "PASS" and not result.withheld and result.output_base64:
|
|
121
|
+
result.save_output("redacted.pdf")
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`get_redaction_presets()` returns the built-in preset IDs and specifications.
|
|
125
|
+
Use `redaction_spec` to supply a custom spec. Redaction processes the whole
|
|
126
|
+
PDF or image; page subsets are not supported. Completed requests are charged
|
|
127
|
+
even if verification fails. `save_output` on `redact()` saves any available
|
|
128
|
+
PDF, including one with failed verification. Redaction returns a typed result;
|
|
129
|
+
`stream_response_to` is not supported for this helper.
|
|
130
|
+
|
|
81
131
|
## Other endpoints
|
|
82
132
|
|
|
83
133
|
| Method | Endpoint |
|
|
@@ -88,7 +138,6 @@ When you do not set the parse `mode`, the API picks the parse mode that matches
|
|
|
88
138
|
| `form_fields()` | Find the fillable fields in a PDF or image |
|
|
89
139
|
| `track_changes()` | Read tracked changes and comments from DOCX or PDF |
|
|
90
140
|
| `create_document()` | Make a DOCX from markdown with track changes markup |
|
|
91
|
-
| `generate_extraction_schemas()` | Suggest extraction schemas for a saved checkpoint |
|
|
92
141
|
| `delete_result()` | Result deletion, by `result.request_id` |
|
|
93
142
|
| `upload_files()`, `list_files()`, ... | File storage. Pass the returned `datalab://file-...` reference as `file_url` |
|
|
94
143
|
| `create_extraction_schema()`, ... | Saved extraction schemas |
|
|
@@ -105,6 +154,10 @@ Published-agent execution is in open beta; the API may change. Processor design
|
|
|
105
154
|
- 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.
|
|
106
155
|
- 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`.
|
|
107
156
|
|
|
157
|
+
With SDK 0.9.0, `upload_files(paths, max_concurrency=5)` streams
|
|
158
|
+
files from disk and limits the number of active uploads. Results retain the
|
|
159
|
+
input order. Use `AsyncDatalabClient` inside an existing async event loop.
|
|
160
|
+
|
|
108
161
|
## Workflows
|
|
109
162
|
|
|
110
163
|
The Datalab API removed the Workflows API. The workflow methods and CLI commands in this SDK are deprecated, and the API does not answer them. Use pipelines instead.
|
|
@@ -30,6 +30,8 @@ from .models import (
|
|
|
30
30
|
CustomPipelineOptions,
|
|
31
31
|
TrackChangesOptions,
|
|
32
32
|
OCROptions,
|
|
33
|
+
RedactOptions,
|
|
34
|
+
RedactResult,
|
|
33
35
|
FormFillingOptions,
|
|
34
36
|
FormFillingResult,
|
|
35
37
|
FormFieldsOptions,
|
|
@@ -78,6 +80,8 @@ __all__ = [
|
|
|
78
80
|
"CustomPipelineOptions",
|
|
79
81
|
"TrackChangesOptions",
|
|
80
82
|
"OCROptions",
|
|
83
|
+
"RedactOptions",
|
|
84
|
+
"RedactResult",
|
|
81
85
|
"FormFillingOptions",
|
|
82
86
|
"FormFillingResult",
|
|
83
87
|
"FormFieldsOptions",
|