datalab-python-sdk 0.10.0__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.
- {datalab_python_sdk-0.10.0.dist-info → datalab_python_sdk-0.11.0.dist-info}/METADATA +1 -1
- datalab_python_sdk-0.11.0.dist-info/RECORD +13 -0
- datalab_sdk/__init__.py +19 -0
- datalab_sdk/cli.py +119 -67
- datalab_sdk/client.py +227 -80
- datalab_sdk/models.py +58 -34
- datalab_python_sdk-0.10.0.dist-info/RECORD +0 -13
- {datalab_python_sdk-0.10.0.dist-info → datalab_python_sdk-0.11.0.dist-info}/WHEEL +0 -0
- {datalab_python_sdk-0.10.0.dist-info → datalab_python_sdk-0.11.0.dist-info}/entry_points.txt +0 -0
- {datalab_python_sdk-0.10.0.dist-info → datalab_python_sdk-0.11.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -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,16 @@ 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).
|
|
55
65
|
Eval,
|
|
56
66
|
EvalDifference,
|
|
57
67
|
EvalDifferences,
|
|
@@ -111,6 +121,15 @@ __all__ = [
|
|
|
111
121
|
"PipelineExecutionStepResult",
|
|
112
122
|
"CustomProcessor",
|
|
113
123
|
"CustomProcessorVersion",
|
|
124
|
+
"Comparison",
|
|
125
|
+
"ComparisonDifference",
|
|
126
|
+
"ComparisonDifferences",
|
|
127
|
+
"ComparisonField",
|
|
128
|
+
"ComparisonDocumentResult",
|
|
129
|
+
"ComparisonFile",
|
|
130
|
+
"ComparisonList",
|
|
131
|
+
"ComparisonVariant",
|
|
132
|
+
"ComparisonVariantResult",
|
|
114
133
|
"Eval",
|
|
115
134
|
"EvalDifference",
|
|
116
135
|
"EvalDifferences",
|
datalab_sdk/cli.py
CHANGED
|
@@ -26,7 +26,7 @@ from datalab_sdk.models import (
|
|
|
26
26
|
ProcessingOptions,
|
|
27
27
|
WorkflowStep,
|
|
28
28
|
InputConfig,
|
|
29
|
-
|
|
29
|
+
ComparisonVariant,
|
|
30
30
|
)
|
|
31
31
|
from datalab_sdk.exceptions import DatalabError
|
|
32
32
|
from datalab_sdk.settings import settings
|
|
@@ -1153,10 +1153,13 @@ def create_document(
|
|
|
1153
1153
|
sys.exit(1)
|
|
1154
1154
|
|
|
1155
1155
|
|
|
1156
|
-
#
|
|
1156
|
+
# Compare commands (open beta; the API may change). `datalab eval` is the
|
|
1157
|
+
# deprecated 0.10.0 name of the same commands.
|
|
1157
1158
|
|
|
1159
|
+
_LEGACY_EVAL_META = "datalab_legacy_eval"
|
|
1158
1160
|
|
|
1159
|
-
|
|
1161
|
+
|
|
1162
|
+
def _compare_client(api_key: Optional[str], base_url: str) -> DatalabClient:
|
|
1160
1163
|
if api_key is None:
|
|
1161
1164
|
api_key = settings.DATALAB_API_KEY
|
|
1162
1165
|
if api_key is None:
|
|
@@ -1167,12 +1170,31 @@ def _eval_client(api_key: Optional[str], base_url: str) -> DatalabClient:
|
|
|
1167
1170
|
return DatalabClient(api_key=api_key, base_url=base_url)
|
|
1168
1171
|
|
|
1169
1172
|
|
|
1170
|
-
def
|
|
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:
|
|
1171
1193
|
click.echo(
|
|
1172
|
-
f"
|
|
1173
|
-
f"(pipeline {
|
|
1194
|
+
f"Comparison {comparison.comparison_id}: {comparison.status} "
|
|
1195
|
+
f"(pipeline {comparison.pipeline_id}, compares {comparison.compared_step})"
|
|
1174
1196
|
)
|
|
1175
|
-
for variant in
|
|
1197
|
+
for variant in comparison.variants:
|
|
1176
1198
|
share = f"{variant.share * 100:.0f}%" if variant.share is not None else "n/a"
|
|
1177
1199
|
rate = (
|
|
1178
1200
|
f"${variant.rate_per_1000_pages_cents / 100:.2f}/1000 pages"
|
|
@@ -1190,33 +1212,46 @@ def _print_eval_summary(evaluation) -> None:
|
|
|
1190
1212
|
)
|
|
1191
1213
|
|
|
1192
1214
|
|
|
1193
|
-
|
|
1194
|
-
|
|
1215
|
+
compare_option_api_key = click.option(
|
|
1216
|
+
"--api_key", required=False, help="Datalab API key"
|
|
1217
|
+
)
|
|
1218
|
+
compare_option_base_url = click.option(
|
|
1195
1219
|
"--base_url", default=settings.DATALAB_HOST, help="API base URL"
|
|
1196
1220
|
)
|
|
1197
|
-
|
|
1221
|
+
compare_option_json = click.option(
|
|
1198
1222
|
"--json", "json_output", is_flag=True, help="Print the raw result as JSON"
|
|
1199
1223
|
)
|
|
1200
1224
|
|
|
1201
1225
|
|
|
1202
|
-
@click.group("
|
|
1203
|
-
def
|
|
1226
|
+
@click.group("compare")
|
|
1227
|
+
def compare_group():
|
|
1204
1228
|
"""[Open beta] Compare pipeline variants, head to head."""
|
|
1205
1229
|
pass
|
|
1206
1230
|
|
|
1207
1231
|
|
|
1208
|
-
@
|
|
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")
|
|
1209
1244
|
@click.argument("paths", nargs=-1, type=click.Path(exists=True))
|
|
1210
1245
|
@click.option(
|
|
1211
1246
|
"--pipeline",
|
|
1212
1247
|
"pipeline_id",
|
|
1213
1248
|
required=True,
|
|
1214
|
-
help="Pipeline ID to
|
|
1249
|
+
help="Pipeline ID to compare (pl_XXXXX)",
|
|
1215
1250
|
)
|
|
1216
1251
|
@click.option(
|
|
1217
1252
|
"--collection_id",
|
|
1218
1253
|
type=int,
|
|
1219
|
-
help="Collection ID to
|
|
1254
|
+
help="Collection ID to compare, instead of FILE paths",
|
|
1220
1255
|
)
|
|
1221
1256
|
@click.option(
|
|
1222
1257
|
"--variant-json",
|
|
@@ -1229,7 +1264,9 @@ def eval_group():
|
|
|
1229
1264
|
"--version", type=int, help="Pipeline version to run (0=draft, omit=active)"
|
|
1230
1265
|
)
|
|
1231
1266
|
@click.option(
|
|
1232
|
-
"--wait",
|
|
1267
|
+
"--wait",
|
|
1268
|
+
is_flag=True,
|
|
1269
|
+
help="Poll until the comparison finishes and print a summary",
|
|
1233
1270
|
)
|
|
1234
1271
|
@click.option(
|
|
1235
1272
|
"--poll_interval", default=10, type=int, help="Seconds between polls with --wait"
|
|
@@ -1237,10 +1274,10 @@ def eval_group():
|
|
|
1237
1274
|
@click.option(
|
|
1238
1275
|
"--timeout", default=7200, type=int, help="Maximum seconds to wait with --wait"
|
|
1239
1276
|
)
|
|
1240
|
-
@
|
|
1241
|
-
@
|
|
1242
|
-
@
|
|
1243
|
-
def
|
|
1277
|
+
@compare_option_json
|
|
1278
|
+
@compare_option_api_key
|
|
1279
|
+
@compare_option_base_url
|
|
1280
|
+
def compare_run(
|
|
1244
1281
|
paths,
|
|
1245
1282
|
pipeline_id: str,
|
|
1246
1283
|
collection_id: Optional[int],
|
|
@@ -1253,7 +1290,7 @@ def eval_run(
|
|
|
1253
1290
|
api_key: Optional[str],
|
|
1254
1291
|
base_url: str,
|
|
1255
1292
|
):
|
|
1256
|
-
"""[Open beta]
|
|
1293
|
+
"""[Open beta] Compare pipeline variants on FILE paths or a collection."""
|
|
1257
1294
|
try:
|
|
1258
1295
|
if bool(paths) == bool(collection_id):
|
|
1259
1296
|
raise click.UsageError(
|
|
@@ -1263,10 +1300,11 @@ def eval_run(
|
|
|
1263
1300
|
if variants_json is not None:
|
|
1264
1301
|
data = _load_json_option(variants_json, "--variant-json")
|
|
1265
1302
|
variants = [
|
|
1266
|
-
|
|
1303
|
+
ComparisonVariant(name=v["name"], steps=v.get("steps", {}))
|
|
1304
|
+
for v in data
|
|
1267
1305
|
]
|
|
1268
1306
|
|
|
1269
|
-
client =
|
|
1307
|
+
client = _compare_client(api_key, base_url)
|
|
1270
1308
|
file_ids = None
|
|
1271
1309
|
if paths:
|
|
1272
1310
|
uploaded = client.upload_files(list(paths))
|
|
@@ -1274,7 +1312,7 @@ def eval_run(
|
|
|
1274
1312
|
uploaded = [uploaded]
|
|
1275
1313
|
file_ids = [u.file_id for u in uploaded]
|
|
1276
1314
|
|
|
1277
|
-
|
|
1315
|
+
comparison = client.create_comparison(
|
|
1278
1316
|
pipeline_id,
|
|
1279
1317
|
file_ids=file_ids,
|
|
1280
1318
|
collection_id=collection_id,
|
|
@@ -1282,51 +1320,55 @@ def eval_run(
|
|
|
1282
1320
|
version=version,
|
|
1283
1321
|
)
|
|
1284
1322
|
if wait:
|
|
1285
|
-
|
|
1286
|
-
|
|
1323
|
+
comparison = client.wait_for_comparison(
|
|
1324
|
+
comparison.comparison_id, poll_interval=poll_interval, timeout=timeout
|
|
1287
1325
|
)
|
|
1288
1326
|
if json_output:
|
|
1289
|
-
|
|
1327
|
+
_echo_json(comparison)
|
|
1290
1328
|
else:
|
|
1291
|
-
|
|
1329
|
+
_print_comparison_summary(comparison)
|
|
1292
1330
|
elif json_output:
|
|
1293
|
-
|
|
1331
|
+
_echo_json(comparison)
|
|
1294
1332
|
else:
|
|
1295
|
-
click.echo(
|
|
1296
|
-
|
|
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}")
|
|
1297
1337
|
except DatalabError as e:
|
|
1298
1338
|
click.echo(f"Error: {e}", err=True)
|
|
1299
1339
|
sys.exit(1)
|
|
1300
1340
|
|
|
1301
1341
|
|
|
1302
|
-
@
|
|
1303
|
-
@click.argument("
|
|
1304
|
-
@
|
|
1305
|
-
@
|
|
1306
|
-
@
|
|
1307
|
-
def
|
|
1308
|
-
|
|
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."""
|
|
1309
1351
|
try:
|
|
1310
|
-
client =
|
|
1311
|
-
|
|
1352
|
+
client = _compare_client(api_key, base_url)
|
|
1353
|
+
comparison = client.get_comparison(comparison_id)
|
|
1312
1354
|
if json_output:
|
|
1313
|
-
|
|
1355
|
+
_echo_json(comparison)
|
|
1314
1356
|
else:
|
|
1315
|
-
|
|
1357
|
+
_print_comparison_summary(comparison)
|
|
1316
1358
|
except DatalabError as e:
|
|
1317
1359
|
click.echo(f"Error: {e}", err=True)
|
|
1318
1360
|
sys.exit(1)
|
|
1319
1361
|
|
|
1320
1362
|
|
|
1321
|
-
@
|
|
1322
|
-
@click.option("--pipeline_id", help="Only
|
|
1323
|
-
@click.option("--collection_id", type=int, help="Only
|
|
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")
|
|
1324
1366
|
@click.option("--limit", default=20, type=int, help="Maximum number to return")
|
|
1325
1367
|
@click.option("--offset", default=0, type=int, help="Offset for pagination")
|
|
1326
|
-
@
|
|
1327
|
-
@
|
|
1328
|
-
@
|
|
1329
|
-
def
|
|
1368
|
+
@compare_option_json
|
|
1369
|
+
@compare_option_api_key
|
|
1370
|
+
@compare_option_base_url
|
|
1371
|
+
def compare_list(
|
|
1330
1372
|
pipeline_id: Optional[str],
|
|
1331
1373
|
collection_id: Optional[int],
|
|
1332
1374
|
limit: int,
|
|
@@ -1335,43 +1377,47 @@ def eval_list(
|
|
|
1335
1377
|
api_key: Optional[str],
|
|
1336
1378
|
base_url: str,
|
|
1337
1379
|
):
|
|
1338
|
-
"""[Open beta] List the team's
|
|
1380
|
+
"""[Open beta] List the team's comparisons, newest first."""
|
|
1339
1381
|
try:
|
|
1340
|
-
client =
|
|
1341
|
-
result = client.
|
|
1382
|
+
client = _compare_client(api_key, base_url)
|
|
1383
|
+
result = client.list_comparisons(
|
|
1342
1384
|
pipeline_id=pipeline_id,
|
|
1343
1385
|
collection_id=collection_id,
|
|
1344
1386
|
limit=limit,
|
|
1345
1387
|
offset=offset,
|
|
1346
1388
|
)
|
|
1347
1389
|
if json_output:
|
|
1348
|
-
|
|
1390
|
+
_echo_json(result)
|
|
1349
1391
|
else:
|
|
1350
|
-
click.echo(f"{result.total}
|
|
1351
|
-
for
|
|
1392
|
+
click.echo(f"{result.total} comparison(s):")
|
|
1393
|
+
for comparison in result.comparisons:
|
|
1352
1394
|
click.echo(
|
|
1353
|
-
f" {
|
|
1395
|
+
f" {comparison.comparison_id}: {comparison.status} (pipeline {comparison.pipeline_id})"
|
|
1354
1396
|
)
|
|
1355
1397
|
except DatalabError as e:
|
|
1356
1398
|
click.echo(f"Error: {e}", err=True)
|
|
1357
1399
|
sys.exit(1)
|
|
1358
1400
|
|
|
1359
1401
|
|
|
1360
|
-
@
|
|
1361
|
-
@click.argument("
|
|
1402
|
+
@click.command("differences")
|
|
1403
|
+
@click.argument("comparison_id", type=int)
|
|
1362
1404
|
@click.argument("file_id", type=int)
|
|
1363
|
-
@
|
|
1364
|
-
@
|
|
1365
|
-
@
|
|
1366
|
-
def
|
|
1367
|
-
|
|
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,
|
|
1368
1414
|
):
|
|
1369
|
-
"""[Open beta] Show where
|
|
1415
|
+
"""[Open beta] Show where a comparison's variants read one document differently."""
|
|
1370
1416
|
try:
|
|
1371
|
-
client =
|
|
1372
|
-
result = client.
|
|
1417
|
+
client = _compare_client(api_key, base_url)
|
|
1418
|
+
result = client.get_comparison_differences(comparison_id, file_id)
|
|
1373
1419
|
if json_output:
|
|
1374
|
-
|
|
1420
|
+
_echo_json(result)
|
|
1375
1421
|
else:
|
|
1376
1422
|
click.echo(
|
|
1377
1423
|
f"File {result.file_id}: variants {', '.join(result.variant_names)}"
|
|
@@ -1386,6 +1432,11 @@ def eval_differences(
|
|
|
1386
1432
|
sys.exit(1)
|
|
1387
1433
|
|
|
1388
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
|
+
|
|
1389
1440
|
# Workflow commands
|
|
1390
1441
|
def _echo_workflows_removed():
|
|
1391
1442
|
click.echo(
|
|
@@ -1894,6 +1945,7 @@ cli.add_command(fill)
|
|
|
1894
1945
|
cli.add_command(form_fields)
|
|
1895
1946
|
cli.add_command(agent)
|
|
1896
1947
|
cli.add_command(create_document)
|
|
1948
|
+
cli.add_command(compare_group)
|
|
1897
1949
|
cli.add_command(eval_group)
|
|
1898
1950
|
cli.add_command(create_workflow)
|
|
1899
1951
|
cli.add_command(get_workflow)
|
datalab_sdk/client.py
CHANGED
|
@@ -65,15 +65,15 @@ from datalab_sdk.models import (
|
|
|
65
65
|
PipelineExecutionStepResult,
|
|
66
66
|
CustomProcessor,
|
|
67
67
|
CustomProcessorVersion,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
Comparison,
|
|
69
|
+
ComparisonDifference,
|
|
70
|
+
ComparisonDifferences,
|
|
71
|
+
ComparisonDocumentResult,
|
|
72
|
+
ComparisonField,
|
|
73
|
+
ComparisonFile,
|
|
74
|
+
ComparisonList,
|
|
75
|
+
ComparisonVariant,
|
|
76
|
+
ComparisonVariantResult,
|
|
77
77
|
)
|
|
78
78
|
from datalab_sdk.settings import settings
|
|
79
79
|
|
|
@@ -218,6 +218,16 @@ def _warn_workflows_removed() -> None:
|
|
|
218
218
|
warnings.warn(_WORKFLOWS_REMOVED_MESSAGE, DeprecationWarning, stacklevel=3)
|
|
219
219
|
|
|
220
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
|
+
|
|
221
231
|
class _AsyncIterableReader:
|
|
222
232
|
"""Adapts an async iterable of bytes into an async file-like object for ijson."""
|
|
223
233
|
|
|
@@ -2880,24 +2890,24 @@ class AsyncDatalabClient:
|
|
|
2880
2890
|
"POST", f"/api/v1/custom_processors/{processor_id}/archive"
|
|
2881
2891
|
)
|
|
2882
2892
|
|
|
2883
|
-
# ---
|
|
2893
|
+
# --- Comparison methods (open beta; the API may change) ---
|
|
2884
2894
|
|
|
2885
|
-
async def
|
|
2895
|
+
async def create_comparison(
|
|
2886
2896
|
self,
|
|
2887
2897
|
pipeline_id: str,
|
|
2888
2898
|
*,
|
|
2889
2899
|
file_ids: Optional[list[int]] = None,
|
|
2890
2900
|
collection_id: Optional[int] = None,
|
|
2891
|
-
variants: Optional[list[
|
|
2901
|
+
variants: Optional[list[ComparisonVariant]] = None,
|
|
2892
2902
|
version: Optional[int] = None,
|
|
2893
|
-
) ->
|
|
2903
|
+
) -> Comparison:
|
|
2894
2904
|
"""
|
|
2895
2905
|
Run 2 to 4 variants of a pipeline on the same documents and compare them.
|
|
2896
2906
|
|
|
2897
2907
|
Open beta: the API may change.
|
|
2898
2908
|
|
|
2899
2909
|
Give exactly one of file_ids (uploaded with upload_files()) or
|
|
2900
|
-
collection_id. With no variants, the
|
|
2910
|
+
collection_id. With no variants, the comparison runs the Fast,
|
|
2901
2911
|
Balanced and Accurate modes. A variant may change only the mode
|
|
2902
2912
|
settings: for a pipeline of Convert steps, output_mode and
|
|
2903
2913
|
merge_cross_page; for a pipeline with one Extract step,
|
|
@@ -2907,7 +2917,7 @@ class AsyncDatalabClient:
|
|
|
2907
2917
|
pipeline_id: Pipeline ID string (e.g. pl_k8Hx9mP2nQ4v)
|
|
2908
2918
|
file_ids: Uploaded file IDs to compare (mutually exclusive with collection_id)
|
|
2909
2919
|
collection_id: Collection whose files to compare (mutually exclusive with file_ids)
|
|
2910
|
-
variants: 2 to 4
|
|
2920
|
+
variants: 2 to 4 ComparisonVariant objects, each with a different name.
|
|
2911
2921
|
Omit to compare the default modes.
|
|
2912
2922
|
version: Pipeline version to run (0=draft, omit=active)
|
|
2913
2923
|
"""
|
|
@@ -2925,37 +2935,39 @@ class AsyncDatalabClient:
|
|
|
2925
2935
|
if version is not None:
|
|
2926
2936
|
payload["version"] = version
|
|
2927
2937
|
response = await self._make_request(
|
|
2928
|
-
"POST", f"/api/v1/pipelines/{pipeline_id}/
|
|
2938
|
+
"POST", f"/api/v1/pipelines/{pipeline_id}/comparisons", json=payload
|
|
2929
2939
|
)
|
|
2930
|
-
return self.
|
|
2940
|
+
return self._build_comparison(response)
|
|
2931
2941
|
|
|
2932
|
-
async def
|
|
2942
|
+
async def get_comparison(self, comparison_id: int) -> Comparison:
|
|
2933
2943
|
"""
|
|
2934
|
-
Get
|
|
2944
|
+
Get a comparison's status, each variant's share of the differences, and each document
|
|
2935
2945
|
|
|
2936
2946
|
Open beta: the API may change.
|
|
2937
2947
|
|
|
2938
2948
|
Args:
|
|
2939
|
-
|
|
2949
|
+
comparison_id: The comparison's ID
|
|
2940
2950
|
"""
|
|
2941
|
-
response = await self._make_request(
|
|
2942
|
-
|
|
2951
|
+
response = await self._make_request(
|
|
2952
|
+
"GET", f"/api/v1/comparisons/{comparison_id}"
|
|
2953
|
+
)
|
|
2954
|
+
return self._build_comparison(response)
|
|
2943
2955
|
|
|
2944
|
-
async def
|
|
2956
|
+
async def list_comparisons(
|
|
2945
2957
|
self,
|
|
2946
2958
|
pipeline_id: Optional[str] = None,
|
|
2947
2959
|
collection_id: Optional[int] = None,
|
|
2948
2960
|
limit: int = 20,
|
|
2949
2961
|
offset: int = 0,
|
|
2950
|
-
) ->
|
|
2962
|
+
) -> ComparisonList:
|
|
2951
2963
|
"""
|
|
2952
|
-
List the team's
|
|
2964
|
+
List the team's comparisons, newest first, without per-document results
|
|
2953
2965
|
|
|
2954
2966
|
Open beta: the API may change.
|
|
2955
2967
|
|
|
2956
2968
|
Args:
|
|
2957
|
-
pipeline_id: Only
|
|
2958
|
-
collection_id: Only
|
|
2969
|
+
pipeline_id: Only comparisons of this pipeline
|
|
2970
|
+
collection_id: Only comparisons of this collection
|
|
2959
2971
|
limit: Maximum number to return (default: 20, max: 100)
|
|
2960
2972
|
offset: Offset for pagination (default: 0)
|
|
2961
2973
|
"""
|
|
@@ -2964,35 +2976,40 @@ class AsyncDatalabClient:
|
|
|
2964
2976
|
params += f"&pipeline_id={pipeline_id}"
|
|
2965
2977
|
if collection_id is not None:
|
|
2966
2978
|
params += f"&collection_id={collection_id}"
|
|
2967
|
-
response = await self._make_request("GET", f"/api/v1/
|
|
2968
|
-
return
|
|
2969
|
-
|
|
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
|
+
],
|
|
2970
2984
|
total=response.get("total", 0),
|
|
2971
2985
|
)
|
|
2972
2986
|
|
|
2973
|
-
async def
|
|
2987
|
+
async def get_comparison_differences(
|
|
2988
|
+
self, comparison_id: int, file_id: int
|
|
2989
|
+
) -> ComparisonDifferences:
|
|
2974
2990
|
"""
|
|
2975
|
-
Get where
|
|
2976
|
-
matches the page
|
|
2991
|
+
Get where a comparison's variants read one document differently, and which
|
|
2992
|
+
reading matches the page
|
|
2977
2993
|
|
|
2978
2994
|
Open beta: the API may change.
|
|
2979
2995
|
|
|
2980
2996
|
Args:
|
|
2981
|
-
|
|
2982
|
-
file_id: The file's ID, from
|
|
2997
|
+
comparison_id: The comparison's ID
|
|
2998
|
+
file_id: The file's ID, from get_comparison().files
|
|
2983
2999
|
"""
|
|
2984
3000
|
response = await self._make_request(
|
|
2985
|
-
"GET",
|
|
3001
|
+
"GET",
|
|
3002
|
+
f"/api/v1/comparisons/{comparison_id}/files/{file_id}/differences",
|
|
2986
3003
|
)
|
|
2987
|
-
return
|
|
3004
|
+
return ComparisonDifferences(
|
|
2988
3005
|
file_id=response.get("file_id", file_id),
|
|
2989
3006
|
variant_names=response.get("variant_names") or [],
|
|
2990
3007
|
differences=[
|
|
2991
|
-
self.
|
|
3008
|
+
self._build_comparison_difference(d)
|
|
2992
3009
|
for d in response.get("differences") or []
|
|
2993
3010
|
],
|
|
2994
3011
|
fields=[
|
|
2995
|
-
|
|
3012
|
+
ComparisonField(
|
|
2996
3013
|
path=f.get("path", ""),
|
|
2997
3014
|
description=f.get("description", ""),
|
|
2998
3015
|
values=f.get("values") or [],
|
|
@@ -3001,38 +3018,102 @@ class AsyncDatalabClient:
|
|
|
3001
3018
|
],
|
|
3002
3019
|
)
|
|
3003
3020
|
|
|
3004
|
-
async def
|
|
3021
|
+
async def wait_for_comparison(
|
|
3005
3022
|
self,
|
|
3006
|
-
|
|
3023
|
+
comparison_id: int,
|
|
3007
3024
|
*,
|
|
3008
3025
|
poll_interval: int = 10,
|
|
3009
3026
|
timeout: int = 7200,
|
|
3010
|
-
) ->
|
|
3027
|
+
) -> Comparison:
|
|
3011
3028
|
"""
|
|
3012
|
-
Poll
|
|
3029
|
+
Poll get_comparison() until the comparison completes or fails
|
|
3013
3030
|
|
|
3014
3031
|
Open beta: the API may change.
|
|
3015
3032
|
|
|
3016
3033
|
Args:
|
|
3017
|
-
|
|
3034
|
+
comparison_id: The comparison's ID
|
|
3018
3035
|
poll_interval: Seconds between polls
|
|
3019
3036
|
timeout: Maximum seconds to wait before raising DatalabTimeoutError
|
|
3020
3037
|
"""
|
|
3021
3038
|
slept = 0
|
|
3022
3039
|
while True:
|
|
3023
|
-
result = await self.
|
|
3040
|
+
result = await self.get_comparison(comparison_id)
|
|
3024
3041
|
if result.status in ("completed", "failed"):
|
|
3025
3042
|
return result
|
|
3026
3043
|
if slept >= timeout:
|
|
3027
3044
|
raise DatalabTimeoutError(
|
|
3028
|
-
f"
|
|
3045
|
+
f"Comparison {comparison_id} did not finish within {timeout} seconds"
|
|
3029
3046
|
)
|
|
3030
3047
|
await asyncio.sleep(poll_interval)
|
|
3031
3048
|
slept += poll_interval
|
|
3032
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
|
+
|
|
3033
3112
|
@staticmethod
|
|
3034
|
-
def
|
|
3035
|
-
|
|
3113
|
+
def _build_comparison_document_result(
|
|
3114
|
+
data: Dict[str, Any],
|
|
3115
|
+
) -> ComparisonDocumentResult:
|
|
3116
|
+
return ComparisonDocumentResult(
|
|
3036
3117
|
file_name=data.get("file_name", ""),
|
|
3037
3118
|
status=data.get("status", ""),
|
|
3038
3119
|
file_id=data.get("file_id"),
|
|
@@ -3045,8 +3126,8 @@ class AsyncDatalabClient:
|
|
|
3045
3126
|
)
|
|
3046
3127
|
|
|
3047
3128
|
@staticmethod
|
|
3048
|
-
def
|
|
3049
|
-
return
|
|
3129
|
+
def _build_comparison_file(data: Dict[str, Any]) -> ComparisonFile:
|
|
3130
|
+
return ComparisonFile(
|
|
3050
3131
|
file_id=data["file_id"],
|
|
3051
3132
|
file_name=data.get("file_name", ""),
|
|
3052
3133
|
comparison=data.get("comparison", "pending"),
|
|
@@ -3054,8 +3135,8 @@ class AsyncDatalabClient:
|
|
|
3054
3135
|
)
|
|
3055
3136
|
|
|
3056
3137
|
@staticmethod
|
|
3057
|
-
def
|
|
3058
|
-
return
|
|
3138
|
+
def _build_comparison_difference(data: Dict[str, Any]) -> ComparisonDifference:
|
|
3139
|
+
return ComparisonDifference(
|
|
3059
3140
|
page=data.get("page", 0),
|
|
3060
3141
|
before=data.get("before", ""),
|
|
3061
3142
|
after=data.get("after", ""),
|
|
@@ -3070,9 +3151,11 @@ class AsyncDatalabClient:
|
|
|
3070
3151
|
)
|
|
3071
3152
|
|
|
3072
3153
|
@classmethod
|
|
3073
|
-
def
|
|
3154
|
+
def _build_comparison_variant_result(
|
|
3155
|
+
cls, data: Dict[str, Any]
|
|
3156
|
+
) -> ComparisonVariantResult:
|
|
3074
3157
|
documents = data.get("documents")
|
|
3075
|
-
return
|
|
3158
|
+
return ComparisonVariantResult(
|
|
3076
3159
|
name=data.get("name", ""),
|
|
3077
3160
|
steps=data.get("steps") or {},
|
|
3078
3161
|
status=data.get("status", ""),
|
|
@@ -3088,27 +3171,29 @@ class AsyncDatalabClient:
|
|
|
3088
3171
|
undecided=data.get("undecided", 0),
|
|
3089
3172
|
rate_per_1000_pages_cents=data.get("rate_per_1000_pages_cents"),
|
|
3090
3173
|
seconds_per_page=data.get("seconds_per_page"),
|
|
3091
|
-
documents=[cls.
|
|
3174
|
+
documents=[cls._build_comparison_document_result(d) for d in documents]
|
|
3092
3175
|
if documents is not None
|
|
3093
3176
|
else None,
|
|
3094
3177
|
)
|
|
3095
3178
|
|
|
3096
3179
|
@classmethod
|
|
3097
|
-
def
|
|
3180
|
+
def _build_comparison(cls, data: Dict[str, Any]) -> Comparison:
|
|
3098
3181
|
files = data.get("files")
|
|
3099
|
-
return
|
|
3100
|
-
eval_id
|
|
3182
|
+
return Comparison(
|
|
3183
|
+
# The deprecated /evals routes answer with eval_id.
|
|
3184
|
+
comparison_id=data.get("comparison_id", data.get("eval_id")),
|
|
3101
3185
|
pipeline_id=data.get("pipeline_id", ""),
|
|
3102
3186
|
status=data.get("status", ""),
|
|
3103
3187
|
variants=[
|
|
3104
|
-
cls.
|
|
3188
|
+
cls._build_comparison_variant_result(v)
|
|
3189
|
+
for v in data.get("variants") or []
|
|
3105
3190
|
],
|
|
3106
3191
|
pipeline_name=data.get("pipeline_name"),
|
|
3107
3192
|
pipeline_version=data.get("pipeline_version"),
|
|
3108
3193
|
compared_step=data.get("compared_step", "convert"),
|
|
3109
3194
|
collection_id=data.get("collection_id"),
|
|
3110
3195
|
file_ids=data.get("file_ids"),
|
|
3111
|
-
files=[cls.
|
|
3196
|
+
files=[cls._build_comparison_file(f) for f in files]
|
|
3112
3197
|
if files is not None
|
|
3113
3198
|
else None,
|
|
3114
3199
|
created=data.get("created"),
|
|
@@ -4068,20 +4153,20 @@ class DatalabClient:
|
|
|
4068
4153
|
self._async_client.archive_custom_processor(processor_id=processor_id)
|
|
4069
4154
|
)
|
|
4070
4155
|
|
|
4071
|
-
# ---
|
|
4156
|
+
# --- Comparison methods (sync; open beta, the API may change) ---
|
|
4072
4157
|
|
|
4073
|
-
def
|
|
4158
|
+
def create_comparison(
|
|
4074
4159
|
self,
|
|
4075
4160
|
pipeline_id: str,
|
|
4076
4161
|
*,
|
|
4077
4162
|
file_ids: Optional[list[int]] = None,
|
|
4078
4163
|
collection_id: Optional[int] = None,
|
|
4079
|
-
variants: Optional[list[
|
|
4164
|
+
variants: Optional[list[ComparisonVariant]] = None,
|
|
4080
4165
|
version: Optional[int] = None,
|
|
4081
|
-
) ->
|
|
4166
|
+
) -> Comparison:
|
|
4082
4167
|
"""Run and compare pipeline variants (sync version). Open beta: the API may change."""
|
|
4083
4168
|
return self._run_async(
|
|
4084
|
-
self._async_client.
|
|
4169
|
+
self._async_client.create_comparison(
|
|
4085
4170
|
pipeline_id,
|
|
4086
4171
|
file_ids=file_ids,
|
|
4087
4172
|
collection_id=collection_id,
|
|
@@ -4090,20 +4175,20 @@ class DatalabClient:
|
|
|
4090
4175
|
)
|
|
4091
4176
|
)
|
|
4092
4177
|
|
|
4093
|
-
def
|
|
4094
|
-
"""Get
|
|
4095
|
-
return self._run_async(self._async_client.
|
|
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))
|
|
4096
4181
|
|
|
4097
|
-
def
|
|
4182
|
+
def list_comparisons(
|
|
4098
4183
|
self,
|
|
4099
4184
|
pipeline_id: Optional[str] = None,
|
|
4100
4185
|
collection_id: Optional[int] = None,
|
|
4101
4186
|
limit: int = 20,
|
|
4102
4187
|
offset: int = 0,
|
|
4103
|
-
) ->
|
|
4104
|
-
"""List the team's
|
|
4188
|
+
) -> ComparisonList:
|
|
4189
|
+
"""List the team's comparisons (sync version). Open beta: the API may change."""
|
|
4105
4190
|
return self._run_async(
|
|
4106
|
-
self._async_client.
|
|
4191
|
+
self._async_client.list_comparisons(
|
|
4107
4192
|
pipeline_id=pipeline_id,
|
|
4108
4193
|
collection_id=collection_id,
|
|
4109
4194
|
limit=limit,
|
|
@@ -4111,24 +4196,86 @@ class DatalabClient:
|
|
|
4111
4196
|
)
|
|
4112
4197
|
)
|
|
4113
4198
|
|
|
4114
|
-
def
|
|
4199
|
+
def get_comparison_differences(
|
|
4200
|
+
self, comparison_id: int, file_id: int
|
|
4201
|
+
) -> ComparisonDifferences:
|
|
4115
4202
|
"""Get one document's differences (sync version). Open beta: the API may change."""
|
|
4116
4203
|
return self._run_async(
|
|
4117
|
-
self._async_client.
|
|
4204
|
+
self._async_client.get_comparison_differences(comparison_id, file_id)
|
|
4118
4205
|
)
|
|
4119
4206
|
|
|
4120
|
-
def
|
|
4207
|
+
def wait_for_comparison(
|
|
4121
4208
|
self,
|
|
4122
|
-
|
|
4209
|
+
comparison_id: int,
|
|
4123
4210
|
*,
|
|
4124
4211
|
poll_interval: int = 10,
|
|
4125
4212
|
timeout: int = 7200,
|
|
4126
|
-
) ->
|
|
4127
|
-
"""Poll until the
|
|
4213
|
+
) -> Comparison:
|
|
4214
|
+
"""Poll until the comparison completes or fails (sync version). Open beta: the API may change."""
|
|
4128
4215
|
return self._run_async(
|
|
4129
|
-
self._async_client.
|
|
4130
|
-
|
|
4216
|
+
self._async_client.wait_for_comparison(
|
|
4217
|
+
comparison_id,
|
|
4131
4218
|
poll_interval=poll_interval,
|
|
4132
4219
|
timeout=timeout,
|
|
4133
4220
|
)
|
|
4134
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
|
@@ -1031,12 +1031,13 @@ class CustomProcessorVersion:
|
|
|
1031
1031
|
is_active: bool = False
|
|
1032
1032
|
|
|
1033
1033
|
|
|
1034
|
-
# ---
|
|
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.
|
|
1035
1036
|
|
|
1036
1037
|
|
|
1037
1038
|
@dataclass
|
|
1038
|
-
class
|
|
1039
|
-
"""One variant that
|
|
1039
|
+
class ComparisonVariant:
|
|
1040
|
+
"""One variant that a comparison runs and compares, with its own settings.
|
|
1040
1041
|
|
|
1041
1042
|
`steps` maps a step type ("convert" or "extract") to the settings that
|
|
1042
1043
|
this variant merges into that step's settings, for example
|
|
@@ -1047,13 +1048,13 @@ class EvalVariant:
|
|
|
1047
1048
|
steps: Dict[str, Dict[str, Any]] = field(default_factory=dict)
|
|
1048
1049
|
|
|
1049
1050
|
def to_dict(self) -> Dict[str, Any]:
|
|
1050
|
-
"""Convert to a dict for the
|
|
1051
|
+
"""Convert to a dict for the create_comparison request body"""
|
|
1051
1052
|
return {"name": self.name, "steps": self.steps}
|
|
1052
1053
|
|
|
1053
1054
|
|
|
1054
1055
|
@dataclass
|
|
1055
|
-
class
|
|
1056
|
-
"""One document's result for one variant of
|
|
1056
|
+
class ComparisonDocumentResult:
|
|
1057
|
+
"""One document's result for one variant of a comparison (open beta).
|
|
1057
1058
|
|
|
1058
1059
|
`share` is this variant's share of the decided places (won / decided) on
|
|
1059
1060
|
this document. None until the comparison ends, or when nothing was
|
|
@@ -1072,8 +1073,8 @@ class EvalDocumentResult:
|
|
|
1072
1073
|
|
|
1073
1074
|
|
|
1074
1075
|
@dataclass
|
|
1075
|
-
class
|
|
1076
|
-
"""One file of
|
|
1076
|
+
class ComparisonFile:
|
|
1077
|
+
"""One file of a comparison, with its comparison status (open beta)."""
|
|
1077
1078
|
|
|
1078
1079
|
file_id: int
|
|
1079
1080
|
file_name: str
|
|
@@ -1084,12 +1085,12 @@ class EvalFile:
|
|
|
1084
1085
|
|
|
1085
1086
|
|
|
1086
1087
|
@dataclass
|
|
1087
|
-
class
|
|
1088
|
-
"""One variant's settings and result in
|
|
1088
|
+
class ComparisonVariantResult:
|
|
1089
|
+
"""One variant's settings and result in a comparison (open beta; the API may change).
|
|
1089
1090
|
|
|
1090
1091
|
`share` is this variant's share of the decided places (won / decided)
|
|
1091
1092
|
over the documents compared so far. It is relative to the other
|
|
1092
|
-
variants in the same
|
|
1093
|
+
variants in the same comparison, not an absolute quality score.
|
|
1093
1094
|
"""
|
|
1094
1095
|
|
|
1095
1096
|
name: str
|
|
@@ -1106,7 +1107,7 @@ class EvalVariantResult:
|
|
|
1106
1107
|
page_breaks_total: int = 0
|
|
1107
1108
|
# The scored Convert settings this variant ran with: output_mode and merge_cross_page.
|
|
1108
1109
|
convert_settings: Dict[str, Any] = field(default_factory=dict)
|
|
1109
|
-
# The scored Extract settings of the variant (extraction_mode), for
|
|
1110
|
+
# The scored Extract settings of the variant (extraction_mode), for a comparison of Extract.
|
|
1110
1111
|
extract_settings: Dict[str, Any] = field(default_factory=dict)
|
|
1111
1112
|
# Places where the variants differ but no reading was decided. None when unknown.
|
|
1112
1113
|
undecided: Optional[int] = 0
|
|
@@ -1114,45 +1115,56 @@ class EvalVariantResult:
|
|
|
1114
1115
|
# (before any discount), in cents.
|
|
1115
1116
|
rate_per_1000_pages_cents: Optional[float] = None
|
|
1116
1117
|
seconds_per_page: Optional[float] = None
|
|
1117
|
-
# Per-document results. Only present on
|
|
1118
|
-
|
|
1118
|
+
# Per-document results. Only present on get_comparison(), not on create_comparison() or
|
|
1119
|
+
# list_comparisons().
|
|
1120
|
+
documents: Optional[List[ComparisonDocumentResult]] = None
|
|
1119
1121
|
|
|
1120
1122
|
|
|
1121
1123
|
@dataclass
|
|
1122
|
-
class
|
|
1123
|
-
"""Status and results of
|
|
1124
|
+
class Comparison:
|
|
1125
|
+
"""Status and results of a comparison of pipeline variants (open beta; the API may change)."""
|
|
1124
1126
|
|
|
1125
|
-
|
|
1127
|
+
comparison_id: int
|
|
1126
1128
|
pipeline_id: str
|
|
1127
1129
|
status: str # running, completed, failed
|
|
1128
|
-
variants: List[
|
|
1130
|
+
variants: List[ComparisonVariantResult] = field(default_factory=list)
|
|
1129
1131
|
pipeline_name: Optional[str] = None
|
|
1130
1132
|
pipeline_version: Optional[int] = None
|
|
1131
1133
|
# "convert" (the pages) or "extract" (the fields of the pipeline's Extract step)
|
|
1132
1134
|
compared_step: str = "convert"
|
|
1133
1135
|
collection_id: Optional[int] = None
|
|
1134
1136
|
file_ids: Optional[List[int]] = None
|
|
1135
|
-
# The files of the
|
|
1136
|
-
files: Optional[List[
|
|
1137
|
+
# The files of the comparison, with names and comparison status. Only on get_comparison().
|
|
1138
|
+
files: Optional[List[ComparisonFile]] = None
|
|
1137
1139
|
created: Optional[str] = None
|
|
1138
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
|
+
|
|
1139
1146
|
|
|
1140
1147
|
@dataclass
|
|
1141
|
-
class
|
|
1142
|
-
"""A page of the team's
|
|
1148
|
+
class ComparisonList:
|
|
1149
|
+
"""A page of the team's comparisons, newest first (open beta; the API may change)."""
|
|
1143
1150
|
|
|
1144
|
-
|
|
1151
|
+
comparisons: List[Comparison] = field(default_factory=list)
|
|
1145
1152
|
total: int = 0
|
|
1146
1153
|
|
|
1154
|
+
@property
|
|
1155
|
+
def evals(self) -> List[Comparison]:
|
|
1156
|
+
"""Deprecated: the SDK 0.10.0 name of comparisons."""
|
|
1157
|
+
return self.comparisons
|
|
1158
|
+
|
|
1147
1159
|
|
|
1148
1160
|
@dataclass
|
|
1149
|
-
class
|
|
1150
|
-
"""One place where
|
|
1161
|
+
class ComparisonDifference:
|
|
1162
|
+
"""One place where a comparison's variants read a document differently (open beta).
|
|
1151
1163
|
|
|
1152
1164
|
`verdict` is "decided", "none", "unclear" or "ignored". `decided_by` is
|
|
1153
1165
|
"text_layer", "judge", or "" when not decided. For a table difference,
|
|
1154
1166
|
`question` holds the question about the cell in place of before/after.
|
|
1155
|
-
For
|
|
1167
|
+
For a comparison of Extract, `description` is the schema's description of the
|
|
1156
1168
|
field that `question` names.
|
|
1157
1169
|
"""
|
|
1158
1170
|
|
|
@@ -1170,10 +1182,10 @@ class EvalDifference:
|
|
|
1170
1182
|
|
|
1171
1183
|
|
|
1172
1184
|
@dataclass
|
|
1173
|
-
class
|
|
1174
|
-
"""
|
|
1185
|
+
class ComparisonField:
|
|
1186
|
+
"""A comparison of Extract: one compared field and each variant's value, equal or not (open beta).
|
|
1175
1187
|
|
|
1176
|
-
`values` follows
|
|
1188
|
+
`values` follows ComparisonDifferences.variant_names. An empty string means no value.
|
|
1177
1189
|
"""
|
|
1178
1190
|
|
|
1179
1191
|
path: str
|
|
@@ -1182,11 +1194,23 @@ class EvalField:
|
|
|
1182
1194
|
|
|
1183
1195
|
|
|
1184
1196
|
@dataclass
|
|
1185
|
-
class
|
|
1186
|
-
"""Where
|
|
1197
|
+
class ComparisonDifferences:
|
|
1198
|
+
"""Where a comparison's variants read one document differently (open beta; the API may change)."""
|
|
1187
1199
|
|
|
1188
1200
|
file_id: int
|
|
1189
1201
|
variant_names: List[str] = field(default_factory=list)
|
|
1190
|
-
differences: List[
|
|
1191
|
-
#
|
|
1192
|
-
fields: 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=mkxth8TTkcU5KHgp8B6G_Mec_lx_OY0LYx_ZTssCfDY,2809
|
|
2
|
-
datalab_sdk/auth.py,sha256=X2eccKzpdxogFEDoS4geOHIOeECQ8u3kANxKoqF0PVk,4388
|
|
3
|
-
datalab_sdk/cli.py,sha256=_thBW6ZWb9TzAAeLZy4E3xtNrFJrlV1jYAAXiMxxteo,62565
|
|
4
|
-
datalab_sdk/client.py,sha256=NPgd9BHn5RZT_YAcQdXUwtIT4QNpXctWF4TAmjpfH9Q,153111
|
|
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=Xm6MLl5DL32jFcmNv4t858qbmmO9FEMZQgiq1N5zFRw,41454
|
|
8
|
-
datalab_sdk/settings.py,sha256=B_B42QQADAz6ePXQTOqENZllcppFR4JpwonEk2vlzhw,693
|
|
9
|
-
datalab_python_sdk-0.10.0.dist-info/METADATA,sha256=wiHF5_waERJS-TyHlF00d90ypuwI2Rgi6t6VCb131JE,10034
|
|
10
|
-
datalab_python_sdk-0.10.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
11
|
-
datalab_python_sdk-0.10.0.dist-info/entry_points.txt,sha256=rqWxO21UV57JxxyeF20iBTxHpzBYOA69hCHIqwdn-Ok,48
|
|
12
|
-
datalab_python_sdk-0.10.0.dist-info/licenses/LICENSE,sha256=XGjT-Uz6t7UZzr3JCZfilsGcZEgMm_1aONcRunohxWg,1064
|
|
13
|
-
datalab_python_sdk-0.10.0.dist-info/RECORD,,
|
|
File without changes
|
{datalab_python_sdk-0.10.0.dist-info → datalab_python_sdk-0.11.0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{datalab_python_sdk-0.10.0.dist-info → datalab_python_sdk-0.11.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|