datalab-python-sdk 0.7.1__py3-none-any.whl → 0.8.0__py3-none-any.whl
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.dist-info → datalab_python_sdk-0.8.0.dist-info}/METADATA +27 -1
- {datalab_python_sdk-0.7.1.dist-info → datalab_python_sdk-0.8.0.dist-info}/RECORD +7 -7
- datalab_sdk/client.py +133 -4
- datalab_sdk/models.py +9 -0
- {datalab_python_sdk-0.7.1.dist-info → datalab_python_sdk-0.8.0.dist-info}/WHEEL +0 -0
- {datalab_python_sdk-0.7.1.dist-info → datalab_python_sdk-0.8.0.dist-info}/entry_points.txt +0 -0
- {datalab_python_sdk-0.7.1.dist-info → datalab_python_sdk-0.8.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: datalab-python-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.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
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
datalab_sdk/__init__.py,sha256=BLAqVuqjxhdjKabkDUePLSmGeVMo0BnWfVbLDt8haP4,2397
|
|
2
2
|
datalab_sdk/auth.py,sha256=X2eccKzpdxogFEDoS4geOHIOeECQ8u3kANxKoqF0PVk,4388
|
|
3
3
|
datalab_sdk/cli.py,sha256=icUy91brz0J8hzvC1G-pBtZPszc5oRd4H3sEpYhKr7Y,54186
|
|
4
|
-
datalab_sdk/client.py,sha256=
|
|
4
|
+
datalab_sdk/client.py,sha256=ULzCKs1EgHQzi7eg2lxHvjZC20AUtVzuFa0YQDz-JSA,132311
|
|
5
5
|
datalab_sdk/exceptions.py,sha256=5-lzlfvB7FKGOhvgyacceTFRRUxton_JqcIyuB8k_mU,2625
|
|
6
6
|
datalab_sdk/mimetypes.py,sha256=a4ULJmHxoR_RMsD0j51hx0t2Q7In_PzNm7UlWX07eEE,932
|
|
7
|
-
datalab_sdk/models.py,sha256=
|
|
7
|
+
datalab_sdk/models.py,sha256=SnXQEHh8xro9pvzcZ0tcT1jlS0-zEopzgXP49x7ycZc,32881
|
|
8
8
|
datalab_sdk/settings.py,sha256=B_B42QQADAz6ePXQTOqENZllcppFR4JpwonEk2vlzhw,693
|
|
9
|
-
datalab_python_sdk-0.
|
|
10
|
-
datalab_python_sdk-0.
|
|
11
|
-
datalab_python_sdk-0.
|
|
12
|
-
datalab_python_sdk-0.
|
|
13
|
-
datalab_python_sdk-0.
|
|
9
|
+
datalab_python_sdk-0.8.0.dist-info/METADATA,sha256=59jpki5J8TcCcJ2fO7w7w7VWIahfuippcJboYqhcSXU,8136
|
|
10
|
+
datalab_python_sdk-0.8.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
11
|
+
datalab_python_sdk-0.8.0.dist-info/entry_points.txt,sha256=rqWxO21UV57JxxyeF20iBTxHpzBYOA69hCHIqwdn-Ok,48
|
|
12
|
+
datalab_python_sdk-0.8.0.dist-info/licenses/LICENSE,sha256=XGjT-Uz6t7UZzr3JCZfilsGcZEgMm_1aONcRunohxWg,1064
|
|
13
|
+
datalab_python_sdk-0.8.0.dist-info/RECORD,,
|
datalab_sdk/client.py
CHANGED
|
@@ -3,6 +3,7 @@ Datalab API client - async core with sync wrapper
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
import asyncio
|
|
6
|
+
import inspect
|
|
6
7
|
import json as jsonlib
|
|
7
8
|
import mimetypes
|
|
8
9
|
import os
|
|
@@ -20,7 +21,7 @@ from tenacity import (
|
|
|
20
21
|
wait_exponential_jitter,
|
|
21
22
|
)
|
|
22
23
|
from pathlib import Path
|
|
23
|
-
from typing import Union, Optional, Dict, Any
|
|
24
|
+
from typing import Union, Optional, Dict, Any, Callable, Awaitable
|
|
24
25
|
|
|
25
26
|
from datalab_sdk.exceptions import (
|
|
26
27
|
DatalabAPIError,
|
|
@@ -66,6 +67,29 @@ from datalab_sdk.models import (
|
|
|
66
67
|
from datalab_sdk.settings import settings
|
|
67
68
|
|
|
68
69
|
|
|
70
|
+
ProgressCallback = Callable[[int], Optional[Awaitable[None]]]
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class _ProgressReporter:
|
|
74
|
+
"""Deliver increasing, valid percentages within one polling operation."""
|
|
75
|
+
|
|
76
|
+
def __init__(self, callback: Optional[ProgressCallback]):
|
|
77
|
+
self.callback = callback
|
|
78
|
+
self.last = -1
|
|
79
|
+
|
|
80
|
+
async def report(self, percent: Any, *, complete: bool = False) -> None:
|
|
81
|
+
if complete:
|
|
82
|
+
percent = 100
|
|
83
|
+
if type(percent) is not int or not 0 <= percent <= (100 if complete else 99):
|
|
84
|
+
return
|
|
85
|
+
if self.callback is None or percent <= self.last:
|
|
86
|
+
return
|
|
87
|
+
self.last = percent
|
|
88
|
+
result = self.callback(percent)
|
|
89
|
+
if inspect.isawaitable(result):
|
|
90
|
+
await result
|
|
91
|
+
|
|
92
|
+
|
|
69
93
|
# HTTP status codes that a POST submission can safely retry. The API sends
|
|
70
94
|
# 429 for rate limits and 503 when it cannot queue the job ("please retry").
|
|
71
95
|
_SUBMIT_RETRY_STATUSES = (429, 503)
|
|
@@ -293,6 +317,7 @@ class AsyncDatalabClient:
|
|
|
293
317
|
max_polls: int = 300,
|
|
294
318
|
poll_interval: int = 1,
|
|
295
319
|
stream_response_to: Optional[Path] = None,
|
|
320
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
296
321
|
) -> Union[Dict[str, Any], FileResult]:
|
|
297
322
|
"""Poll for result completion"""
|
|
298
323
|
full_url = (
|
|
@@ -301,20 +326,26 @@ class AsyncDatalabClient:
|
|
|
301
326
|
else f"{self.base_url}/{check_url.lstrip('/')}"
|
|
302
327
|
)
|
|
303
328
|
|
|
329
|
+
progress = _ProgressReporter(on_progress)
|
|
304
330
|
for i in range(max_polls):
|
|
305
331
|
if stream_response_to:
|
|
306
332
|
result = await self._poll_get_streaming(full_url, stream_response_to)
|
|
307
333
|
status, success, error = result.status, result.success, result.error
|
|
334
|
+
percent = result.progress_percent
|
|
308
335
|
else:
|
|
309
336
|
data = await self._poll_get_with_retry(full_url)
|
|
310
337
|
status = data.get("status")
|
|
311
338
|
success = data.get("success", True)
|
|
312
339
|
error = data.get("error")
|
|
340
|
+
percent = data.get("progress_percent")
|
|
313
341
|
|
|
314
342
|
if status == "complete":
|
|
315
|
-
if stream_response_to:
|
|
316
|
-
|
|
317
|
-
|
|
343
|
+
if not stream_response_to:
|
|
344
|
+
result = await self._resolve_signed_result(data)
|
|
345
|
+
await progress.report(percent, complete=bool(success))
|
|
346
|
+
return result
|
|
347
|
+
|
|
348
|
+
await progress.report(percent)
|
|
318
349
|
|
|
319
350
|
if not success and status != "processing":
|
|
320
351
|
raise DatalabAPIError(f"Processing failed: {error or 'Unknown error'}")
|
|
@@ -449,6 +480,7 @@ class AsyncDatalabClient:
|
|
|
449
480
|
success = None
|
|
450
481
|
error = None
|
|
451
482
|
result_url = None
|
|
483
|
+
progress_percent = None
|
|
452
484
|
|
|
453
485
|
tee_reader = _AsyncIterableReader(
|
|
454
486
|
self._tee_stream_to_file(resp.content, fd)
|
|
@@ -462,6 +494,8 @@ class AsyncDatalabClient:
|
|
|
462
494
|
error = value
|
|
463
495
|
elif prefix == "result_url" and event == "string":
|
|
464
496
|
result_url = value
|
|
497
|
+
elif prefix == "progress_percent" and event == "number":
|
|
498
|
+
progress_percent = value
|
|
465
499
|
finally:
|
|
466
500
|
resp.release()
|
|
467
501
|
|
|
@@ -488,6 +522,7 @@ class AsyncDatalabClient:
|
|
|
488
522
|
status=status,
|
|
489
523
|
output_path=stream_response_to,
|
|
490
524
|
error=error,
|
|
525
|
+
progress_percent=progress_percent,
|
|
491
526
|
)
|
|
492
527
|
else:
|
|
493
528
|
return FileResult(
|
|
@@ -495,6 +530,7 @@ class AsyncDatalabClient:
|
|
|
495
530
|
status=status,
|
|
496
531
|
output_path=stream_response_to,
|
|
497
532
|
error=error,
|
|
533
|
+
progress_percent=progress_percent,
|
|
498
534
|
)
|
|
499
535
|
finally:
|
|
500
536
|
if fd is not None:
|
|
@@ -597,6 +633,7 @@ class AsyncDatalabClient:
|
|
|
597
633
|
extraction_mode=result_data.get("extraction_mode"),
|
|
598
634
|
segmentation_schema=result_data.get("segmentation_schema"),
|
|
599
635
|
checkpoint_reused=result_data.get("checkpoint_reused"),
|
|
636
|
+
progress_percent=result_data.get("progress_percent"),
|
|
600
637
|
)
|
|
601
638
|
|
|
602
639
|
async def _submit_and_poll(
|
|
@@ -607,6 +644,7 @@ class AsyncDatalabClient:
|
|
|
607
644
|
poll_interval: int = 1,
|
|
608
645
|
stream_response_to: Optional[Path] = None,
|
|
609
646
|
json: Optional[Dict[str, Any]] = None,
|
|
647
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
610
648
|
) -> Union[Dict[str, Any], FileResult]:
|
|
611
649
|
"""Submit a request and poll for the result.
|
|
612
650
|
|
|
@@ -624,6 +662,7 @@ class AsyncDatalabClient:
|
|
|
624
662
|
initial_data["request_check_url"],
|
|
625
663
|
max_polls=max_polls,
|
|
626
664
|
poll_interval=poll_interval,
|
|
665
|
+
on_progress=on_progress,
|
|
627
666
|
stream_response_to=stream_response_to,
|
|
628
667
|
)
|
|
629
668
|
if isinstance(result, dict):
|
|
@@ -680,6 +719,7 @@ class AsyncDatalabClient:
|
|
|
680
719
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
681
720
|
max_polls: int = 300,
|
|
682
721
|
poll_interval: int = 1,
|
|
722
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
683
723
|
) -> Union[ConversionResult, FileResult]:
|
|
684
724
|
"""
|
|
685
725
|
Convert a document to markdown, HTML, JSON, or chunks
|
|
@@ -693,6 +733,7 @@ class AsyncDatalabClient:
|
|
|
693
733
|
stream_response_to: Optional path to stream raw JSON response to disk
|
|
694
734
|
max_polls: Maximum number of polling attempts
|
|
695
735
|
poll_interval: Seconds between polling attempts
|
|
736
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
696
737
|
"""
|
|
697
738
|
resolved_stream_response_to = self._resolve_stream_path(
|
|
698
739
|
save_output, stream_response_to
|
|
@@ -708,6 +749,7 @@ class AsyncDatalabClient:
|
|
|
708
749
|
),
|
|
709
750
|
max_polls=max_polls,
|
|
710
751
|
poll_interval=poll_interval,
|
|
752
|
+
on_progress=on_progress,
|
|
711
753
|
stream_response_to=resolved_stream_response_to,
|
|
712
754
|
)
|
|
713
755
|
|
|
@@ -727,6 +769,7 @@ class AsyncDatalabClient:
|
|
|
727
769
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
728
770
|
max_polls: int = 300,
|
|
729
771
|
poll_interval: int = 1,
|
|
772
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
730
773
|
) -> Union[ConversionResult, FileResult]:
|
|
731
774
|
"""
|
|
732
775
|
Extract structured data from a document using a JSON schema or saved extraction schema
|
|
@@ -742,6 +785,7 @@ class AsyncDatalabClient:
|
|
|
742
785
|
stream_response_to: Optional path to stream raw JSON response to disk
|
|
743
786
|
max_polls: Maximum number of polling attempts
|
|
744
787
|
poll_interval: Seconds between polling attempts
|
|
788
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
745
789
|
"""
|
|
746
790
|
resolved_stream_response_to = self._resolve_stream_path(
|
|
747
791
|
save_output, stream_response_to
|
|
@@ -780,6 +824,7 @@ class AsyncDatalabClient:
|
|
|
780
824
|
),
|
|
781
825
|
max_polls=max_polls,
|
|
782
826
|
poll_interval=poll_interval,
|
|
827
|
+
on_progress=on_progress,
|
|
783
828
|
stream_response_to=resolved_stream_response_to,
|
|
784
829
|
)
|
|
785
830
|
|
|
@@ -799,6 +844,7 @@ class AsyncDatalabClient:
|
|
|
799
844
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
800
845
|
max_polls: int = 300,
|
|
801
846
|
poll_interval: int = 1,
|
|
847
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
802
848
|
) -> Union[ConversionResult, FileResult]:
|
|
803
849
|
"""
|
|
804
850
|
Segment a document into sections using a schema
|
|
@@ -814,6 +860,7 @@ class AsyncDatalabClient:
|
|
|
814
860
|
stream_response_to: Optional path to stream raw JSON response to disk
|
|
815
861
|
max_polls: Maximum number of polling attempts
|
|
816
862
|
poll_interval: Seconds between polling attempts
|
|
863
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
817
864
|
"""
|
|
818
865
|
resolved_stream_response_to = self._resolve_stream_path(
|
|
819
866
|
save_output, stream_response_to
|
|
@@ -836,6 +883,7 @@ class AsyncDatalabClient:
|
|
|
836
883
|
),
|
|
837
884
|
max_polls=max_polls,
|
|
838
885
|
poll_interval=poll_interval,
|
|
886
|
+
on_progress=on_progress,
|
|
839
887
|
stream_response_to=resolved_stream_response_to,
|
|
840
888
|
)
|
|
841
889
|
|
|
@@ -855,6 +903,7 @@ class AsyncDatalabClient:
|
|
|
855
903
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
856
904
|
max_polls: int = 300,
|
|
857
905
|
poll_interval: int = 1,
|
|
906
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
858
907
|
) -> Union[AgentResult, FileResult]:
|
|
859
908
|
"""
|
|
860
909
|
Run a published agent processor on a document (open beta; API may change).
|
|
@@ -871,6 +920,7 @@ class AsyncDatalabClient:
|
|
|
871
920
|
stream_response_to: Optional path to stream raw JSON response to disk
|
|
872
921
|
max_polls: Maximum number of polling attempts
|
|
873
922
|
poll_interval: Seconds between polling attempts
|
|
923
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
874
924
|
"""
|
|
875
925
|
resolved_stream_response_to = self._resolve_stream_path(
|
|
876
926
|
save_output, stream_response_to
|
|
@@ -886,6 +936,7 @@ class AsyncDatalabClient:
|
|
|
886
936
|
),
|
|
887
937
|
max_polls=max_polls,
|
|
888
938
|
poll_interval=poll_interval,
|
|
939
|
+
on_progress=on_progress,
|
|
889
940
|
stream_response_to=resolved_stream_response_to,
|
|
890
941
|
)
|
|
891
942
|
|
|
@@ -919,6 +970,7 @@ class AsyncDatalabClient:
|
|
|
919
970
|
request_id=result_data.get("request_id"),
|
|
920
971
|
result_url=result_data.get("result_url"),
|
|
921
972
|
expires_in=result_data.get("expires_in"),
|
|
973
|
+
progress_percent=result_data.get("progress_percent"),
|
|
922
974
|
)
|
|
923
975
|
self._save_if_requested(result, save_output)
|
|
924
976
|
return result
|
|
@@ -932,6 +984,7 @@ class AsyncDatalabClient:
|
|
|
932
984
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
933
985
|
max_polls: int = 300,
|
|
934
986
|
poll_interval: int = 1,
|
|
987
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
935
988
|
) -> Union[ConversionResult, FileResult]:
|
|
936
989
|
"""
|
|
937
990
|
Execute a custom processor on a document
|
|
@@ -947,6 +1000,7 @@ class AsyncDatalabClient:
|
|
|
947
1000
|
stream_response_to: Optional path to stream raw JSON response to disk
|
|
948
1001
|
max_polls: Maximum number of polling attempts
|
|
949
1002
|
poll_interval: Seconds between polling attempts
|
|
1003
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
950
1004
|
"""
|
|
951
1005
|
warnings.warn(
|
|
952
1006
|
"run_custom_processor() uses the deprecated /custom-processor endpoint. "
|
|
@@ -962,6 +1016,7 @@ class AsyncDatalabClient:
|
|
|
962
1016
|
stream_response_to=stream_response_to,
|
|
963
1017
|
max_polls=max_polls,
|
|
964
1018
|
poll_interval=poll_interval,
|
|
1019
|
+
on_progress=on_progress,
|
|
965
1020
|
)
|
|
966
1021
|
|
|
967
1022
|
async def _run_custom_processor(
|
|
@@ -973,6 +1028,7 @@ class AsyncDatalabClient:
|
|
|
973
1028
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
974
1029
|
max_polls: int = 300,
|
|
975
1030
|
poll_interval: int = 1,
|
|
1031
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
976
1032
|
) -> Union[ConversionResult, FileResult]:
|
|
977
1033
|
resolved_stream_response_to = self._resolve_stream_path(
|
|
978
1034
|
save_output, stream_response_to
|
|
@@ -988,6 +1044,7 @@ class AsyncDatalabClient:
|
|
|
988
1044
|
),
|
|
989
1045
|
max_polls=max_polls,
|
|
990
1046
|
poll_interval=poll_interval,
|
|
1047
|
+
on_progress=on_progress,
|
|
991
1048
|
stream_response_to=resolved_stream_response_to,
|
|
992
1049
|
)
|
|
993
1050
|
|
|
@@ -1007,6 +1064,7 @@ class AsyncDatalabClient:
|
|
|
1007
1064
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
1008
1065
|
max_polls: int = 300,
|
|
1009
1066
|
poll_interval: int = 1,
|
|
1067
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
1010
1068
|
) -> Union[ConversionResult, FileResult]:
|
|
1011
1069
|
"""Execute a custom processor on a document
|
|
1012
1070
|
|
|
@@ -1027,6 +1085,7 @@ class AsyncDatalabClient:
|
|
|
1027
1085
|
stream_response_to=stream_response_to,
|
|
1028
1086
|
max_polls=max_polls,
|
|
1029
1087
|
poll_interval=poll_interval,
|
|
1088
|
+
on_progress=on_progress,
|
|
1030
1089
|
)
|
|
1031
1090
|
|
|
1032
1091
|
async def track_changes(
|
|
@@ -1038,6 +1097,7 @@ class AsyncDatalabClient:
|
|
|
1038
1097
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
1039
1098
|
max_polls: int = 300,
|
|
1040
1099
|
poll_interval: int = 1,
|
|
1100
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
1041
1101
|
) -> Union[ConversionResult, FileResult]:
|
|
1042
1102
|
"""
|
|
1043
1103
|
Extract tracked changes and comments from DOCX or PDF documents
|
|
@@ -1050,6 +1110,7 @@ class AsyncDatalabClient:
|
|
|
1050
1110
|
stream_response_to: Optional path to stream raw JSON response to disk
|
|
1051
1111
|
max_polls: Maximum number of polling attempts
|
|
1052
1112
|
poll_interval: Seconds between polling attempts
|
|
1113
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
1053
1114
|
"""
|
|
1054
1115
|
resolved_stream_response_to = self._resolve_stream_path(
|
|
1055
1116
|
save_output, stream_response_to
|
|
@@ -1065,6 +1126,7 @@ class AsyncDatalabClient:
|
|
|
1065
1126
|
),
|
|
1066
1127
|
max_polls=max_polls,
|
|
1067
1128
|
poll_interval=poll_interval,
|
|
1129
|
+
on_progress=on_progress,
|
|
1068
1130
|
stream_response_to=resolved_stream_response_to,
|
|
1069
1131
|
)
|
|
1070
1132
|
|
|
@@ -1085,6 +1147,7 @@ class AsyncDatalabClient:
|
|
|
1085
1147
|
max_polls: int = 300,
|
|
1086
1148
|
poll_interval: int = 1,
|
|
1087
1149
|
processing_location: Optional[str] = None,
|
|
1150
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
1088
1151
|
) -> Union[CreateDocumentResult, FileResult]:
|
|
1089
1152
|
"""
|
|
1090
1153
|
Create a DOCX document from markdown with track changes support
|
|
@@ -1102,6 +1165,7 @@ class AsyncDatalabClient:
|
|
|
1102
1165
|
stream_response_to: Optional path to stream raw JSON response to disk
|
|
1103
1166
|
max_polls: Maximum number of polling attempts
|
|
1104
1167
|
poll_interval: Seconds between polling attempts
|
|
1168
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
1105
1169
|
processing_location: Optional residency region, e.g. "eu"
|
|
1106
1170
|
"""
|
|
1107
1171
|
resolved_stream_response_to = self._resolve_stream_path(
|
|
@@ -1122,6 +1186,7 @@ class AsyncDatalabClient:
|
|
|
1122
1186
|
json=payload,
|
|
1123
1187
|
max_polls=max_polls,
|
|
1124
1188
|
poll_interval=poll_interval,
|
|
1189
|
+
on_progress=on_progress,
|
|
1125
1190
|
stream_response_to=resolved_stream_response_to,
|
|
1126
1191
|
)
|
|
1127
1192
|
|
|
@@ -1141,6 +1206,7 @@ class AsyncDatalabClient:
|
|
|
1141
1206
|
request_id=result_data.get("request_id"),
|
|
1142
1207
|
result_url=result_data.get("result_url"),
|
|
1143
1208
|
expires_in=result_data.get("expires_in"),
|
|
1209
|
+
progress_percent=result_data.get("progress_percent"),
|
|
1144
1210
|
)
|
|
1145
1211
|
self._save_if_requested(result, save_output, bool(result.output_base64))
|
|
1146
1212
|
return result
|
|
@@ -1153,6 +1219,7 @@ class AsyncDatalabClient:
|
|
|
1153
1219
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
1154
1220
|
max_polls: int = 300,
|
|
1155
1221
|
poll_interval: int = 1,
|
|
1222
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
1156
1223
|
) -> Union[OCRResult, FileResult]:
|
|
1157
1224
|
"""Perform OCR on a document
|
|
1158
1225
|
|
|
@@ -1177,6 +1244,7 @@ class AsyncDatalabClient:
|
|
|
1177
1244
|
data=self.get_form_params(file_path=file_path, options=options),
|
|
1178
1245
|
max_polls=max_polls,
|
|
1179
1246
|
poll_interval=poll_interval,
|
|
1247
|
+
on_progress=on_progress,
|
|
1180
1248
|
stream_response_to=resolved_stream_response_to,
|
|
1181
1249
|
)
|
|
1182
1250
|
|
|
@@ -1192,6 +1260,7 @@ class AsyncDatalabClient:
|
|
|
1192
1260
|
versions=result_data.get("versions"),
|
|
1193
1261
|
cost_breakdown=result_data.get("cost_breakdown"),
|
|
1194
1262
|
request_id=result_data.get("request_id"),
|
|
1263
|
+
progress_percent=result_data.get("progress_percent"),
|
|
1195
1264
|
)
|
|
1196
1265
|
self._save_if_requested(result, save_output)
|
|
1197
1266
|
return result
|
|
@@ -1205,6 +1274,7 @@ class AsyncDatalabClient:
|
|
|
1205
1274
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
1206
1275
|
max_polls: int = 300,
|
|
1207
1276
|
poll_interval: int = 1,
|
|
1277
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
1208
1278
|
) -> Union[FormFillingResult, FileResult]:
|
|
1209
1279
|
"""
|
|
1210
1280
|
Fill PDF or image forms with provided field data
|
|
@@ -1217,6 +1287,7 @@ class AsyncDatalabClient:
|
|
|
1217
1287
|
stream_response_to: Optional path to stream raw JSON response to disk
|
|
1218
1288
|
max_polls: Maximum number of polling attempts
|
|
1219
1289
|
poll_interval: Seconds between polling attempts
|
|
1290
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
1220
1291
|
"""
|
|
1221
1292
|
resolved_stream_response_to = self._resolve_stream_path(
|
|
1222
1293
|
save_output, stream_response_to
|
|
@@ -1232,6 +1303,7 @@ class AsyncDatalabClient:
|
|
|
1232
1303
|
),
|
|
1233
1304
|
max_polls=max_polls,
|
|
1234
1305
|
poll_interval=poll_interval,
|
|
1306
|
+
on_progress=on_progress,
|
|
1235
1307
|
stream_response_to=resolved_stream_response_to,
|
|
1236
1308
|
)
|
|
1237
1309
|
|
|
@@ -1254,6 +1326,7 @@ class AsyncDatalabClient:
|
|
|
1254
1326
|
request_id=result_data.get("request_id"),
|
|
1255
1327
|
result_url=result_data.get("result_url"),
|
|
1256
1328
|
expires_in=result_data.get("expires_in"),
|
|
1329
|
+
progress_percent=result_data.get("progress_percent"),
|
|
1257
1330
|
)
|
|
1258
1331
|
self._save_if_requested(result, save_output, bool(result.output_base64))
|
|
1259
1332
|
return result
|
|
@@ -1267,6 +1340,7 @@ class AsyncDatalabClient:
|
|
|
1267
1340
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
1268
1341
|
max_polls: int = 300,
|
|
1269
1342
|
poll_interval: int = 1,
|
|
1343
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
1270
1344
|
) -> Union[FormFieldsResult, FileResult]:
|
|
1271
1345
|
"""
|
|
1272
1346
|
Find the fillable fields on each page of a PDF or image
|
|
@@ -1282,6 +1356,7 @@ class AsyncDatalabClient:
|
|
|
1282
1356
|
stream_response_to: Optional path to stream raw JSON response to disk
|
|
1283
1357
|
max_polls: Maximum number of polling attempts
|
|
1284
1358
|
poll_interval: Seconds between polling attempts
|
|
1359
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
1285
1360
|
"""
|
|
1286
1361
|
resolved_stream_response_to = self._resolve_stream_path(
|
|
1287
1362
|
save_output, stream_response_to
|
|
@@ -1297,6 +1372,7 @@ class AsyncDatalabClient:
|
|
|
1297
1372
|
),
|
|
1298
1373
|
max_polls=max_polls,
|
|
1299
1374
|
poll_interval=poll_interval,
|
|
1375
|
+
on_progress=on_progress,
|
|
1300
1376
|
stream_response_to=resolved_stream_response_to,
|
|
1301
1377
|
)
|
|
1302
1378
|
|
|
@@ -1315,6 +1391,7 @@ class AsyncDatalabClient:
|
|
|
1315
1391
|
request_id=result_data.get("request_id"),
|
|
1316
1392
|
result_url=result_data.get("result_url"),
|
|
1317
1393
|
expires_in=result_data.get("expires_in"),
|
|
1394
|
+
progress_percent=result_data.get("progress_percent"),
|
|
1318
1395
|
)
|
|
1319
1396
|
self._save_if_requested(result, save_output)
|
|
1320
1397
|
return result
|
|
@@ -2331,6 +2408,7 @@ class AsyncDatalabClient:
|
|
|
2331
2408
|
poll_interval: int = 1,
|
|
2332
2409
|
checkpoint_id: Optional[str] = None,
|
|
2333
2410
|
processing_location: Optional[str] = None,
|
|
2411
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
2334
2412
|
) -> PipelineExecution:
|
|
2335
2413
|
"""
|
|
2336
2414
|
Execute a pipeline on a file
|
|
@@ -2346,6 +2424,7 @@ class AsyncDatalabClient:
|
|
|
2346
2424
|
version: Pipeline version to execute (0=draft, omit=active)
|
|
2347
2425
|
max_polls: Maximum polling attempts after submission (default: 1)
|
|
2348
2426
|
poll_interval: Seconds between polls
|
|
2427
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
2349
2428
|
checkpoint_id: Checkpoint from the convert step of an earlier run.
|
|
2350
2429
|
The API skips re-parsing and runs only the later steps. You
|
|
2351
2430
|
must still send the file.
|
|
@@ -2371,6 +2450,10 @@ class AsyncDatalabClient:
|
|
|
2371
2450
|
f"/api/v1/pipelines/{pipeline_id}/run", data=form_data
|
|
2372
2451
|
)
|
|
2373
2452
|
execution = self._build_pipeline_execution(response)
|
|
2453
|
+
progress = _ProgressReporter(on_progress)
|
|
2454
|
+
await progress.report(
|
|
2455
|
+
execution.progress_percent, complete=execution.status == "completed"
|
|
2456
|
+
)
|
|
2374
2457
|
|
|
2375
2458
|
# Poll if requested
|
|
2376
2459
|
if max_polls > 1 and execution.status not in (
|
|
@@ -2378,10 +2461,15 @@ class AsyncDatalabClient:
|
|
|
2378
2461
|
"completed_with_errors",
|
|
2379
2462
|
"failed",
|
|
2380
2463
|
):
|
|
2464
|
+
|
|
2465
|
+
async def forward_progress(percent: int) -> None:
|
|
2466
|
+
await progress.report(percent, complete=percent == 100)
|
|
2467
|
+
|
|
2381
2468
|
return await self.get_pipeline_execution(
|
|
2382
2469
|
execution.execution_id,
|
|
2383
2470
|
max_polls=max_polls - 1,
|
|
2384
2471
|
poll_interval=poll_interval,
|
|
2472
|
+
on_progress=forward_progress,
|
|
2385
2473
|
)
|
|
2386
2474
|
return execution
|
|
2387
2475
|
|
|
@@ -2390,6 +2478,7 @@ class AsyncDatalabClient:
|
|
|
2390
2478
|
execution_id: str,
|
|
2391
2479
|
max_polls: int = 1,
|
|
2392
2480
|
poll_interval: int = 1,
|
|
2481
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
2393
2482
|
) -> PipelineExecution:
|
|
2394
2483
|
"""
|
|
2395
2484
|
Get the status of a pipeline execution, optionally polling until completion
|
|
@@ -2398,12 +2487,17 @@ class AsyncDatalabClient:
|
|
|
2398
2487
|
execution_id: Execution ID (pex_XXXXX)
|
|
2399
2488
|
max_polls: Maximum polling attempts (default: 1 for single check)
|
|
2400
2489
|
poll_interval: Seconds between polls
|
|
2490
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
2401
2491
|
"""
|
|
2492
|
+
progress = _ProgressReporter(on_progress)
|
|
2402
2493
|
for i in range(max_polls):
|
|
2403
2494
|
response = await self._make_request(
|
|
2404
2495
|
"GET", f"/api/v1/pipelines/executions/{execution_id}"
|
|
2405
2496
|
)
|
|
2406
2497
|
execution = self._build_pipeline_execution(response)
|
|
2498
|
+
await progress.report(
|
|
2499
|
+
execution.progress_percent, complete=execution.status == "completed"
|
|
2500
|
+
)
|
|
2407
2501
|
|
|
2408
2502
|
if execution.status in ("completed", "completed_with_errors", "failed"):
|
|
2409
2503
|
return execution
|
|
@@ -2480,6 +2574,7 @@ class AsyncDatalabClient:
|
|
|
2480
2574
|
checkpoint_id=s.get("checkpoint_id"),
|
|
2481
2575
|
source_step_type=s.get("source_step_type"),
|
|
2482
2576
|
checkpoint_reused=s.get("checkpoint_reused"),
|
|
2577
|
+
progress_percent=s.get("progress_percent"),
|
|
2483
2578
|
)
|
|
2484
2579
|
for s in data.get("steps", [])
|
|
2485
2580
|
]
|
|
@@ -2495,6 +2590,7 @@ class AsyncDatalabClient:
|
|
|
2495
2590
|
config_snapshot=data.get("config_snapshot"),
|
|
2496
2591
|
input_config=data.get("input_config"),
|
|
2497
2592
|
rate_breakdown=data.get("rate_breakdown"),
|
|
2593
|
+
progress_percent=data.get("progress_percent"),
|
|
2498
2594
|
)
|
|
2499
2595
|
|
|
2500
2596
|
# --- Custom Processor Management methods ---
|
|
@@ -2639,6 +2735,7 @@ class DatalabClient:
|
|
|
2639
2735
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
2640
2736
|
max_polls: int = 300,
|
|
2641
2737
|
poll_interval: int = 1,
|
|
2738
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
2642
2739
|
) -> Union[ConversionResult, FileResult]:
|
|
2643
2740
|
"""
|
|
2644
2741
|
Convert a document to markdown, HTML, JSON, or chunks (sync version)
|
|
@@ -2651,6 +2748,7 @@ class DatalabClient:
|
|
|
2651
2748
|
stream_response_to: Optional path to stream raw JSON response to disk
|
|
2652
2749
|
max_polls: Maximum number of polling attempts
|
|
2653
2750
|
poll_interval: Seconds between polling attempts
|
|
2751
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
2654
2752
|
"""
|
|
2655
2753
|
return self._run_async(
|
|
2656
2754
|
self._async_client.convert(
|
|
@@ -2661,6 +2759,7 @@ class DatalabClient:
|
|
|
2661
2759
|
stream_response_to=stream_response_to,
|
|
2662
2760
|
max_polls=max_polls,
|
|
2663
2761
|
poll_interval=poll_interval,
|
|
2762
|
+
on_progress=on_progress,
|
|
2664
2763
|
)
|
|
2665
2764
|
)
|
|
2666
2765
|
|
|
@@ -2673,6 +2772,7 @@ class DatalabClient:
|
|
|
2673
2772
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
2674
2773
|
max_polls: int = 300,
|
|
2675
2774
|
poll_interval: int = 1,
|
|
2775
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
2676
2776
|
) -> Union[ConversionResult, FileResult]:
|
|
2677
2777
|
"""
|
|
2678
2778
|
Extract structured data using a JSON schema or saved extraction schema (sync version)
|
|
@@ -2685,6 +2785,7 @@ class DatalabClient:
|
|
|
2685
2785
|
stream_response_to: Optional path to stream raw JSON response to disk
|
|
2686
2786
|
max_polls: Maximum number of polling attempts
|
|
2687
2787
|
poll_interval: Seconds between polling attempts
|
|
2788
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
2688
2789
|
"""
|
|
2689
2790
|
return self._run_async(
|
|
2690
2791
|
self._async_client.extract(
|
|
@@ -2695,6 +2796,7 @@ class DatalabClient:
|
|
|
2695
2796
|
stream_response_to=stream_response_to,
|
|
2696
2797
|
max_polls=max_polls,
|
|
2697
2798
|
poll_interval=poll_interval,
|
|
2799
|
+
on_progress=on_progress,
|
|
2698
2800
|
)
|
|
2699
2801
|
)
|
|
2700
2802
|
|
|
@@ -2707,6 +2809,7 @@ class DatalabClient:
|
|
|
2707
2809
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
2708
2810
|
max_polls: int = 300,
|
|
2709
2811
|
poll_interval: int = 1,
|
|
2812
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
2710
2813
|
) -> Union[ConversionResult, FileResult]:
|
|
2711
2814
|
"""
|
|
2712
2815
|
Segment a document into sections using a schema (sync version)
|
|
@@ -2719,6 +2822,7 @@ class DatalabClient:
|
|
|
2719
2822
|
stream_response_to: Optional path to stream raw JSON response to disk
|
|
2720
2823
|
max_polls: Maximum number of polling attempts
|
|
2721
2824
|
poll_interval: Seconds between polling attempts
|
|
2825
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
2722
2826
|
"""
|
|
2723
2827
|
return self._run_async(
|
|
2724
2828
|
self._async_client.segment(
|
|
@@ -2729,6 +2833,7 @@ class DatalabClient:
|
|
|
2729
2833
|
stream_response_to=stream_response_to,
|
|
2730
2834
|
max_polls=max_polls,
|
|
2731
2835
|
poll_interval=poll_interval,
|
|
2836
|
+
on_progress=on_progress,
|
|
2732
2837
|
)
|
|
2733
2838
|
)
|
|
2734
2839
|
|
|
@@ -2741,6 +2846,7 @@ class DatalabClient:
|
|
|
2741
2846
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
2742
2847
|
max_polls: int = 300,
|
|
2743
2848
|
poll_interval: int = 1,
|
|
2849
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
2744
2850
|
) -> Union[ConversionResult, FileResult]:
|
|
2745
2851
|
"""
|
|
2746
2852
|
Execute a custom processor on a document (sync version)
|
|
@@ -2756,6 +2862,7 @@ class DatalabClient:
|
|
|
2756
2862
|
stream_response_to: Optional path to stream raw JSON response to disk
|
|
2757
2863
|
max_polls: Maximum number of polling attempts
|
|
2758
2864
|
poll_interval: Seconds between polling attempts
|
|
2865
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
2759
2866
|
"""
|
|
2760
2867
|
warnings.warn(
|
|
2761
2868
|
"run_custom_processor() uses the deprecated /custom-processor endpoint. "
|
|
@@ -2772,6 +2879,7 @@ class DatalabClient:
|
|
|
2772
2879
|
stream_response_to=stream_response_to,
|
|
2773
2880
|
max_polls=max_polls,
|
|
2774
2881
|
poll_interval=poll_interval,
|
|
2882
|
+
on_progress=on_progress,
|
|
2775
2883
|
)
|
|
2776
2884
|
)
|
|
2777
2885
|
|
|
@@ -2784,6 +2892,7 @@ class DatalabClient:
|
|
|
2784
2892
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
2785
2893
|
max_polls: int = 300,
|
|
2786
2894
|
poll_interval: int = 1,
|
|
2895
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
2787
2896
|
) -> Union[ConversionResult, FileResult]:
|
|
2788
2897
|
"""Execute a custom processor on a document (sync version)
|
|
2789
2898
|
|
|
@@ -2805,6 +2914,7 @@ class DatalabClient:
|
|
|
2805
2914
|
stream_response_to=stream_response_to,
|
|
2806
2915
|
max_polls=max_polls,
|
|
2807
2916
|
poll_interval=poll_interval,
|
|
2917
|
+
on_progress=on_progress,
|
|
2808
2918
|
)
|
|
2809
2919
|
)
|
|
2810
2920
|
|
|
@@ -2817,6 +2927,7 @@ class DatalabClient:
|
|
|
2817
2927
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
2818
2928
|
max_polls: int = 300,
|
|
2819
2929
|
poll_interval: int = 1,
|
|
2930
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
2820
2931
|
) -> Union[ConversionResult, FileResult]:
|
|
2821
2932
|
"""
|
|
2822
2933
|
Extract and display tracked changes from DOCX documents (sync version)
|
|
@@ -2829,6 +2940,7 @@ class DatalabClient:
|
|
|
2829
2940
|
stream_response_to: Optional path to stream raw JSON response to disk
|
|
2830
2941
|
max_polls: Maximum number of polling attempts
|
|
2831
2942
|
poll_interval: Seconds between polling attempts
|
|
2943
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
2832
2944
|
"""
|
|
2833
2945
|
return self._run_async(
|
|
2834
2946
|
self._async_client.track_changes(
|
|
@@ -2839,6 +2951,7 @@ class DatalabClient:
|
|
|
2839
2951
|
stream_response_to=stream_response_to,
|
|
2840
2952
|
max_polls=max_polls,
|
|
2841
2953
|
poll_interval=poll_interval,
|
|
2954
|
+
on_progress=on_progress,
|
|
2842
2955
|
)
|
|
2843
2956
|
)
|
|
2844
2957
|
|
|
@@ -2852,6 +2965,7 @@ class DatalabClient:
|
|
|
2852
2965
|
max_polls: int = 300,
|
|
2853
2966
|
poll_interval: int = 1,
|
|
2854
2967
|
processing_location: Optional[str] = None,
|
|
2968
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
2855
2969
|
) -> Union[CreateDocumentResult, FileResult]:
|
|
2856
2970
|
"""
|
|
2857
2971
|
Create a DOCX document from markdown (sync version)
|
|
@@ -2864,6 +2978,7 @@ class DatalabClient:
|
|
|
2864
2978
|
stream_response_to: Optional path to stream raw JSON response to disk
|
|
2865
2979
|
max_polls: Maximum number of polling attempts
|
|
2866
2980
|
poll_interval: Seconds between polling attempts
|
|
2981
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
2867
2982
|
"""
|
|
2868
2983
|
return self._run_async(
|
|
2869
2984
|
self._async_client.create_document(
|
|
@@ -2874,6 +2989,7 @@ class DatalabClient:
|
|
|
2874
2989
|
stream_response_to=stream_response_to,
|
|
2875
2990
|
max_polls=max_polls,
|
|
2876
2991
|
poll_interval=poll_interval,
|
|
2992
|
+
on_progress=on_progress,
|
|
2877
2993
|
processing_location=processing_location,
|
|
2878
2994
|
)
|
|
2879
2995
|
)
|
|
@@ -2886,6 +3002,7 @@ class DatalabClient:
|
|
|
2886
3002
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
2887
3003
|
max_polls: int = 300,
|
|
2888
3004
|
poll_interval: int = 1,
|
|
3005
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
2889
3006
|
) -> Union[OCRResult, FileResult]:
|
|
2890
3007
|
"""Perform OCR on a document (sync version)
|
|
2891
3008
|
|
|
@@ -2900,6 +3017,7 @@ class DatalabClient:
|
|
|
2900
3017
|
stream_response_to=stream_response_to,
|
|
2901
3018
|
max_polls=max_polls,
|
|
2902
3019
|
poll_interval=poll_interval,
|
|
3020
|
+
on_progress=on_progress,
|
|
2903
3021
|
)
|
|
2904
3022
|
)
|
|
2905
3023
|
|
|
@@ -2912,6 +3030,7 @@ class DatalabClient:
|
|
|
2912
3030
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
2913
3031
|
max_polls: int = 300,
|
|
2914
3032
|
poll_interval: int = 1,
|
|
3033
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
2915
3034
|
) -> Union[FormFillingResult, FileResult]:
|
|
2916
3035
|
"""
|
|
2917
3036
|
Fill PDF or image forms with provided field data (sync version)
|
|
@@ -2924,6 +3043,7 @@ class DatalabClient:
|
|
|
2924
3043
|
stream_response_to: Optional path to stream raw JSON response to disk
|
|
2925
3044
|
max_polls: Maximum number of polling attempts
|
|
2926
3045
|
poll_interval: Seconds between polling attempts
|
|
3046
|
+
on_progress: Optional callback for increasing estimated percentages (0-100).
|
|
2927
3047
|
"""
|
|
2928
3048
|
return self._run_async(
|
|
2929
3049
|
self._async_client.fill(
|
|
@@ -2934,6 +3054,7 @@ class DatalabClient:
|
|
|
2934
3054
|
stream_response_to=stream_response_to,
|
|
2935
3055
|
max_polls=max_polls,
|
|
2936
3056
|
poll_interval=poll_interval,
|
|
3057
|
+
on_progress=on_progress,
|
|
2937
3058
|
)
|
|
2938
3059
|
)
|
|
2939
3060
|
|
|
@@ -2946,6 +3067,7 @@ class DatalabClient:
|
|
|
2946
3067
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
2947
3068
|
max_polls: int = 300,
|
|
2948
3069
|
poll_interval: int = 1,
|
|
3070
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
2949
3071
|
) -> Union[AgentResult, FileResult]:
|
|
2950
3072
|
"""Run a published agent processor on a document (sync version)"""
|
|
2951
3073
|
return self._run_async(
|
|
@@ -2957,6 +3079,7 @@ class DatalabClient:
|
|
|
2957
3079
|
stream_response_to=stream_response_to,
|
|
2958
3080
|
max_polls=max_polls,
|
|
2959
3081
|
poll_interval=poll_interval,
|
|
3082
|
+
on_progress=on_progress,
|
|
2960
3083
|
)
|
|
2961
3084
|
)
|
|
2962
3085
|
|
|
@@ -2969,6 +3092,7 @@ class DatalabClient:
|
|
|
2969
3092
|
stream_response_to: Optional[Union[str, Path]] = None,
|
|
2970
3093
|
max_polls: int = 300,
|
|
2971
3094
|
poll_interval: int = 1,
|
|
3095
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
2972
3096
|
) -> Union[FormFieldsResult, FileResult]:
|
|
2973
3097
|
"""Find the fillable fields in a PDF or image (sync version)"""
|
|
2974
3098
|
return self._run_async(
|
|
@@ -2980,6 +3104,7 @@ class DatalabClient:
|
|
|
2980
3104
|
stream_response_to=stream_response_to,
|
|
2981
3105
|
max_polls=max_polls,
|
|
2982
3106
|
poll_interval=poll_interval,
|
|
3107
|
+
on_progress=on_progress,
|
|
2983
3108
|
)
|
|
2984
3109
|
)
|
|
2985
3110
|
|
|
@@ -3376,6 +3501,7 @@ class DatalabClient:
|
|
|
3376
3501
|
poll_interval: int = 1,
|
|
3377
3502
|
checkpoint_id: Optional[str] = None,
|
|
3378
3503
|
processing_location: Optional[str] = None,
|
|
3504
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
3379
3505
|
) -> PipelineExecution:
|
|
3380
3506
|
"""Execute a pipeline on a file (sync version)"""
|
|
3381
3507
|
return self._run_async(
|
|
@@ -3390,6 +3516,7 @@ class DatalabClient:
|
|
|
3390
3516
|
version=version,
|
|
3391
3517
|
max_polls=max_polls,
|
|
3392
3518
|
poll_interval=poll_interval,
|
|
3519
|
+
on_progress=on_progress,
|
|
3393
3520
|
checkpoint_id=checkpoint_id,
|
|
3394
3521
|
processing_location=processing_location,
|
|
3395
3522
|
)
|
|
@@ -3400,6 +3527,7 @@ class DatalabClient:
|
|
|
3400
3527
|
execution_id: str,
|
|
3401
3528
|
max_polls: int = 1,
|
|
3402
3529
|
poll_interval: int = 1,
|
|
3530
|
+
on_progress: Optional[ProgressCallback] = None,
|
|
3403
3531
|
) -> PipelineExecution:
|
|
3404
3532
|
"""Get pipeline execution status (sync version)"""
|
|
3405
3533
|
return self._run_async(
|
|
@@ -3407,6 +3535,7 @@ class DatalabClient:
|
|
|
3407
3535
|
execution_id=execution_id,
|
|
3408
3536
|
max_polls=max_polls,
|
|
3409
3537
|
poll_interval=poll_interval,
|
|
3538
|
+
on_progress=on_progress,
|
|
3410
3539
|
)
|
|
3411
3540
|
)
|
|
3412
3541
|
|
datalab_sdk/models.py
CHANGED
|
@@ -339,6 +339,7 @@ class ConversionResult:
|
|
|
339
339
|
segmentation_schema: Optional[str] = None
|
|
340
340
|
# True when the run reused a checkpoint of the same file.
|
|
341
341
|
checkpoint_reused: Optional[bool] = None
|
|
342
|
+
progress_percent: Optional[int] = None
|
|
342
343
|
|
|
343
344
|
def save_output(
|
|
344
345
|
self, output_path: Union[str, Path], save_images: bool = True
|
|
@@ -538,6 +539,7 @@ class OCRResult:
|
|
|
538
539
|
versions: Optional[Union[Dict[str, Any], str]] = None
|
|
539
540
|
cost_breakdown: Optional[Dict[str, Any]] = None
|
|
540
541
|
request_id: Optional[str] = None
|
|
542
|
+
progress_percent: Optional[int] = None
|
|
541
543
|
|
|
542
544
|
def get_text(self, page_num: Optional[int] = None) -> str:
|
|
543
545
|
"""Extract text from OCR results"""
|
|
@@ -603,6 +605,7 @@ class FormFillingResult:
|
|
|
603
605
|
request_id: Optional[str] = None
|
|
604
606
|
result_url: Optional[str] = None
|
|
605
607
|
expires_in: Optional[int] = None
|
|
608
|
+
progress_percent: Optional[int] = None
|
|
606
609
|
|
|
607
610
|
def save_output(self, output_path: Union[str, Path]) -> None:
|
|
608
611
|
"""Save the filled form to a file"""
|
|
@@ -660,6 +663,7 @@ class CreateDocumentResult:
|
|
|
660
663
|
request_id: Optional[str] = None
|
|
661
664
|
result_url: Optional[str] = None
|
|
662
665
|
expires_in: Optional[int] = None
|
|
666
|
+
progress_percent: Optional[int] = None
|
|
663
667
|
|
|
664
668
|
def save_output(self, output_path: Union[str, Path]) -> None:
|
|
665
669
|
"""Save the created document to a file"""
|
|
@@ -704,6 +708,7 @@ class AgentResult:
|
|
|
704
708
|
request_id: Optional[str] = None
|
|
705
709
|
result_url: Optional[str] = None
|
|
706
710
|
expires_in: Optional[int] = None
|
|
711
|
+
progress_percent: Optional[int] = None
|
|
707
712
|
|
|
708
713
|
def save_output(
|
|
709
714
|
self, output_path: Union[str, Path], save_images: bool = True
|
|
@@ -761,6 +766,7 @@ class FormFieldsResult:
|
|
|
761
766
|
request_id: Optional[str] = None
|
|
762
767
|
result_url: Optional[str] = None
|
|
763
768
|
expires_in: Optional[int] = None
|
|
769
|
+
progress_percent: Optional[int] = None
|
|
764
770
|
|
|
765
771
|
def save_output(self, output_path: Union[str, Path]) -> None:
|
|
766
772
|
"""Save the detected fields to a JSON file"""
|
|
@@ -806,6 +812,7 @@ class FileResult:
|
|
|
806
812
|
status: str
|
|
807
813
|
output_path: Path
|
|
808
814
|
error: Optional[str] = None
|
|
815
|
+
progress_percent: Optional[int] = None
|
|
809
816
|
|
|
810
817
|
|
|
811
818
|
# --- Extraction Schema models ---
|
|
@@ -894,6 +901,7 @@ class PipelineExecutionStepResult:
|
|
|
894
901
|
checkpoint_id: Optional[str] = None
|
|
895
902
|
source_step_type: Optional[str] = None # for eval steps: the step it scores
|
|
896
903
|
checkpoint_reused: Optional[bool] = None
|
|
904
|
+
progress_percent: Optional[int] = None
|
|
897
905
|
|
|
898
906
|
|
|
899
907
|
@dataclass
|
|
@@ -911,6 +919,7 @@ class PipelineExecution:
|
|
|
911
919
|
config_snapshot: Optional[Dict[str, Any]] = None
|
|
912
920
|
input_config: Optional[Dict[str, Any]] = None
|
|
913
921
|
rate_breakdown: Optional[Dict[str, Any]] = None
|
|
922
|
+
progress_percent: Optional[int] = None
|
|
914
923
|
|
|
915
924
|
|
|
916
925
|
# --- Custom Processor models ---
|
|
File without changes
|
|
File without changes
|
|
File without changes
|