datalab-python-sdk 0.9.2__py3-none-any.whl → 0.11.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: datalab-python-sdk
3
- Version: 0.9.2
3
+ Version: 0.11.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
@@ -125,6 +125,12 @@ print(result.extraction_schema_json, result.extraction_score_average)
125
125
 
126
126
  When you do not set the parse `mode`, the API picks the parse mode that matches `extraction_mode`.
127
127
 
128
+ **Open beta (SDK 0.9.2):** set `citation_granularity="phrase"` in
129
+ `ExtractOptions` for matching words, offsets and match scores. A citation includes
130
+ a box only when the phrase can be located; some citations keep only block/page
131
+ references. Phrase citations cost nothing extra. Turbo returns no citations. See the
132
+ [phrase citation guide](https://documentation.datalab.to/docs/recipes/structured-extraction/api-overview#phrase-level-citations).
133
+
128
134
  ## Redaction
129
135
 
130
136
  **Open beta (SDK 0.9.0):** the redaction API may change.
@@ -153,7 +159,7 @@ PDF, including one with failed verification. Redaction returns a typed result;
153
159
 
154
160
  | Method | Endpoint |
155
161
  | --- | --- |
156
- | `run_agent()` | **Beta:** run an existing published processor (`AgentOptions(processor="cp_...")`) |
162
+ | `run_agent()` | **Beta:** run an existing published processor (`AgentOptions(processor="cp_...")`, or built-in `jats` / `wcag`) |
157
163
  | `segment()` | Split a document into sections (`SegmentOptions`) |
158
164
  | `fill()` | Fill a PDF or image form (`FormFillingOptions`) |
159
165
  | `form_fields()` | Find the fillable fields in a PDF or image |
@@ -166,6 +172,11 @@ PDF, including one with failed verification. Redaction returns a typed result;
166
172
 
167
173
  `run_custom_processor()` and `ocr()` call deprecated API endpoints. Use `run_agent()` and `convert()` instead.
168
174
 
175
+ The published `jats` processor returns JATS XML; `wcag` returns an Accessible PDF.
176
+ Inspect `finished`, `verdict` and `verifier_metrics` before using either artifact.
177
+ [Fixed processor examples](https://documentation.datalab.to/docs/recipes/document-agent/jats-and-accessible-pdf)
178
+ show the result fields and version pinning.
179
+
169
180
  Published-agent execution is in open beta; the API may change. Processor design and raw-prompt execution are not included.
170
181
 
171
182
  ## Inputs, polling and errors
@@ -0,0 +1,13 @@
1
+ datalab_sdk/__init__.py,sha256=bgRAkvlqFmwVdUpZjPf4LfPDzkDM7GLq3FszGKAUn68,3321
2
+ datalab_sdk/auth.py,sha256=X2eccKzpdxogFEDoS4geOHIOeECQ8u3kANxKoqF0PVk,4388
3
+ datalab_sdk/cli.py,sha256=g_qR_xMJS19PYVOf19HRD3nl3GnzHf1bIohh7WY5AO0,63928
4
+ datalab_sdk/client.py,sha256=fPp_tzNEeqtRV7VOviFGxtUPnc7USUzMyyAgQiWvZJ0,158547
5
+ datalab_sdk/exceptions.py,sha256=5-lzlfvB7FKGOhvgyacceTFRRUxton_JqcIyuB8k_mU,2625
6
+ datalab_sdk/mimetypes.py,sha256=a4ULJmHxoR_RMsD0j51hx0t2Q7In_PzNm7UlWX07eEE,932
7
+ datalab_sdk/models.py,sha256=3r9xoAPBf5Tpx7Qg1rUQtKyVRjPKo91g0iHhTHQRe6Y,42408
8
+ datalab_sdk/settings.py,sha256=B_B42QQADAz6ePXQTOqENZllcppFR4JpwonEk2vlzhw,693
9
+ datalab_python_sdk-0.11.0.dist-info/METADATA,sha256=hd_ZyN5LPiickFxcJEXYEV_ebYMMu1-7VOgkfjMCp7o,10034
10
+ datalab_python_sdk-0.11.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
11
+ datalab_python_sdk-0.11.0.dist-info/entry_points.txt,sha256=rqWxO21UV57JxxyeF20iBTxHpzBYOA69hCHIqwdn-Ok,48
12
+ datalab_python_sdk-0.11.0.dist-info/licenses/LICENSE,sha256=XGjT-Uz6t7UZzr3JCZfilsGcZEgMm_1aONcRunohxWg,1064
13
+ datalab_python_sdk-0.11.0.dist-info/RECORD,,
datalab_sdk/__init__.py CHANGED
@@ -52,6 +52,25 @@ from .models import (
52
52
  PipelineExecutionStepResult,
53
53
  CustomProcessor,
54
54
  CustomProcessorVersion,
55
+ Comparison,
56
+ ComparisonDifference,
57
+ ComparisonDifferences,
58
+ ComparisonField,
59
+ ComparisonDocumentResult,
60
+ ComparisonFile,
61
+ ComparisonList,
62
+ ComparisonVariant,
63
+ ComparisonVariantResult,
64
+ # Deprecated aliases of the Comparison models (SDK 0.10.0 names).
65
+ Eval,
66
+ EvalDifference,
67
+ EvalDifferences,
68
+ EvalField,
69
+ EvalDocumentResult,
70
+ EvalFile,
71
+ EvalList,
72
+ EvalVariant,
73
+ EvalVariantResult,
55
74
  )
56
75
  from .settings import settings
57
76
 
@@ -102,4 +121,22 @@ __all__ = [
102
121
  "PipelineExecutionStepResult",
103
122
  "CustomProcessor",
104
123
  "CustomProcessorVersion",
124
+ "Comparison",
125
+ "ComparisonDifference",
126
+ "ComparisonDifferences",
127
+ "ComparisonField",
128
+ "ComparisonDocumentResult",
129
+ "ComparisonFile",
130
+ "ComparisonList",
131
+ "ComparisonVariant",
132
+ "ComparisonVariantResult",
133
+ "Eval",
134
+ "EvalDifference",
135
+ "EvalDifferences",
136
+ "EvalField",
137
+ "EvalDocumentResult",
138
+ "EvalFile",
139
+ "EvalList",
140
+ "EvalVariant",
141
+ "EvalVariantResult",
105
142
  ]
datalab_sdk/cli.py CHANGED
@@ -26,9 +26,11 @@ from datalab_sdk.models import (
26
26
  ProcessingOptions,
27
27
  WorkflowStep,
28
28
  InputConfig,
29
+ ComparisonVariant,
29
30
  )
30
31
  from datalab_sdk.exceptions import DatalabError
31
32
  from datalab_sdk.settings import settings
33
+ import dataclasses
32
34
  import json
33
35
 
34
36
 
@@ -963,10 +965,16 @@ def fill(
963
965
 
964
966
  @click.command("form-fields")
965
967
  @click.argument("path", type=click.Path(exists=True))
968
+ @click.option(
969
+ "--include_text",
970
+ is_flag=True,
971
+ help="Also read the page text and mark each field in it (slower)",
972
+ )
966
973
  @webhook_option
967
974
  @common_options
968
975
  def form_fields(
969
976
  path: str,
977
+ include_text: bool,
970
978
  webhook_url: Optional[str],
971
979
  api_key: str,
972
980
  output_dir: str,
@@ -985,6 +993,7 @@ def form_fields(
985
993
  max_pages=max_pages,
986
994
  page_range=page_range,
987
995
  skip_cache=skip_cache,
996
+ include_text=include_text,
988
997
  )
989
998
  process_documents(
990
999
  path=path,
@@ -1144,6 +1153,290 @@ def create_document(
1144
1153
  sys.exit(1)
1145
1154
 
1146
1155
 
1156
+ # Compare commands (open beta; the API may change). `datalab eval` is the
1157
+ # deprecated 0.10.0 name of the same commands.
1158
+
1159
+ _LEGACY_EVAL_META = "datalab_legacy_eval"
1160
+
1161
+
1162
+ def _compare_client(api_key: Optional[str], base_url: str) -> DatalabClient:
1163
+ if api_key is None:
1164
+ api_key = settings.DATALAB_API_KEY
1165
+ if api_key is None:
1166
+ raise DatalabError(
1167
+ "You must either pass in an api key via --api_key or set the DATALAB_API_KEY env variable. "
1168
+ "Get a free API key at https://www.datalab.to/app/keys"
1169
+ )
1170
+ return DatalabClient(api_key=api_key, base_url=base_url)
1171
+
1172
+
1173
+ def _legacy_eval() -> bool:
1174
+ """True when the command runs as the deprecated `datalab eval`."""
1175
+ return bool(click.get_current_context().meta.get(_LEGACY_EVAL_META))
1176
+
1177
+
1178
+ def _echo_json(result) -> None:
1179
+ """Print a result as JSON. Under `datalab eval`, use the 0.10.0 keys."""
1180
+ data = dataclasses.asdict(result)
1181
+ if _legacy_eval():
1182
+ if "comparison_id" in data:
1183
+ data = {"eval_id": data.pop("comparison_id"), **data}
1184
+ if "comparisons" in data:
1185
+ data["evals"] = [
1186
+ {"eval_id": c.pop("comparison_id"), **c}
1187
+ for c in data.pop("comparisons")
1188
+ ]
1189
+ click.echo(json.dumps(data, indent=2))
1190
+
1191
+
1192
+ def _print_comparison_summary(comparison) -> None:
1193
+ click.echo(
1194
+ f"Comparison {comparison.comparison_id}: {comparison.status} "
1195
+ f"(pipeline {comparison.pipeline_id}, compares {comparison.compared_step})"
1196
+ )
1197
+ for variant in comparison.variants:
1198
+ share = f"{variant.share * 100:.0f}%" if variant.share is not None else "n/a"
1199
+ rate = (
1200
+ f"${variant.rate_per_1000_pages_cents / 100:.2f}/1000 pages"
1201
+ if variant.rate_per_1000_pages_cents is not None
1202
+ else "n/a"
1203
+ )
1204
+ speed = (
1205
+ f"{variant.seconds_per_page:.2f}s/page"
1206
+ if variant.seconds_per_page is not None
1207
+ else "n/a"
1208
+ )
1209
+ click.echo(
1210
+ f" {variant.name}: share={share} decided={variant.decided} won={variant.won} "
1211
+ f"rate={rate} speed={speed}"
1212
+ )
1213
+
1214
+
1215
+ compare_option_api_key = click.option(
1216
+ "--api_key", required=False, help="Datalab API key"
1217
+ )
1218
+ compare_option_base_url = click.option(
1219
+ "--base_url", default=settings.DATALAB_HOST, help="API base URL"
1220
+ )
1221
+ compare_option_json = click.option(
1222
+ "--json", "json_output", is_flag=True, help="Print the raw result as JSON"
1223
+ )
1224
+
1225
+
1226
+ @click.group("compare")
1227
+ def compare_group():
1228
+ """[Open beta] Compare pipeline variants, head to head."""
1229
+ pass
1230
+
1231
+
1232
+ @click.group("eval", hidden=True)
1233
+ @click.pass_context
1234
+ def eval_group(ctx):
1235
+ """Deprecated: use `datalab compare`."""
1236
+ ctx.meta[_LEGACY_EVAL_META] = True
1237
+ click.echo(
1238
+ "Note: `datalab eval` is deprecated. Use `datalab compare` instead.",
1239
+ err=True,
1240
+ )
1241
+
1242
+
1243
+ @click.command("run")
1244
+ @click.argument("paths", nargs=-1, type=click.Path(exists=True))
1245
+ @click.option(
1246
+ "--pipeline",
1247
+ "pipeline_id",
1248
+ required=True,
1249
+ help="Pipeline ID to compare (pl_XXXXX)",
1250
+ )
1251
+ @click.option(
1252
+ "--collection_id",
1253
+ type=int,
1254
+ help="Collection ID to compare, instead of FILE paths",
1255
+ )
1256
+ @click.option(
1257
+ "--variant-json",
1258
+ "variants_json",
1259
+ help='Variants as JSON or a path to a JSON file: [{"name": "Accurate", '
1260
+ '"steps": {"convert": {"output_mode": "accurate"}}}, ...]. Omit to '
1261
+ "compare the default Fast/Balanced/Accurate modes.",
1262
+ )
1263
+ @click.option(
1264
+ "--version", type=int, help="Pipeline version to run (0=draft, omit=active)"
1265
+ )
1266
+ @click.option(
1267
+ "--wait",
1268
+ is_flag=True,
1269
+ help="Poll until the comparison finishes and print a summary",
1270
+ )
1271
+ @click.option(
1272
+ "--poll_interval", default=10, type=int, help="Seconds between polls with --wait"
1273
+ )
1274
+ @click.option(
1275
+ "--timeout", default=7200, type=int, help="Maximum seconds to wait with --wait"
1276
+ )
1277
+ @compare_option_json
1278
+ @compare_option_api_key
1279
+ @compare_option_base_url
1280
+ def compare_run(
1281
+ paths,
1282
+ pipeline_id: str,
1283
+ collection_id: Optional[int],
1284
+ variants_json: Optional[str],
1285
+ version: Optional[int],
1286
+ wait: bool,
1287
+ poll_interval: int,
1288
+ timeout: int,
1289
+ json_output: bool,
1290
+ api_key: Optional[str],
1291
+ base_url: str,
1292
+ ):
1293
+ """[Open beta] Compare pipeline variants on FILE paths or a collection."""
1294
+ try:
1295
+ if bool(paths) == bool(collection_id):
1296
+ raise click.UsageError(
1297
+ "Give either FILE paths or --collection_id, not both."
1298
+ )
1299
+ variants = None
1300
+ if variants_json is not None:
1301
+ data = _load_json_option(variants_json, "--variant-json")
1302
+ variants = [
1303
+ ComparisonVariant(name=v["name"], steps=v.get("steps", {}))
1304
+ for v in data
1305
+ ]
1306
+
1307
+ client = _compare_client(api_key, base_url)
1308
+ file_ids = None
1309
+ if paths:
1310
+ uploaded = client.upload_files(list(paths))
1311
+ if not isinstance(uploaded, list):
1312
+ uploaded = [uploaded]
1313
+ file_ids = [u.file_id for u in uploaded]
1314
+
1315
+ comparison = client.create_comparison(
1316
+ pipeline_id,
1317
+ file_ids=file_ids,
1318
+ collection_id=collection_id,
1319
+ variants=variants,
1320
+ version=version,
1321
+ )
1322
+ if wait:
1323
+ comparison = client.wait_for_comparison(
1324
+ comparison.comparison_id, poll_interval=poll_interval, timeout=timeout
1325
+ )
1326
+ if json_output:
1327
+ _echo_json(comparison)
1328
+ else:
1329
+ _print_comparison_summary(comparison)
1330
+ elif json_output:
1331
+ _echo_json(comparison)
1332
+ else:
1333
+ click.echo(
1334
+ f"Comparison {comparison.comparison_id} started ({comparison.status})."
1335
+ )
1336
+ click.echo(f"Check it with: datalab compare get {comparison.comparison_id}")
1337
+ except DatalabError as e:
1338
+ click.echo(f"Error: {e}", err=True)
1339
+ sys.exit(1)
1340
+
1341
+
1342
+ @click.command("get")
1343
+ @click.argument("comparison_id", type=int)
1344
+ @compare_option_json
1345
+ @compare_option_api_key
1346
+ @compare_option_base_url
1347
+ def compare_get(
1348
+ comparison_id: int, json_output: bool, api_key: Optional[str], base_url: str
1349
+ ):
1350
+ """[Open beta] Get a comparison's status and each variant's result."""
1351
+ try:
1352
+ client = _compare_client(api_key, base_url)
1353
+ comparison = client.get_comparison(comparison_id)
1354
+ if json_output:
1355
+ _echo_json(comparison)
1356
+ else:
1357
+ _print_comparison_summary(comparison)
1358
+ except DatalabError as e:
1359
+ click.echo(f"Error: {e}", err=True)
1360
+ sys.exit(1)
1361
+
1362
+
1363
+ @click.command("list")
1364
+ @click.option("--pipeline_id", help="Only comparisons of this pipeline")
1365
+ @click.option("--collection_id", type=int, help="Only comparisons of this collection")
1366
+ @click.option("--limit", default=20, type=int, help="Maximum number to return")
1367
+ @click.option("--offset", default=0, type=int, help="Offset for pagination")
1368
+ @compare_option_json
1369
+ @compare_option_api_key
1370
+ @compare_option_base_url
1371
+ def compare_list(
1372
+ pipeline_id: Optional[str],
1373
+ collection_id: Optional[int],
1374
+ limit: int,
1375
+ offset: int,
1376
+ json_output: bool,
1377
+ api_key: Optional[str],
1378
+ base_url: str,
1379
+ ):
1380
+ """[Open beta] List the team's comparisons, newest first."""
1381
+ try:
1382
+ client = _compare_client(api_key, base_url)
1383
+ result = client.list_comparisons(
1384
+ pipeline_id=pipeline_id,
1385
+ collection_id=collection_id,
1386
+ limit=limit,
1387
+ offset=offset,
1388
+ )
1389
+ if json_output:
1390
+ _echo_json(result)
1391
+ else:
1392
+ click.echo(f"{result.total} comparison(s):")
1393
+ for comparison in result.comparisons:
1394
+ click.echo(
1395
+ f" {comparison.comparison_id}: {comparison.status} (pipeline {comparison.pipeline_id})"
1396
+ )
1397
+ except DatalabError as e:
1398
+ click.echo(f"Error: {e}", err=True)
1399
+ sys.exit(1)
1400
+
1401
+
1402
+ @click.command("differences")
1403
+ @click.argument("comparison_id", type=int)
1404
+ @click.argument("file_id", type=int)
1405
+ @compare_option_json
1406
+ @compare_option_api_key
1407
+ @compare_option_base_url
1408
+ def compare_differences(
1409
+ comparison_id: int,
1410
+ file_id: int,
1411
+ json_output: bool,
1412
+ api_key: Optional[str],
1413
+ base_url: str,
1414
+ ):
1415
+ """[Open beta] Show where a comparison's variants read one document differently."""
1416
+ try:
1417
+ client = _compare_client(api_key, base_url)
1418
+ result = client.get_comparison_differences(comparison_id, file_id)
1419
+ if json_output:
1420
+ _echo_json(result)
1421
+ else:
1422
+ click.echo(
1423
+ f"File {result.file_id}: variants {', '.join(result.variant_names)}"
1424
+ )
1425
+ for d in result.differences:
1426
+ label = d.question or d.before[:40]
1427
+ click.echo(
1428
+ f" page {d.page} [{d.verdict}] {label!r} -> winners {d.winners}"
1429
+ )
1430
+ except DatalabError as e:
1431
+ click.echo(f"Error: {e}", err=True)
1432
+ sys.exit(1)
1433
+
1434
+
1435
+ for _command in (compare_run, compare_get, compare_list, compare_differences):
1436
+ compare_group.add_command(_command)
1437
+ eval_group.add_command(_command)
1438
+
1439
+
1147
1440
  # Workflow commands
1148
1441
  def _echo_workflows_removed():
1149
1442
  click.echo(
@@ -1652,6 +1945,8 @@ cli.add_command(fill)
1652
1945
  cli.add_command(form_fields)
1653
1946
  cli.add_command(agent)
1654
1947
  cli.add_command(create_document)
1948
+ cli.add_command(compare_group)
1949
+ cli.add_command(eval_group)
1655
1950
  cli.add_command(create_workflow)
1656
1951
  cli.add_command(get_workflow)
1657
1952
  cli.add_command(get_step_types)
datalab_sdk/client.py CHANGED
@@ -65,6 +65,15 @@ from datalab_sdk.models import (
65
65
  PipelineExecutionStepResult,
66
66
  CustomProcessor,
67
67
  CustomProcessorVersion,
68
+ Comparison,
69
+ ComparisonDifference,
70
+ ComparisonDifferences,
71
+ ComparisonDocumentResult,
72
+ ComparisonField,
73
+ ComparisonFile,
74
+ ComparisonList,
75
+ ComparisonVariant,
76
+ ComparisonVariantResult,
68
77
  )
69
78
  from datalab_sdk.settings import settings
70
79
 
@@ -94,6 +103,16 @@ class _ProgressReporter:
94
103
 
95
104
  # HTTP status codes that a POST submission can safely retry. The API sends
96
105
  # 429 for rate limits and 503 when it cannot queue the job ("please retry").
106
+ # Pipeline execution statuses that end polling. ``needs_review``: the output is
107
+ # ready, but a blocking Check failed or the Request hit its cost limit.
108
+ _OUTPUT_READY_PIPELINE_STATUSES = ("completed", "needs_review")
109
+ _TERMINAL_PIPELINE_STATUSES = (
110
+ "completed",
111
+ "completed_with_errors",
112
+ "needs_review",
113
+ "failed",
114
+ )
115
+
97
116
  _SUBMIT_RETRY_STATUSES = (429, 503)
98
117
  _BACKOFF = wait_exponential_jitter(initial=5, max=120)
99
118
  _MAX_RETRY_AFTER_SECONDS = 120.0
@@ -199,6 +218,16 @@ def _warn_workflows_removed() -> None:
199
218
  warnings.warn(_WORKFLOWS_REMOVED_MESSAGE, DeprecationWarning, stacklevel=3)
200
219
 
201
220
 
221
+ def _warn_eval_renamed(old: str, new: str) -> None:
222
+ """Evals became Comparisons in 0.11.0. The 0.10.0 eval methods still work."""
223
+ warnings.warn(
224
+ f"{old}() is deprecated. Use {new}() instead. "
225
+ "This method will be removed in a future version.",
226
+ DeprecationWarning,
227
+ stacklevel=3,
228
+ )
229
+
230
+
202
231
  class _AsyncIterableReader:
203
232
  """Adapts an async iterable of bytes into an async file-like object for ijson."""
204
233
 
@@ -1480,7 +1509,8 @@ class AsyncDatalabClient:
1480
1509
  Find the fillable fields on each page of a PDF or image
1481
1510
 
1482
1511
  The API finds blank lines, empty boxes, tick boxes and signature
1483
- blanks, with their printed labels.
1512
+ blanks, with their printed labels. With options.include_text, it also
1513
+ reads the page text and marks each field in that text.
1484
1514
 
1485
1515
  Args:
1486
1516
  file_path: Path to the PDF or image
@@ -1518,6 +1548,8 @@ class AsyncDatalabClient:
1518
1548
  success=result_data.get("success"),
1519
1549
  error=result_data.get("error"),
1520
1550
  pages=result_data.get("pages"),
1551
+ json=result_data.get("json"),
1552
+ text_error=result_data.get("text_error"),
1521
1553
  page_count=result_data.get("page_count"),
1522
1554
  cost_breakdown=result_data.get("cost_breakdown"),
1523
1555
  runtime=result_data.get("runtime"),
@@ -2620,15 +2652,12 @@ class AsyncDatalabClient:
2620
2652
  execution = self._build_pipeline_execution(response)
2621
2653
  progress = _ProgressReporter(on_progress)
2622
2654
  await progress.report(
2623
- execution.progress_percent, complete=execution.status == "completed"
2655
+ execution.progress_percent,
2656
+ complete=execution.status in _OUTPUT_READY_PIPELINE_STATUSES,
2624
2657
  )
2625
2658
 
2626
2659
  # Poll if requested
2627
- if max_polls > 1 and execution.status not in (
2628
- "completed",
2629
- "completed_with_errors",
2630
- "failed",
2631
- ):
2660
+ if max_polls > 1 and execution.status not in _TERMINAL_PIPELINE_STATUSES:
2632
2661
 
2633
2662
  async def forward_progress(percent: int) -> None:
2634
2663
  await progress.report(percent, complete=percent == 100)
@@ -2664,10 +2693,11 @@ class AsyncDatalabClient:
2664
2693
  )
2665
2694
  execution = self._build_pipeline_execution(response)
2666
2695
  await progress.report(
2667
- execution.progress_percent, complete=execution.status == "completed"
2696
+ execution.progress_percent,
2697
+ complete=execution.status in _OUTPUT_READY_PIPELINE_STATUSES,
2668
2698
  )
2669
2699
 
2670
- if execution.status in ("completed", "completed_with_errors", "failed"):
2700
+ if execution.status in _TERMINAL_PIPELINE_STATUSES:
2671
2701
  return execution
2672
2702
 
2673
2703
  if i < max_polls - 1:
@@ -2860,6 +2890,315 @@ class AsyncDatalabClient:
2860
2890
  "POST", f"/api/v1/custom_processors/{processor_id}/archive"
2861
2891
  )
2862
2892
 
2893
+ # --- Comparison methods (open beta; the API may change) ---
2894
+
2895
+ async def create_comparison(
2896
+ self,
2897
+ pipeline_id: str,
2898
+ *,
2899
+ file_ids: Optional[list[int]] = None,
2900
+ collection_id: Optional[int] = None,
2901
+ variants: Optional[list[ComparisonVariant]] = None,
2902
+ version: Optional[int] = None,
2903
+ ) -> Comparison:
2904
+ """
2905
+ Run 2 to 4 variants of a pipeline on the same documents and compare them.
2906
+
2907
+ Open beta: the API may change.
2908
+
2909
+ Give exactly one of file_ids (uploaded with upload_files()) or
2910
+ collection_id. With no variants, the comparison runs the Fast,
2911
+ Balanced and Accurate modes. A variant may change only the mode
2912
+ settings: for a pipeline of Convert steps, output_mode and
2913
+ merge_cross_page; for a pipeline with one Extract step,
2914
+ extraction_mode and the Convert output_mode.
2915
+
2916
+ Args:
2917
+ pipeline_id: Pipeline ID string (e.g. pl_k8Hx9mP2nQ4v)
2918
+ file_ids: Uploaded file IDs to compare (mutually exclusive with collection_id)
2919
+ collection_id: Collection whose files to compare (mutually exclusive with file_ids)
2920
+ variants: 2 to 4 ComparisonVariant objects, each with a different name.
2921
+ Omit to compare the default modes.
2922
+ version: Pipeline version to run (0=draft, omit=active)
2923
+ """
2924
+ if (file_ids is None) == (collection_id is None):
2925
+ raise DatalabValidationError(
2926
+ "Give exactly one of file_ids or collection_id."
2927
+ )
2928
+ payload: Dict[str, Any] = {}
2929
+ if file_ids is not None:
2930
+ payload["file_ids"] = file_ids
2931
+ if collection_id is not None:
2932
+ payload["collection_id"] = collection_id
2933
+ if variants is not None:
2934
+ payload["variants"] = [v.to_dict() for v in variants]
2935
+ if version is not None:
2936
+ payload["version"] = version
2937
+ response = await self._make_request(
2938
+ "POST", f"/api/v1/pipelines/{pipeline_id}/comparisons", json=payload
2939
+ )
2940
+ return self._build_comparison(response)
2941
+
2942
+ async def get_comparison(self, comparison_id: int) -> Comparison:
2943
+ """
2944
+ Get a comparison's status, each variant's share of the differences, and each document
2945
+
2946
+ Open beta: the API may change.
2947
+
2948
+ Args:
2949
+ comparison_id: The comparison's ID
2950
+ """
2951
+ response = await self._make_request(
2952
+ "GET", f"/api/v1/comparisons/{comparison_id}"
2953
+ )
2954
+ return self._build_comparison(response)
2955
+
2956
+ async def list_comparisons(
2957
+ self,
2958
+ pipeline_id: Optional[str] = None,
2959
+ collection_id: Optional[int] = None,
2960
+ limit: int = 20,
2961
+ offset: int = 0,
2962
+ ) -> ComparisonList:
2963
+ """
2964
+ List the team's comparisons, newest first, without per-document results
2965
+
2966
+ Open beta: the API may change.
2967
+
2968
+ Args:
2969
+ pipeline_id: Only comparisons of this pipeline
2970
+ collection_id: Only comparisons of this collection
2971
+ limit: Maximum number to return (default: 20, max: 100)
2972
+ offset: Offset for pagination (default: 0)
2973
+ """
2974
+ params = f"limit={limit}&offset={offset}"
2975
+ if pipeline_id is not None:
2976
+ params += f"&pipeline_id={pipeline_id}"
2977
+ if collection_id is not None:
2978
+ params += f"&collection_id={collection_id}"
2979
+ response = await self._make_request("GET", f"/api/v1/comparisons?{params}")
2980
+ return ComparisonList(
2981
+ comparisons=[
2982
+ self._build_comparison(c) for c in response.get("comparisons", [])
2983
+ ],
2984
+ total=response.get("total", 0),
2985
+ )
2986
+
2987
+ async def get_comparison_differences(
2988
+ self, comparison_id: int, file_id: int
2989
+ ) -> ComparisonDifferences:
2990
+ """
2991
+ Get where a comparison's variants read one document differently, and which
2992
+ reading matches the page
2993
+
2994
+ Open beta: the API may change.
2995
+
2996
+ Args:
2997
+ comparison_id: The comparison's ID
2998
+ file_id: The file's ID, from get_comparison().files
2999
+ """
3000
+ response = await self._make_request(
3001
+ "GET",
3002
+ f"/api/v1/comparisons/{comparison_id}/files/{file_id}/differences",
3003
+ )
3004
+ return ComparisonDifferences(
3005
+ file_id=response.get("file_id", file_id),
3006
+ variant_names=response.get("variant_names") or [],
3007
+ differences=[
3008
+ self._build_comparison_difference(d)
3009
+ for d in response.get("differences") or []
3010
+ ],
3011
+ fields=[
3012
+ ComparisonField(
3013
+ path=f.get("path", ""),
3014
+ description=f.get("description", ""),
3015
+ values=f.get("values") or [],
3016
+ )
3017
+ for f in response.get("fields") or []
3018
+ ],
3019
+ )
3020
+
3021
+ async def wait_for_comparison(
3022
+ self,
3023
+ comparison_id: int,
3024
+ *,
3025
+ poll_interval: int = 10,
3026
+ timeout: int = 7200,
3027
+ ) -> Comparison:
3028
+ """
3029
+ Poll get_comparison() until the comparison completes or fails
3030
+
3031
+ Open beta: the API may change.
3032
+
3033
+ Args:
3034
+ comparison_id: The comparison's ID
3035
+ poll_interval: Seconds between polls
3036
+ timeout: Maximum seconds to wait before raising DatalabTimeoutError
3037
+ """
3038
+ slept = 0
3039
+ while True:
3040
+ result = await self.get_comparison(comparison_id)
3041
+ if result.status in ("completed", "failed"):
3042
+ return result
3043
+ if slept >= timeout:
3044
+ raise DatalabTimeoutError(
3045
+ f"Comparison {comparison_id} did not finish within {timeout} seconds"
3046
+ )
3047
+ await asyncio.sleep(poll_interval)
3048
+ slept += poll_interval
3049
+
3050
+ # --- Deprecated Eval methods (SDK 0.10.0): use the comparison methods ---
3051
+
3052
+ async def create_eval(
3053
+ self,
3054
+ pipeline_id: str,
3055
+ *,
3056
+ file_ids: Optional[list[int]] = None,
3057
+ collection_id: Optional[int] = None,
3058
+ variants: Optional[list[ComparisonVariant]] = None,
3059
+ version: Optional[int] = None,
3060
+ ) -> Comparison:
3061
+ """Deprecated: use create_comparison()."""
3062
+ _warn_eval_renamed("create_eval", "create_comparison")
3063
+ return await self.create_comparison(
3064
+ pipeline_id,
3065
+ file_ids=file_ids,
3066
+ collection_id=collection_id,
3067
+ variants=variants,
3068
+ version=version,
3069
+ )
3070
+
3071
+ async def get_eval(self, eval_id: int) -> Comparison:
3072
+ """Deprecated: use get_comparison()."""
3073
+ _warn_eval_renamed("get_eval", "get_comparison")
3074
+ return await self.get_comparison(eval_id)
3075
+
3076
+ async def list_evals(
3077
+ self,
3078
+ pipeline_id: Optional[str] = None,
3079
+ collection_id: Optional[int] = None,
3080
+ limit: int = 20,
3081
+ offset: int = 0,
3082
+ ) -> ComparisonList:
3083
+ """Deprecated: use list_comparisons()."""
3084
+ _warn_eval_renamed("list_evals", "list_comparisons")
3085
+ return await self.list_comparisons(
3086
+ pipeline_id=pipeline_id,
3087
+ collection_id=collection_id,
3088
+ limit=limit,
3089
+ offset=offset,
3090
+ )
3091
+
3092
+ async def get_eval_differences(
3093
+ self, eval_id: int, file_id: int
3094
+ ) -> ComparisonDifferences:
3095
+ """Deprecated: use get_comparison_differences()."""
3096
+ _warn_eval_renamed("get_eval_differences", "get_comparison_differences")
3097
+ return await self.get_comparison_differences(eval_id, file_id)
3098
+
3099
+ async def wait_for_eval(
3100
+ self,
3101
+ eval_id: int,
3102
+ *,
3103
+ poll_interval: int = 10,
3104
+ timeout: int = 7200,
3105
+ ) -> Comparison:
3106
+ """Deprecated: use wait_for_comparison()."""
3107
+ _warn_eval_renamed("wait_for_eval", "wait_for_comparison")
3108
+ return await self.wait_for_comparison(
3109
+ eval_id, poll_interval=poll_interval, timeout=timeout
3110
+ )
3111
+
3112
+ @staticmethod
3113
+ def _build_comparison_document_result(
3114
+ data: Dict[str, Any],
3115
+ ) -> ComparisonDocumentResult:
3116
+ return ComparisonDocumentResult(
3117
+ file_name=data.get("file_name", ""),
3118
+ status=data.get("status", ""),
3119
+ file_id=data.get("file_id"),
3120
+ lookup_key=data.get("lookup_key"),
3121
+ request_id=data.get("request_id"),
3122
+ share=data.get("share"),
3123
+ won=data.get("won", 0),
3124
+ decided=data.get("decided", 0),
3125
+ undecided=data.get("undecided", 0),
3126
+ )
3127
+
3128
+ @staticmethod
3129
+ def _build_comparison_file(data: Dict[str, Any]) -> ComparisonFile:
3130
+ return ComparisonFile(
3131
+ file_id=data["file_id"],
3132
+ file_name=data.get("file_name", ""),
3133
+ comparison=data.get("comparison", "pending"),
3134
+ comparison_error=data.get("comparison_error"),
3135
+ )
3136
+
3137
+ @staticmethod
3138
+ def _build_comparison_difference(data: Dict[str, Any]) -> ComparisonDifference:
3139
+ return ComparisonDifference(
3140
+ page=data.get("page", 0),
3141
+ before=data.get("before", ""),
3142
+ after=data.get("after", ""),
3143
+ readings=data.get("readings") or [],
3144
+ winners=data.get("winners") or [],
3145
+ verdict=data.get("verdict", "none"),
3146
+ decided_by=data.get("decided_by", ""),
3147
+ weight=data.get("weight", 0.0),
3148
+ question=data.get("question", ""),
3149
+ boxes=data.get("boxes") or [],
3150
+ description=data.get("description", ""),
3151
+ )
3152
+
3153
+ @classmethod
3154
+ def _build_comparison_variant_result(
3155
+ cls, data: Dict[str, Any]
3156
+ ) -> ComparisonVariantResult:
3157
+ documents = data.get("documents")
3158
+ return ComparisonVariantResult(
3159
+ name=data.get("name", ""),
3160
+ steps=data.get("steps") or {},
3161
+ status=data.get("status", ""),
3162
+ share=data.get("share"),
3163
+ won=data.get("won", 0),
3164
+ decided=data.get("decided", 0),
3165
+ documents_compared=data.get("documents_compared", 0),
3166
+ documents_total=data.get("documents_total", 0),
3167
+ page_breaks_passed=data.get("page_breaks_passed", 0),
3168
+ page_breaks_total=data.get("page_breaks_total", 0),
3169
+ convert_settings=data.get("convert_settings") or {},
3170
+ extract_settings=data.get("extract_settings") or {},
3171
+ undecided=data.get("undecided", 0),
3172
+ rate_per_1000_pages_cents=data.get("rate_per_1000_pages_cents"),
3173
+ seconds_per_page=data.get("seconds_per_page"),
3174
+ documents=[cls._build_comparison_document_result(d) for d in documents]
3175
+ if documents is not None
3176
+ else None,
3177
+ )
3178
+
3179
+ @classmethod
3180
+ def _build_comparison(cls, data: Dict[str, Any]) -> Comparison:
3181
+ files = data.get("files")
3182
+ return Comparison(
3183
+ # The deprecated /evals routes answer with eval_id.
3184
+ comparison_id=data.get("comparison_id", data.get("eval_id")),
3185
+ pipeline_id=data.get("pipeline_id", ""),
3186
+ status=data.get("status", ""),
3187
+ variants=[
3188
+ cls._build_comparison_variant_result(v)
3189
+ for v in data.get("variants") or []
3190
+ ],
3191
+ pipeline_name=data.get("pipeline_name"),
3192
+ pipeline_version=data.get("pipeline_version"),
3193
+ compared_step=data.get("compared_step", "convert"),
3194
+ collection_id=data.get("collection_id"),
3195
+ file_ids=data.get("file_ids"),
3196
+ files=[cls._build_comparison_file(f) for f in files]
3197
+ if files is not None
3198
+ else None,
3199
+ created=data.get("created"),
3200
+ )
3201
+
2863
3202
 
2864
3203
  class DatalabClient:
2865
3204
  """Synchronous wrapper around AsyncDatalabClient"""
@@ -3339,8 +3678,6 @@ class DatalabClient:
3339
3678
  """Delete the stored result of a finished request (sync version)"""
3340
3679
  return self._run_async(self._async_client.delete_result(request_id=request_id))
3341
3680
 
3342
- # --- Eval Rubric methods (sync) ---
3343
-
3344
3681
  # Workflow methods (sync)
3345
3682
  def create_workflow(
3346
3683
  self,
@@ -3815,3 +4152,130 @@ class DatalabClient:
3815
4152
  return self._run_async(
3816
4153
  self._async_client.archive_custom_processor(processor_id=processor_id)
3817
4154
  )
4155
+
4156
+ # --- Comparison methods (sync; open beta, the API may change) ---
4157
+
4158
+ def create_comparison(
4159
+ self,
4160
+ pipeline_id: str,
4161
+ *,
4162
+ file_ids: Optional[list[int]] = None,
4163
+ collection_id: Optional[int] = None,
4164
+ variants: Optional[list[ComparisonVariant]] = None,
4165
+ version: Optional[int] = None,
4166
+ ) -> Comparison:
4167
+ """Run and compare pipeline variants (sync version). Open beta: the API may change."""
4168
+ return self._run_async(
4169
+ self._async_client.create_comparison(
4170
+ pipeline_id,
4171
+ file_ids=file_ids,
4172
+ collection_id=collection_id,
4173
+ variants=variants,
4174
+ version=version,
4175
+ )
4176
+ )
4177
+
4178
+ def get_comparison(self, comparison_id: int) -> Comparison:
4179
+ """Get a comparison's status and results (sync version). Open beta: the API may change."""
4180
+ return self._run_async(self._async_client.get_comparison(comparison_id))
4181
+
4182
+ def list_comparisons(
4183
+ self,
4184
+ pipeline_id: Optional[str] = None,
4185
+ collection_id: Optional[int] = None,
4186
+ limit: int = 20,
4187
+ offset: int = 0,
4188
+ ) -> ComparisonList:
4189
+ """List the team's comparisons (sync version). Open beta: the API may change."""
4190
+ return self._run_async(
4191
+ self._async_client.list_comparisons(
4192
+ pipeline_id=pipeline_id,
4193
+ collection_id=collection_id,
4194
+ limit=limit,
4195
+ offset=offset,
4196
+ )
4197
+ )
4198
+
4199
+ def get_comparison_differences(
4200
+ self, comparison_id: int, file_id: int
4201
+ ) -> ComparisonDifferences:
4202
+ """Get one document's differences (sync version). Open beta: the API may change."""
4203
+ return self._run_async(
4204
+ self._async_client.get_comparison_differences(comparison_id, file_id)
4205
+ )
4206
+
4207
+ def wait_for_comparison(
4208
+ self,
4209
+ comparison_id: int,
4210
+ *,
4211
+ poll_interval: int = 10,
4212
+ timeout: int = 7200,
4213
+ ) -> Comparison:
4214
+ """Poll until the comparison completes or fails (sync version). Open beta: the API may change."""
4215
+ return self._run_async(
4216
+ self._async_client.wait_for_comparison(
4217
+ comparison_id,
4218
+ poll_interval=poll_interval,
4219
+ timeout=timeout,
4220
+ )
4221
+ )
4222
+
4223
+ # --- Deprecated Eval methods (sync, SDK 0.10.0): use the comparison methods ---
4224
+
4225
+ def create_eval(
4226
+ self,
4227
+ pipeline_id: str,
4228
+ *,
4229
+ file_ids: Optional[list[int]] = None,
4230
+ collection_id: Optional[int] = None,
4231
+ variants: Optional[list[ComparisonVariant]] = None,
4232
+ version: Optional[int] = None,
4233
+ ) -> Comparison:
4234
+ """Deprecated: use create_comparison()."""
4235
+ _warn_eval_renamed("create_eval", "create_comparison")
4236
+ return self.create_comparison(
4237
+ pipeline_id,
4238
+ file_ids=file_ids,
4239
+ collection_id=collection_id,
4240
+ variants=variants,
4241
+ version=version,
4242
+ )
4243
+
4244
+ def get_eval(self, eval_id: int) -> Comparison:
4245
+ """Deprecated: use get_comparison()."""
4246
+ _warn_eval_renamed("get_eval", "get_comparison")
4247
+ return self.get_comparison(eval_id)
4248
+
4249
+ def list_evals(
4250
+ self,
4251
+ pipeline_id: Optional[str] = None,
4252
+ collection_id: Optional[int] = None,
4253
+ limit: int = 20,
4254
+ offset: int = 0,
4255
+ ) -> ComparisonList:
4256
+ """Deprecated: use list_comparisons()."""
4257
+ _warn_eval_renamed("list_evals", "list_comparisons")
4258
+ return self.list_comparisons(
4259
+ pipeline_id=pipeline_id,
4260
+ collection_id=collection_id,
4261
+ limit=limit,
4262
+ offset=offset,
4263
+ )
4264
+
4265
+ def get_eval_differences(self, eval_id: int, file_id: int) -> ComparisonDifferences:
4266
+ """Deprecated: use get_comparison_differences()."""
4267
+ _warn_eval_renamed("get_eval_differences", "get_comparison_differences")
4268
+ return self.get_comparison_differences(eval_id, file_id)
4269
+
4270
+ def wait_for_eval(
4271
+ self,
4272
+ eval_id: int,
4273
+ *,
4274
+ poll_interval: int = 10,
4275
+ timeout: int = 7200,
4276
+ ) -> Comparison:
4277
+ """Deprecated: use wait_for_comparison()."""
4278
+ _warn_eval_renamed("wait_for_eval", "wait_for_comparison")
4279
+ return self.wait_for_comparison(
4280
+ eval_id, poll_interval=poll_interval, timeout=timeout
4281
+ )
datalab_sdk/models.py CHANGED
@@ -297,6 +297,9 @@ class FormFieldsOptions(ProcessingOptions):
297
297
 
298
298
  webhook_url: Optional[str] = None
299
299
  processing_location: Optional[str] = None # residency region, e.g. "eu"
300
+ # Also read the page text (fast mode OCR, in parallel) and put each field into
301
+ # it. Slower, and billed as a fast parse plus form fields.
302
+ include_text: bool = False
300
303
 
301
304
 
302
305
  @dataclass
@@ -811,14 +814,23 @@ class FormFieldsResult:
811
814
  """Result from fillable field detection (/form-fields endpoint)
812
815
 
813
816
  Each page is a dict with 'page', 'fields' and 'error' keys. Each field
814
- has 'field_type', 'bbox' ([x0, y0, x1, y1] as page fractions) and
815
- 'label'.
817
+ has 'field_type', 'bbox' ([x0, y0, x1, y1] as page fractions), 'label'
818
+ (the printed label) and 'name' (a short descriptive name, empty when the
819
+ printed label is enough).
820
+
821
+ With FormFieldsOptions(include_text=True), each page also has 'text' (the
822
+ page text with every field marked where a reader meets it) and 'json' is
823
+ the fast mode parse JSON with an <input data-field-index> tag in the HTML
824
+ of each block that holds a field. 'text_error' is set when the page text
825
+ could not be read; the fields are still returned.
816
826
  """
817
827
 
818
828
  status: str
819
829
  success: Optional[bool] = None
820
830
  error: Optional[str] = None
821
831
  pages: Optional[List[Dict[str, Any]]] = None
832
+ json: Optional[Dict[str, Any]] = None
833
+ text_error: Optional[str] = None
822
834
  page_count: Optional[int] = None
823
835
  cost_breakdown: Optional[Dict[str, Any]] = None
824
836
  runtime: Optional[float] = None
@@ -838,6 +850,8 @@ class FormFieldsResult:
838
850
  "success": self.success,
839
851
  "error": self.error,
840
852
  "pages": self.pages,
853
+ "json": self.json,
854
+ "text_error": self.text_error,
841
855
  "page_count": self.page_count,
842
856
  },
843
857
  indent=2,
@@ -971,7 +985,9 @@ class PipelineExecution:
971
985
  execution_id: str # pex_XXXXX
972
986
  pipeline_id: str # pl_XXXXX
973
987
  pipeline_version: int
974
- status: str # pending, running, completed, completed_with_errors, failed
988
+ status: (
989
+ str # pending, running, completed, completed_with_errors, needs_review, failed
990
+ )
975
991
  steps: List[PipelineExecutionStepResult] = field(default_factory=list)
976
992
  started_at: Optional[str] = None
977
993
  completed_at: Optional[str] = None
@@ -1013,3 +1029,188 @@ class CustomProcessorVersion:
1013
1029
  created_at: Optional[str] = None
1014
1030
  runtime: Optional[float] = None
1015
1031
  is_active: bool = False
1032
+
1033
+
1034
+ # --- Comparison models (open beta; the API may change) ---
1035
+ # SDK 0.10.0 named them Eval*. The Eval* names at the end stay as aliases.
1036
+
1037
+
1038
+ @dataclass
1039
+ class ComparisonVariant:
1040
+ """One variant that a comparison runs and compares, with its own settings.
1041
+
1042
+ `steps` maps a step type ("convert" or "extract") to the settings that
1043
+ this variant merges into that step's settings, for example
1044
+ {"convert": {"output_mode": "accurate"}}. Open beta: the API may change.
1045
+ """
1046
+
1047
+ name: str
1048
+ steps: Dict[str, Dict[str, Any]] = field(default_factory=dict)
1049
+
1050
+ def to_dict(self) -> Dict[str, Any]:
1051
+ """Convert to a dict for the create_comparison request body"""
1052
+ return {"name": self.name, "steps": self.steps}
1053
+
1054
+
1055
+ @dataclass
1056
+ class ComparisonDocumentResult:
1057
+ """One document's result for one variant of a comparison (open beta).
1058
+
1059
+ `share` is this variant's share of the decided places (won / decided) on
1060
+ this document. None until the comparison ends, or when nothing was
1061
+ decided.
1062
+ """
1063
+
1064
+ file_name: str
1065
+ status: str # processing, completed, failed
1066
+ file_id: Optional[int] = None
1067
+ lookup_key: Optional[str] = None
1068
+ request_id: Optional[int] = None
1069
+ share: Optional[float] = None
1070
+ won: int = 0
1071
+ decided: int = 0
1072
+ undecided: Optional[int] = 0
1073
+
1074
+
1075
+ @dataclass
1076
+ class ComparisonFile:
1077
+ """One file of a comparison, with its comparison status (open beta)."""
1078
+
1079
+ file_id: int
1080
+ file_name: str
1081
+ comparison: str = (
1082
+ "pending" # pending, starting, running, completed, failed, skipped
1083
+ )
1084
+ comparison_error: Optional[str] = None
1085
+
1086
+
1087
+ @dataclass
1088
+ class ComparisonVariantResult:
1089
+ """One variant's settings and result in a comparison (open beta; the API may change).
1090
+
1091
+ `share` is this variant's share of the decided places (won / decided)
1092
+ over the documents compared so far. It is relative to the other
1093
+ variants in the same comparison, not an absolute quality score.
1094
+ """
1095
+
1096
+ name: str
1097
+ steps: Dict[str, Dict[str, Any]]
1098
+ status: str # running, completed, failed
1099
+ share: Optional[float] = None
1100
+ won: int = 0
1101
+ decided: int = 0
1102
+ documents_compared: int = 0
1103
+ documents_total: int = 0
1104
+ # Tables that continue across a page break, kept as one table. Zero total
1105
+ # when the variants do not differ in merge_cross_page, or no table crosses a break.
1106
+ page_breaks_passed: int = 0
1107
+ page_breaks_total: int = 0
1108
+ # The scored Convert settings this variant ran with: output_mode and merge_cross_page.
1109
+ convert_settings: Dict[str, Any] = field(default_factory=dict)
1110
+ # The scored Extract settings of the variant (extraction_mode), for a comparison of Extract.
1111
+ extract_settings: Dict[str, Any] = field(default_factory=dict)
1112
+ # Places where the variants differ but no reading was decided. None when unknown.
1113
+ undecided: Optional[int] = 0
1114
+ # The list price per 1,000 pages quoted when the variant's requests started
1115
+ # (before any discount), in cents.
1116
+ rate_per_1000_pages_cents: Optional[float] = None
1117
+ seconds_per_page: Optional[float] = None
1118
+ # Per-document results. Only present on get_comparison(), not on create_comparison() or
1119
+ # list_comparisons().
1120
+ documents: Optional[List[ComparisonDocumentResult]] = None
1121
+
1122
+
1123
+ @dataclass
1124
+ class Comparison:
1125
+ """Status and results of a comparison of pipeline variants (open beta; the API may change)."""
1126
+
1127
+ comparison_id: int
1128
+ pipeline_id: str
1129
+ status: str # running, completed, failed
1130
+ variants: List[ComparisonVariantResult] = field(default_factory=list)
1131
+ pipeline_name: Optional[str] = None
1132
+ pipeline_version: Optional[int] = None
1133
+ # "convert" (the pages) or "extract" (the fields of the pipeline's Extract step)
1134
+ compared_step: str = "convert"
1135
+ collection_id: Optional[int] = None
1136
+ file_ids: Optional[List[int]] = None
1137
+ # The files of the comparison, with names and comparison status. Only on get_comparison().
1138
+ files: Optional[List[ComparisonFile]] = None
1139
+ created: Optional[str] = None
1140
+
1141
+ @property
1142
+ def eval_id(self) -> int:
1143
+ """Deprecated: the SDK 0.10.0 name of comparison_id."""
1144
+ return self.comparison_id
1145
+
1146
+
1147
+ @dataclass
1148
+ class ComparisonList:
1149
+ """A page of the team's comparisons, newest first (open beta; the API may change)."""
1150
+
1151
+ comparisons: List[Comparison] = field(default_factory=list)
1152
+ total: int = 0
1153
+
1154
+ @property
1155
+ def evals(self) -> List[Comparison]:
1156
+ """Deprecated: the SDK 0.10.0 name of comparisons."""
1157
+ return self.comparisons
1158
+
1159
+
1160
+ @dataclass
1161
+ class ComparisonDifference:
1162
+ """One place where a comparison's variants read a document differently (open beta).
1163
+
1164
+ `verdict` is "decided", "none", "unclear" or "ignored". `decided_by` is
1165
+ "text_layer", "judge", or "" when not decided. For a table difference,
1166
+ `question` holds the question about the cell in place of before/after.
1167
+ For a comparison of Extract, `description` is the schema's description of the
1168
+ field that `question` names.
1169
+ """
1170
+
1171
+ page: int
1172
+ before: str
1173
+ after: str
1174
+ readings: List[str] = field(default_factory=list)
1175
+ winners: List[int] = field(default_factory=list)
1176
+ verdict: str = "none"
1177
+ decided_by: str = ""
1178
+ weight: float = 0.0
1179
+ question: str = ""
1180
+ boxes: List[List[float]] = field(default_factory=list)
1181
+ description: str = ""
1182
+
1183
+
1184
+ @dataclass
1185
+ class ComparisonField:
1186
+ """A comparison of Extract: one compared field and each variant's value, equal or not (open beta).
1187
+
1188
+ `values` follows ComparisonDifferences.variant_names. An empty string means no value.
1189
+ """
1190
+
1191
+ path: str
1192
+ description: str = ""
1193
+ values: List[str] = field(default_factory=list)
1194
+
1195
+
1196
+ @dataclass
1197
+ class ComparisonDifferences:
1198
+ """Where a comparison's variants read one document differently (open beta; the API may change)."""
1199
+
1200
+ file_id: int
1201
+ variant_names: List[str] = field(default_factory=list)
1202
+ differences: List[ComparisonDifference] = field(default_factory=list)
1203
+ # A comparison of Extract: every compared field with each variant's value. Empty for Convert.
1204
+ fields: List[ComparisonField] = field(default_factory=list)
1205
+
1206
+
1207
+ # Deprecated aliases: the names of SDK 0.10.0. Use the Comparison* names.
1208
+ Eval = Comparison
1209
+ EvalVariant = ComparisonVariant
1210
+ EvalVariantResult = ComparisonVariantResult
1211
+ EvalDocumentResult = ComparisonDocumentResult
1212
+ EvalFile = ComparisonFile
1213
+ EvalList = ComparisonList
1214
+ EvalDifference = ComparisonDifference
1215
+ EvalDifferences = ComparisonDifferences
1216
+ EvalField = ComparisonField
@@ -1,13 +0,0 @@
1
- datalab_sdk/__init__.py,sha256=O95y4a-N34dxyDak6YWrUjEG4kdtVirgBqShh1L6z_Q,2475
2
- datalab_sdk/auth.py,sha256=X2eccKzpdxogFEDoS4geOHIOeECQ8u3kANxKoqF0PVk,4388
3
- datalab_sdk/cli.py,sha256=6tYZhkx1f4enOU2tvqC43aDW1dI_agJrOCBG5RAJwvg,54490
4
- datalab_sdk/client.py,sha256=NaGY8NKAcOjaBIV0adS_n6diOu710Az581zYdt4jwKM,141435
5
- datalab_sdk/exceptions.py,sha256=5-lzlfvB7FKGOhvgyacceTFRRUxton_JqcIyuB8k_mU,2625
6
- datalab_sdk/mimetypes.py,sha256=a4ULJmHxoR_RMsD0j51hx0t2Q7In_PzNm7UlWX07eEE,932
7
- datalab_sdk/models.py,sha256=tr5pGsbI9x7GDrN4BAyWMEMWLcF1goJ5Ot8X4pFeT5k,35081
8
- datalab_sdk/settings.py,sha256=B_B42QQADAz6ePXQTOqENZllcppFR4JpwonEk2vlzhw,693
9
- datalab_python_sdk-0.9.2.dist-info/METADATA,sha256=_6OLIHKgM0EZAh0BUC5-0VcuxXCHO3DV4mXRrBEwQYQ,9236
10
- datalab_python_sdk-0.9.2.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
11
- datalab_python_sdk-0.9.2.dist-info/entry_points.txt,sha256=rqWxO21UV57JxxyeF20iBTxHpzBYOA69hCHIqwdn-Ok,48
12
- datalab_python_sdk-0.9.2.dist-info/licenses/LICENSE,sha256=XGjT-Uz6t7UZzr3JCZfilsGcZEgMm_1aONcRunohxWg,1064
13
- datalab_python_sdk-0.9.2.dist-info/RECORD,,