rapidata 2.36.2__py3-none-any.whl → 2.38.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.
Potentially problematic release.
This version of rapidata might be problematic. Click here for more details.
- rapidata/__init__.py +3 -4
- rapidata/rapidata_client/__init__.py +1 -4
- rapidata/rapidata_client/api/{rapidata_exception.py → rapidata_api_client.py} +119 -2
- rapidata/rapidata_client/benchmark/leaderboard/rapidata_leaderboard.py +88 -46
- rapidata/rapidata_client/benchmark/participant/_participant.py +26 -9
- rapidata/rapidata_client/benchmark/rapidata_benchmark.py +274 -205
- rapidata/rapidata_client/benchmark/rapidata_benchmark_manager.py +98 -76
- rapidata/rapidata_client/config/__init__.py +3 -0
- rapidata/rapidata_client/config/logger.py +135 -0
- rapidata/rapidata_client/config/logging_config.py +58 -0
- rapidata/rapidata_client/config/managed_print.py +6 -0
- rapidata/rapidata_client/config/order_config.py +14 -0
- rapidata/rapidata_client/config/rapidata_config.py +14 -9
- rapidata/rapidata_client/config/tracer.py +130 -0
- rapidata/rapidata_client/config/upload_config.py +14 -0
- rapidata/rapidata_client/datapoints/_datapoint.py +1 -1
- rapidata/rapidata_client/datapoints/assets/_media_asset.py +1 -1
- rapidata/rapidata_client/datapoints/assets/_sessions.py +2 -2
- rapidata/rapidata_client/demographic/demographic_manager.py +16 -14
- rapidata/rapidata_client/filter/_base_filter.py +11 -5
- rapidata/rapidata_client/filter/age_filter.py +9 -3
- rapidata/rapidata_client/filter/and_filter.py +20 -5
- rapidata/rapidata_client/filter/campaign_filter.py +7 -1
- rapidata/rapidata_client/filter/country_filter.py +8 -2
- rapidata/rapidata_client/filter/custom_filter.py +9 -3
- rapidata/rapidata_client/filter/gender_filter.py +9 -3
- rapidata/rapidata_client/filter/language_filter.py +12 -5
- rapidata/rapidata_client/filter/new_user_filter.py +3 -4
- rapidata/rapidata_client/filter/not_filter.py +17 -5
- rapidata/rapidata_client/filter/or_filter.py +20 -5
- rapidata/rapidata_client/filter/response_count_filter.py +6 -0
- rapidata/rapidata_client/filter/user_score_filter.py +17 -5
- rapidata/rapidata_client/order/_rapidata_dataset.py +45 -17
- rapidata/rapidata_client/order/_rapidata_order_builder.py +19 -13
- rapidata/rapidata_client/order/rapidata_order.py +60 -48
- rapidata/rapidata_client/order/rapidata_order_manager.py +239 -195
- rapidata/rapidata_client/order/rapidata_results.py +71 -57
- rapidata/rapidata_client/rapidata_client.py +36 -23
- rapidata/rapidata_client/selection/_base_selection.py +6 -0
- rapidata/rapidata_client/selection/static_selection.py +5 -10
- rapidata/rapidata_client/settings/_rapidata_setting.py +8 -0
- rapidata/rapidata_client/settings/alert_on_fast_response.py +8 -5
- rapidata/rapidata_client/settings/free_text_minimum_characters.py +9 -4
- rapidata/rapidata_client/validation/rapidata_validation_set.py +20 -16
- rapidata/rapidata_client/validation/rapids/rapids.py +7 -1
- rapidata/rapidata_client/validation/validation_set_manager.py +285 -268
- rapidata/rapidata_client/workflow/_base_workflow.py +6 -1
- rapidata/rapidata_client/workflow/_classify_workflow.py +6 -0
- rapidata/rapidata_client/workflow/_compare_workflow.py +6 -0
- rapidata/rapidata_client/workflow/_draw_workflow.py +6 -0
- rapidata/rapidata_client/workflow/_evaluation_workflow.py +6 -0
- rapidata/rapidata_client/workflow/_free_text_workflow.py +6 -0
- rapidata/rapidata_client/workflow/_locate_workflow.py +6 -0
- rapidata/rapidata_client/workflow/_ranking_workflow.py +12 -0
- rapidata/rapidata_client/workflow/_select_words_workflow.py +6 -0
- rapidata/rapidata_client/workflow/_timestamp_workflow.py +6 -0
- rapidata/service/credential_manager.py +1 -1
- rapidata/service/openapi_service.py +2 -2
- {rapidata-2.36.2.dist-info → rapidata-2.38.0.dist-info}/METADATA +4 -1
- {rapidata-2.36.2.dist-info → rapidata-2.38.0.dist-info}/RECORD +62 -59
- rapidata/rapidata_client/logging/__init__.py +0 -2
- rapidata/rapidata_client/logging/logger.py +0 -122
- rapidata/rapidata_client/logging/output_manager.py +0 -20
- {rapidata-2.36.2.dist-info → rapidata-2.38.0.dist-info}/LICENSE +0 -0
- {rapidata-2.36.2.dist-info → rapidata-2.38.0.dist-info}/WHEEL +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from typing import Sequence, Optional, Literal
|
|
2
2
|
from itertools import zip_longest
|
|
3
3
|
|
|
4
|
+
from rapidata.rapidata_client.config.tracer import tracer
|
|
4
5
|
from rapidata.service.openapi_service import OpenAPIService
|
|
5
6
|
from rapidata.rapidata_client.order.rapidata_order import RapidataOrder
|
|
6
7
|
from rapidata.rapidata_client.order._rapidata_order_builder import RapidataOrderBuilder
|
|
@@ -33,7 +34,7 @@ from rapidata.rapidata_client.filter import RapidataFilter
|
|
|
33
34
|
from rapidata.rapidata_client.filter.rapidata_filters import RapidataFilters
|
|
34
35
|
from rapidata.rapidata_client.settings import RapidataSettings, RapidataSetting
|
|
35
36
|
from rapidata.rapidata_client.selection.rapidata_selections import RapidataSelections
|
|
36
|
-
from rapidata.rapidata_client.
|
|
37
|
+
from rapidata.rapidata_client.config import logger, rapidata_config
|
|
37
38
|
|
|
38
39
|
from rapidata.api_client.models.query_model import QueryModel
|
|
39
40
|
from rapidata.api_client.models.page_info import PageInfo
|
|
@@ -108,6 +109,23 @@ class RapidataOrderManager:
|
|
|
108
109
|
max_vote_count=responses_per_datapoint,
|
|
109
110
|
)
|
|
110
111
|
|
|
112
|
+
logger.debug(
|
|
113
|
+
"Creating order with parameters: name %s, workflow %s, assets %s, responses_per_datapoint %s, contexts %s, media_contexts %s, validation_set_id %s, confidence_threshold %s, filters %s, settings %s, sentences %s, selections %s, private_notes %s",
|
|
114
|
+
name,
|
|
115
|
+
workflow,
|
|
116
|
+
assets,
|
|
117
|
+
responses_per_datapoint,
|
|
118
|
+
contexts,
|
|
119
|
+
media_contexts,
|
|
120
|
+
validation_set_id,
|
|
121
|
+
confidence_threshold,
|
|
122
|
+
filters,
|
|
123
|
+
settings,
|
|
124
|
+
sentences,
|
|
125
|
+
selections,
|
|
126
|
+
private_notes,
|
|
127
|
+
)
|
|
128
|
+
|
|
111
129
|
order_builder = RapidataOrderBuilder(
|
|
112
130
|
name=name, openapi_service=self.__openapi_service
|
|
113
131
|
)
|
|
@@ -235,33 +253,35 @@ class RapidataOrderManager:
|
|
|
235
253
|
If provided has to be the same length as datapoints.\n
|
|
236
254
|
This will NOT be shown to the labelers but will be included in the result purely for your own reference.
|
|
237
255
|
"""
|
|
256
|
+
with tracer.start_as_current_span(
|
|
257
|
+
"RapidataOrderManager.create_classification_order"
|
|
258
|
+
):
|
|
259
|
+
if data_type == "media":
|
|
260
|
+
assets = [MediaAsset(path=path) for path in datapoints]
|
|
261
|
+
elif data_type == "text":
|
|
262
|
+
assets = [TextAsset(text=text) for text in datapoints]
|
|
263
|
+
else:
|
|
264
|
+
raise ValueError(
|
|
265
|
+
f"Unsupported data type: {data_type}, must be one of 'media' or 'text'"
|
|
266
|
+
)
|
|
238
267
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
268
|
+
return self._create_general_order(
|
|
269
|
+
name=name,
|
|
270
|
+
workflow=ClassifyWorkflow(
|
|
271
|
+
instruction=instruction, answer_options=answer_options
|
|
272
|
+
),
|
|
273
|
+
assets=assets,
|
|
274
|
+
responses_per_datapoint=responses_per_datapoint,
|
|
275
|
+
contexts=contexts,
|
|
276
|
+
media_contexts=media_contexts,
|
|
277
|
+
validation_set_id=validation_set_id,
|
|
278
|
+
confidence_threshold=confidence_threshold,
|
|
279
|
+
filters=filters,
|
|
280
|
+
selections=selections,
|
|
281
|
+
settings=settings,
|
|
282
|
+
private_notes=private_notes,
|
|
246
283
|
)
|
|
247
284
|
|
|
248
|
-
return self._create_general_order(
|
|
249
|
-
name=name,
|
|
250
|
-
workflow=ClassifyWorkflow(
|
|
251
|
-
instruction=instruction, answer_options=answer_options
|
|
252
|
-
),
|
|
253
|
-
assets=assets,
|
|
254
|
-
responses_per_datapoint=responses_per_datapoint,
|
|
255
|
-
contexts=contexts,
|
|
256
|
-
media_contexts=media_contexts,
|
|
257
|
-
validation_set_id=validation_set_id,
|
|
258
|
-
confidence_threshold=confidence_threshold,
|
|
259
|
-
filters=filters,
|
|
260
|
-
selections=selections,
|
|
261
|
-
settings=settings,
|
|
262
|
-
private_notes=private_notes,
|
|
263
|
-
)
|
|
264
|
-
|
|
265
285
|
def create_compare_order(
|
|
266
286
|
self,
|
|
267
287
|
name: str,
|
|
@@ -316,46 +336,48 @@ class RapidataOrderManager:
|
|
|
316
336
|
If provided has to be the same length as datapoints.\n
|
|
317
337
|
This will NOT be shown to the labelers but will be included in the result purely for your own reference.
|
|
318
338
|
"""
|
|
339
|
+
with tracer.start_as_current_span("RapidataOrderManager.create_compare_order"):
|
|
340
|
+
if any(type(datapoint) != list for datapoint in datapoints):
|
|
341
|
+
raise ValueError("Each datapoint must be a list of 2 paths/texts")
|
|
319
342
|
|
|
320
|
-
|
|
321
|
-
|
|
343
|
+
if any(len(datapoint) != 2 for datapoint in datapoints):
|
|
344
|
+
raise ValueError("Each datapoint must contain exactly two options")
|
|
322
345
|
|
|
323
|
-
|
|
324
|
-
|
|
346
|
+
if a_b_names is not None and len(a_b_names) != 2:
|
|
347
|
+
raise ValueError(
|
|
348
|
+
"A_B_naming must be a list of exactly two strings or None"
|
|
349
|
+
)
|
|
325
350
|
|
|
326
|
-
|
|
327
|
-
|
|
351
|
+
if data_type == "media":
|
|
352
|
+
assets = [
|
|
353
|
+
MultiAsset([MediaAsset(path=path) for path in datapoint])
|
|
354
|
+
for datapoint in datapoints
|
|
355
|
+
]
|
|
356
|
+
elif data_type == "text":
|
|
357
|
+
assets = [
|
|
358
|
+
MultiAsset([TextAsset(text=text) for text in datapoint])
|
|
359
|
+
for datapoint in datapoints
|
|
360
|
+
]
|
|
361
|
+
else:
|
|
362
|
+
raise ValueError(
|
|
363
|
+
f"Unsupported data type: {data_type}, must be one of 'media' or 'text'"
|
|
364
|
+
)
|
|
328
365
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
366
|
+
return self._create_general_order(
|
|
367
|
+
name=name,
|
|
368
|
+
workflow=CompareWorkflow(instruction=instruction, a_b_names=a_b_names),
|
|
369
|
+
assets=assets,
|
|
370
|
+
responses_per_datapoint=responses_per_datapoint,
|
|
371
|
+
contexts=contexts,
|
|
372
|
+
media_contexts=media_contexts,
|
|
373
|
+
validation_set_id=validation_set_id,
|
|
374
|
+
confidence_threshold=confidence_threshold,
|
|
375
|
+
filters=filters,
|
|
376
|
+
selections=selections,
|
|
377
|
+
settings=settings,
|
|
378
|
+
private_notes=private_notes,
|
|
342
379
|
)
|
|
343
380
|
|
|
344
|
-
return self._create_general_order(
|
|
345
|
-
name=name,
|
|
346
|
-
workflow=CompareWorkflow(instruction=instruction, a_b_names=a_b_names),
|
|
347
|
-
assets=assets,
|
|
348
|
-
responses_per_datapoint=responses_per_datapoint,
|
|
349
|
-
contexts=contexts,
|
|
350
|
-
media_contexts=media_contexts,
|
|
351
|
-
validation_set_id=validation_set_id,
|
|
352
|
-
confidence_threshold=confidence_threshold,
|
|
353
|
-
filters=filters,
|
|
354
|
-
selections=selections,
|
|
355
|
-
settings=settings,
|
|
356
|
-
private_notes=private_notes,
|
|
357
|
-
)
|
|
358
|
-
|
|
359
381
|
def create_ranking_order(
|
|
360
382
|
self,
|
|
361
383
|
name: str,
|
|
@@ -396,30 +418,31 @@ class RapidataOrderManager:
|
|
|
396
418
|
selections (Sequence[RapidataSelection], optional): The list of selections for the order. Defaults to []. Decides in what order the tasks should be shown.
|
|
397
419
|
"""
|
|
398
420
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
421
|
+
with tracer.start_as_current_span("RapidataOrderManager.create_ranking_order"):
|
|
422
|
+
if data_type == "media":
|
|
423
|
+
assets = [MediaAsset(path=path) for path in datapoints]
|
|
424
|
+
elif data_type == "text":
|
|
425
|
+
assets = [TextAsset(text=text) for text in datapoints]
|
|
426
|
+
else:
|
|
427
|
+
raise ValueError(
|
|
428
|
+
f"Unsupported data type: {data_type}, must be one of 'media' or 'text'"
|
|
429
|
+
)
|
|
407
430
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
431
|
+
return self._create_general_order(
|
|
432
|
+
name=name,
|
|
433
|
+
workflow=RankingWorkflow(
|
|
434
|
+
criteria=instruction,
|
|
435
|
+
total_comparison_budget=total_comparison_budget,
|
|
436
|
+
random_comparisons_ratio=random_comparisons_ratio,
|
|
437
|
+
context=context,
|
|
438
|
+
),
|
|
439
|
+
assets=assets,
|
|
440
|
+
responses_per_datapoint=responses_per_comparison,
|
|
441
|
+
validation_set_id=validation_set_id,
|
|
442
|
+
filters=filters,
|
|
443
|
+
selections=selections,
|
|
444
|
+
settings=settings,
|
|
445
|
+
)
|
|
423
446
|
|
|
424
447
|
def create_free_text_order(
|
|
425
448
|
self,
|
|
@@ -428,6 +451,8 @@ class RapidataOrderManager:
|
|
|
428
451
|
datapoints: list[str],
|
|
429
452
|
data_type: Literal["media", "text"] = "media",
|
|
430
453
|
responses_per_datapoint: int = 10,
|
|
454
|
+
contexts: list[str] | None = None,
|
|
455
|
+
media_contexts: list[str] | None = None,
|
|
431
456
|
filters: Sequence[RapidataFilter] = [],
|
|
432
457
|
settings: Sequence[RapidataSetting] = [],
|
|
433
458
|
selections: Sequence[RapidataSelection] = [],
|
|
@@ -445,6 +470,12 @@ class RapidataOrderManager:
|
|
|
445
470
|
data_type (str, optional): The data type of the datapoints. Defaults to "media" (any form of image, video or audio). \n
|
|
446
471
|
Other option: "text".
|
|
447
472
|
responses_per_datapoint (int, optional): The number of responses that will be collected per datapoint. Defaults to 10.
|
|
473
|
+
contexts (list[str], optional): The list of contexts for the free text. Defaults to None.\n
|
|
474
|
+
If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint)
|
|
475
|
+
Will be matched up with the datapoints using the list index.
|
|
476
|
+
media_contexts (list[str], optional): The list of media contexts for the free text i.e links to the images / videos. Defaults to None.\n
|
|
477
|
+
If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint)
|
|
478
|
+
Will be matched up with the datapoints using the list index.
|
|
448
479
|
filters (Sequence[RapidataFilter], optional): The list of filters for the free text. Defaults to []. Decides who the tasks should be shown to.
|
|
449
480
|
settings (Sequence[RapidataSetting], optional): The list of settings for the free text. Defaults to []. Decides how the tasks should be shown.
|
|
450
481
|
selections (Sequence[RapidataSelection], optional): The list of selections for the free text. Defaults to []. Decides in what order the tasks should be shown.
|
|
@@ -452,26 +483,31 @@ class RapidataOrderManager:
|
|
|
452
483
|
If provided has to be the same length as datapoints.\n
|
|
453
484
|
This will NOT be shown to the labelers but will be included in the result purely for your own reference.
|
|
454
485
|
"""
|
|
486
|
+
with tracer.start_as_current_span(
|
|
487
|
+
"RapidataOrderManager.create_free_text_order"
|
|
488
|
+
):
|
|
455
489
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
490
|
+
if data_type == "media":
|
|
491
|
+
assets = [MediaAsset(path=path) for path in datapoints]
|
|
492
|
+
elif data_type == "text":
|
|
493
|
+
assets = [TextAsset(text=text) for text in datapoints]
|
|
494
|
+
else:
|
|
495
|
+
raise ValueError(
|
|
496
|
+
f"Unsupported data type: {data_type}, must be one of 'media' or 'text'"
|
|
497
|
+
)
|
|
464
498
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
499
|
+
return self._create_general_order(
|
|
500
|
+
name=name,
|
|
501
|
+
workflow=FreeTextWorkflow(instruction=instruction),
|
|
502
|
+
assets=assets,
|
|
503
|
+
responses_per_datapoint=responses_per_datapoint,
|
|
504
|
+
contexts=contexts,
|
|
505
|
+
media_contexts=media_contexts,
|
|
506
|
+
filters=filters,
|
|
507
|
+
selections=selections,
|
|
508
|
+
settings=settings,
|
|
509
|
+
private_notes=private_notes,
|
|
510
|
+
)
|
|
475
511
|
|
|
476
512
|
def create_select_words_order(
|
|
477
513
|
self,
|
|
@@ -508,23 +544,25 @@ class RapidataOrderManager:
|
|
|
508
544
|
If provided has to be the same length as datapoints.\n
|
|
509
545
|
This will NOT be shown to the labelers but will be included in the result purely for your own reference.
|
|
510
546
|
"""
|
|
547
|
+
with tracer.start_as_current_span(
|
|
548
|
+
"RapidataOrderManager.create_select_words_order"
|
|
549
|
+
):
|
|
550
|
+
assets = [MediaAsset(path=path) for path in datapoints]
|
|
511
551
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
private_notes=private_notes,
|
|
527
|
-
)
|
|
552
|
+
return self._create_general_order(
|
|
553
|
+
name=name,
|
|
554
|
+
workflow=SelectWordsWorkflow(
|
|
555
|
+
instruction=instruction,
|
|
556
|
+
),
|
|
557
|
+
assets=assets,
|
|
558
|
+
responses_per_datapoint=responses_per_datapoint,
|
|
559
|
+
validation_set_id=validation_set_id,
|
|
560
|
+
filters=filters,
|
|
561
|
+
selections=selections,
|
|
562
|
+
settings=settings,
|
|
563
|
+
sentences=sentences,
|
|
564
|
+
private_notes=private_notes,
|
|
565
|
+
)
|
|
528
566
|
|
|
529
567
|
def create_locate_order(
|
|
530
568
|
self,
|
|
@@ -564,22 +602,22 @@ class RapidataOrderManager:
|
|
|
564
602
|
If provided has to be the same length as datapoints.\n
|
|
565
603
|
This will NOT be shown to the labelers but will be included in the result purely for your own reference.
|
|
566
604
|
"""
|
|
605
|
+
with tracer.start_as_current_span("RapidataOrderManager.create_locate_order"):
|
|
606
|
+
assets = [MediaAsset(path=path) for path in datapoints]
|
|
567
607
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
private_notes=private_notes,
|
|
582
|
-
)
|
|
608
|
+
return self._create_general_order(
|
|
609
|
+
name=name,
|
|
610
|
+
workflow=LocateWorkflow(target=instruction),
|
|
611
|
+
assets=assets,
|
|
612
|
+
responses_per_datapoint=responses_per_datapoint,
|
|
613
|
+
contexts=contexts,
|
|
614
|
+
media_contexts=media_contexts,
|
|
615
|
+
validation_set_id=validation_set_id,
|
|
616
|
+
filters=filters,
|
|
617
|
+
selections=selections,
|
|
618
|
+
settings=settings,
|
|
619
|
+
private_notes=private_notes,
|
|
620
|
+
)
|
|
583
621
|
|
|
584
622
|
def create_draw_order(
|
|
585
623
|
self,
|
|
@@ -619,22 +657,22 @@ class RapidataOrderManager:
|
|
|
619
657
|
If provided has to be the same length as datapoints.\n
|
|
620
658
|
This will NOT be shown to the labelers but will be included in the result purely for your own reference.
|
|
621
659
|
"""
|
|
660
|
+
with tracer.start_as_current_span("RapidataOrderManager.create_draw_order"):
|
|
661
|
+
assets = [MediaAsset(path=path) for path in datapoints]
|
|
622
662
|
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
private_notes=private_notes,
|
|
637
|
-
)
|
|
663
|
+
return self._create_general_order(
|
|
664
|
+
name=name,
|
|
665
|
+
workflow=DrawWorkflow(target=instruction),
|
|
666
|
+
assets=assets,
|
|
667
|
+
responses_per_datapoint=responses_per_datapoint,
|
|
668
|
+
contexts=contexts,
|
|
669
|
+
media_contexts=media_contexts,
|
|
670
|
+
validation_set_id=validation_set_id,
|
|
671
|
+
filters=filters,
|
|
672
|
+
selections=selections,
|
|
673
|
+
settings=settings,
|
|
674
|
+
private_notes=private_notes,
|
|
675
|
+
)
|
|
638
676
|
|
|
639
677
|
def create_timestamp_order(
|
|
640
678
|
self,
|
|
@@ -678,31 +716,34 @@ class RapidataOrderManager:
|
|
|
678
716
|
This will NOT be shown to the labelers but will be included in the result purely for your own reference.
|
|
679
717
|
"""
|
|
680
718
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
for asset in tqdm(
|
|
684
|
-
assets,
|
|
685
|
-
desc="Downloading assets and checking duration",
|
|
686
|
-
disable=RapidataOutputManager.silent_mode,
|
|
719
|
+
with tracer.start_as_current_span(
|
|
720
|
+
"RapidataOrderManager.create_timestamp_order"
|
|
687
721
|
):
|
|
688
|
-
|
|
689
|
-
raise ValueError(
|
|
690
|
-
"The datapoints for this order must have a duration. (e.g. video or audio)"
|
|
691
|
-
)
|
|
722
|
+
assets = [MediaAsset(path=path) for path in datapoints]
|
|
692
723
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
724
|
+
for asset in tqdm(
|
|
725
|
+
assets,
|
|
726
|
+
desc="Downloading assets and checking duration",
|
|
727
|
+
disable=rapidata_config.logging.silent_mode,
|
|
728
|
+
):
|
|
729
|
+
if not asset.get_duration():
|
|
730
|
+
raise ValueError(
|
|
731
|
+
"The datapoints for this order must have a duration. (e.g. video or audio)"
|
|
732
|
+
)
|
|
733
|
+
|
|
734
|
+
return self._create_general_order(
|
|
735
|
+
name=name,
|
|
736
|
+
workflow=TimestampWorkflow(instruction=instruction),
|
|
737
|
+
assets=assets,
|
|
738
|
+
responses_per_datapoint=responses_per_datapoint,
|
|
739
|
+
contexts=contexts,
|
|
740
|
+
media_contexts=media_contexts,
|
|
741
|
+
validation_set_id=validation_set_id,
|
|
742
|
+
filters=filters,
|
|
743
|
+
selections=selections,
|
|
744
|
+
settings=settings,
|
|
745
|
+
private_notes=private_notes,
|
|
746
|
+
)
|
|
706
747
|
|
|
707
748
|
def get_order_by_id(self, order_id: str) -> RapidataOrder:
|
|
708
749
|
"""Get an order by ID.
|
|
@@ -713,14 +754,14 @@ class RapidataOrderManager:
|
|
|
713
754
|
Returns:
|
|
714
755
|
RapidataOrder: The Order instance.
|
|
715
756
|
"""
|
|
757
|
+
with tracer.start_as_current_span("RapidataOrderManager.get_order_by_id"):
|
|
758
|
+
order = self.__openapi_service.order_api.order_order_id_get(order_id)
|
|
716
759
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
openapi_service=self.__openapi_service,
|
|
723
|
-
)
|
|
760
|
+
return RapidataOrder(
|
|
761
|
+
order_id=order_id,
|
|
762
|
+
name=order.order_name,
|
|
763
|
+
openapi_service=self.__openapi_service,
|
|
764
|
+
)
|
|
724
765
|
|
|
725
766
|
def find_orders(self, name: str = "", amount: int = 10) -> list[RapidataOrder]:
|
|
726
767
|
"""Find your recent orders given criteria. If nothing is provided, it will return the most recent order.
|
|
@@ -732,25 +773,28 @@ class RapidataOrderManager:
|
|
|
732
773
|
Returns:
|
|
733
774
|
list[RapidataOrder]: A list of RapidataOrder instances.
|
|
734
775
|
"""
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
776
|
+
with tracer.start_as_current_span("RapidataOrderManager.find_orders"):
|
|
777
|
+
order_page_result = self.__openapi_service.order_api.orders_get(
|
|
778
|
+
QueryModel(
|
|
779
|
+
page=PageInfo(index=1, size=amount),
|
|
780
|
+
filter=RootFilter(
|
|
781
|
+
filters=[
|
|
782
|
+
Filter(
|
|
783
|
+
field="OrderName",
|
|
784
|
+
operator=FilterOperator.CONTAINS,
|
|
785
|
+
value=name,
|
|
786
|
+
)
|
|
787
|
+
]
|
|
788
|
+
),
|
|
789
|
+
sortCriteria=[
|
|
790
|
+
SortCriterion(
|
|
791
|
+
direction=SortDirection.DESC, propertyName="OrderDate"
|
|
744
792
|
)
|
|
745
|
-
]
|
|
746
|
-
)
|
|
747
|
-
sortCriteria=[
|
|
748
|
-
SortCriterion(
|
|
749
|
-
direction=SortDirection.DESC, propertyName="OrderDate"
|
|
750
|
-
)
|
|
751
|
-
],
|
|
793
|
+
],
|
|
794
|
+
)
|
|
752
795
|
)
|
|
753
|
-
)
|
|
754
796
|
|
|
755
|
-
|
|
756
|
-
|
|
797
|
+
orders = [
|
|
798
|
+
self.get_order_by_id(order.id) for order in order_page_result.items
|
|
799
|
+
]
|
|
800
|
+
return orders
|