rapidata 2.21.5__py3-none-any.whl → 2.23.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 +5 -0
- rapidata/api_client/__init__.py +8 -4
- rapidata/api_client/api/__init__.py +1 -0
- rapidata/api_client/api/evaluation_workflow_api.py +372 -0
- rapidata/api_client/api/identity_api.py +268 -0
- rapidata/api_client/api/rapid_api.py +353 -1987
- rapidata/api_client/api/simple_workflow_api.py +6 -6
- rapidata/api_client/models/__init__.py +7 -4
- rapidata/api_client/models/add_campaign_model.py +25 -1
- rapidata/api_client/models/add_validation_rapid_model_truth.py +24 -10
- rapidata/api_client/models/compare_result.py +2 -0
- rapidata/api_client/models/create_order_model.py +43 -2
- rapidata/api_client/models/evaluation_workflow_model1.py +115 -0
- rapidata/api_client/models/filter.py +2 -2
- rapidata/api_client/models/get_validation_rapids_result.py +11 -4
- rapidata/api_client/models/get_validation_rapids_result_truth.py +24 -10
- rapidata/api_client/models/get_workflow_by_id_result_workflow.py +23 -9
- rapidata/api_client/models/get_workflow_results_result.py +118 -0
- rapidata/api_client/models/get_workflow_results_result_paged_result.py +105 -0
- rapidata/api_client/models/google_one_tap_login_model.py +87 -0
- rapidata/api_client/models/labeling_selection.py +22 -3
- rapidata/api_client/models/logic_operator.py +1 -0
- rapidata/api_client/models/rapid_response.py +3 -1
- rapidata/api_client/models/retrieval_mode.py +38 -0
- rapidata/api_client/models/root_filter.py +2 -2
- rapidata/api_client/models/skip_truth.py +94 -0
- rapidata/api_client/models/sticky_state.py +38 -0
- rapidata/api_client/models/update_validation_rapid_model.py +11 -4
- rapidata/api_client/models/update_validation_rapid_model_truth.py +24 -10
- rapidata/api_client/rest.py +1 -0
- rapidata/api_client_README.md +10 -11
- rapidata/rapidata_client/__init__.py +7 -0
- rapidata/rapidata_client/api/rapidata_exception.py +5 -3
- rapidata/rapidata_client/assets/_media_asset.py +8 -1
- rapidata/rapidata_client/assets/_multi_asset.py +6 -0
- rapidata/rapidata_client/assets/_text_asset.py +6 -0
- rapidata/rapidata_client/demographic/demographic_manager.py +2 -3
- rapidata/rapidata_client/logging/__init__.py +2 -0
- rapidata/rapidata_client/logging/logger.py +47 -0
- rapidata/rapidata_client/logging/output_manager.py +16 -0
- rapidata/rapidata_client/order/_rapidata_dataset.py +48 -33
- rapidata/rapidata_client/order/_rapidata_order_builder.py +41 -19
- rapidata/rapidata_client/order/rapidata_order.py +22 -13
- rapidata/rapidata_client/order/rapidata_order_manager.py +84 -34
- rapidata/rapidata_client/order/rapidata_results.py +2 -1
- rapidata/rapidata_client/rapidata_client.py +6 -1
- rapidata/rapidata_client/selection/__init__.py +1 -0
- rapidata/rapidata_client/selection/labeling_selection.py +8 -2
- rapidata/rapidata_client/selection/retrieval_modes.py +9 -0
- rapidata/rapidata_client/settings/alert_on_fast_response.py +2 -1
- rapidata/rapidata_client/settings/free_text_minimum_characters.py +2 -1
- rapidata/rapidata_client/validation/rapidata_validation_set.py +2 -2
- rapidata/rapidata_client/validation/rapids/rapids.py +3 -1
- rapidata/rapidata_client/validation/validation_set_manager.py +39 -36
- rapidata/service/credential_manager.py +22 -30
- rapidata/service/openapi_service.py +11 -0
- {rapidata-2.21.5.dist-info → rapidata-2.23.0.dist-info}/METADATA +2 -1
- {rapidata-2.21.5.dist-info → rapidata-2.23.0.dist-info}/RECORD +60 -48
- {rapidata-2.21.5.dist-info → rapidata-2.23.0.dist-info}/WHEEL +1 -1
- {rapidata-2.21.5.dist-info → rapidata-2.23.0.dist-info}/LICENSE +0 -0
|
@@ -5,7 +5,7 @@ from rapidata.service.openapi_service import OpenAPIService
|
|
|
5
5
|
from rapidata.rapidata_client.assets.data_type_enum import RapidataDataTypes
|
|
6
6
|
from rapidata.rapidata_client.order.rapidata_order import RapidataOrder
|
|
7
7
|
from rapidata.rapidata_client.order._rapidata_order_builder import RapidataOrderBuilder
|
|
8
|
-
from rapidata.rapidata_client.metadata import PromptMetadata, SelectWordsMetadata
|
|
8
|
+
from rapidata.rapidata_client.metadata import PromptMetadata, SelectWordsMetadata, PrivateTextMetadata, Metadata
|
|
9
9
|
from rapidata.rapidata_client.referee._naive_referee import NaiveReferee
|
|
10
10
|
from rapidata.rapidata_client.referee._early_stopping_referee import EarlyStoppingReferee
|
|
11
11
|
from rapidata.rapidata_client.selection._base_selection import RapidataSelection
|
|
@@ -34,6 +34,7 @@ from rapidata.api_client.models.page_info import PageInfo
|
|
|
34
34
|
from rapidata.api_client.models.root_filter import RootFilter
|
|
35
35
|
from rapidata.api_client.models.filter import Filter
|
|
36
36
|
from rapidata.api_client.models.sort_criterion import SortCriterion
|
|
37
|
+
from rapidata.rapidata_client.logging import logger
|
|
37
38
|
|
|
38
39
|
from tqdm import tqdm
|
|
39
40
|
|
|
@@ -53,6 +54,7 @@ class RapidataOrderManager:
|
|
|
53
54
|
self.settings = RapidataSettings
|
|
54
55
|
self.selections = RapidataSelections
|
|
55
56
|
self.__priority = 50
|
|
57
|
+
logger.debug("RapidataOrderManager initialized")
|
|
56
58
|
|
|
57
59
|
def __get_selections(self, validation_set_id: str | None, labeling_amount=3) -> Sequence[RapidataSelection]:
|
|
58
60
|
if validation_set_id:
|
|
@@ -71,7 +73,8 @@ class RapidataOrderManager:
|
|
|
71
73
|
filters: Sequence[RapidataFilter] = [],
|
|
72
74
|
settings: Sequence[RapidataSetting] = [],
|
|
73
75
|
sentences: list[str] | None = None,
|
|
74
|
-
selections: Sequence[RapidataSelection]
|
|
76
|
+
selections: Sequence[RapidataSelection] = [],
|
|
77
|
+
private_notes: list[str] | None = None,
|
|
75
78
|
default_labeling_amount: int = 3
|
|
76
79
|
) -> RapidataOrder:
|
|
77
80
|
|
|
@@ -80,12 +83,12 @@ class RapidataOrderManager:
|
|
|
80
83
|
|
|
81
84
|
if sentences and len(sentences) != len(assets):
|
|
82
85
|
raise ValueError("Number of sentences must match number of datapoints")
|
|
86
|
+
|
|
87
|
+
if private_notes and len(private_notes) != len(assets):
|
|
88
|
+
raise ValueError("Number of private notes must match number of datapoints")
|
|
83
89
|
|
|
84
90
|
if sentences and contexts:
|
|
85
91
|
raise ValueError("You can only use contexts or sentences, not both")
|
|
86
|
-
|
|
87
|
-
if contexts and data_type == RapidataDataTypes.TEXT:
|
|
88
|
-
print("Warning: Contexts are not supported for text data type. Ignoring contexts.")
|
|
89
92
|
|
|
90
93
|
if not confidence_threshold:
|
|
91
94
|
referee = NaiveReferee(responses=responses_per_datapoint)
|
|
@@ -98,21 +101,32 @@ class RapidataOrderManager:
|
|
|
98
101
|
order_builder = RapidataOrderBuilder(name=name, openapi_service=self._openapi_service)
|
|
99
102
|
|
|
100
103
|
if selections and validation_set_id:
|
|
101
|
-
|
|
104
|
+
logger.warning("Warning: Both selections and validation_set_id provided. Ignoring validation_set_id.")
|
|
102
105
|
|
|
103
|
-
if selections
|
|
106
|
+
if not selections:
|
|
104
107
|
selections = self.__get_selections(validation_set_id, labeling_amount=default_labeling_amount)
|
|
105
108
|
|
|
106
109
|
prompts_metadata = [PromptMetadata(prompt=prompt) for prompt in contexts] if contexts else None
|
|
107
110
|
sentence_metadata = [SelectWordsMetadata(select_words=sentence) for sentence in sentences] if sentences else None
|
|
108
111
|
|
|
109
|
-
|
|
112
|
+
if prompts_metadata and sentence_metadata:
|
|
113
|
+
raise ValueError("You can only use contexts or sentences, not both")
|
|
114
|
+
|
|
115
|
+
metadata_list: Sequence[Metadata] = prompts_metadata or sentence_metadata or []
|
|
116
|
+
private_notes_metadata_list: Sequence[Metadata] = [PrivateTextMetadata(text=text) for text in private_notes] if private_notes else []
|
|
117
|
+
|
|
118
|
+
multi_metadata: Sequence[Sequence[Metadata]] = (
|
|
119
|
+
[[metadata, private_notes_metadata] for metadata, private_notes_metadata in zip(metadata_list, private_notes_metadata_list, strict=True)] if metadata_list and private_notes
|
|
120
|
+
else [[private_notes_metadata] for private_notes_metadata in private_notes_metadata_list] if private_notes
|
|
121
|
+
else [[metadata] for metadata in metadata_list] if metadata_list
|
|
122
|
+
else []
|
|
123
|
+
)
|
|
110
124
|
|
|
111
125
|
order = (order_builder
|
|
112
126
|
._workflow(workflow)
|
|
113
127
|
._media(
|
|
114
|
-
|
|
115
|
-
|
|
128
|
+
assets=assets,
|
|
129
|
+
multi_metadata=multi_metadata
|
|
116
130
|
)
|
|
117
131
|
._referee(referee)
|
|
118
132
|
._filters(filters)
|
|
@@ -138,7 +152,8 @@ class RapidataOrderManager:
|
|
|
138
152
|
confidence_threshold: float | None = None,
|
|
139
153
|
filters: Sequence[RapidataFilter] = [],
|
|
140
154
|
settings: Sequence[RapidataSetting] = [],
|
|
141
|
-
selections: Sequence[RapidataSelection]
|
|
155
|
+
selections: Sequence[RapidataSelection] = [],
|
|
156
|
+
private_notes: list[str] | None = None,
|
|
142
157
|
) -> RapidataOrder:
|
|
143
158
|
"""Create a classification order.
|
|
144
159
|
|
|
@@ -159,7 +174,10 @@ class RapidataOrderManager:
|
|
|
159
174
|
If provided, the classification datapoint will stop after the threshold is reached or at the number of responses, whatever happens first.
|
|
160
175
|
filters (Sequence[RapidataFilter], optional): The list of filters for the classification. Defaults to []. Decides who the tasks should be shown to.
|
|
161
176
|
settings (Sequence[RapidataSetting], optional): The list of settings for the classification. Defaults to []. Decides how the tasks should be shown.
|
|
162
|
-
selections (Sequence[RapidataSelection], optional): The list of selections for the classification. Defaults to
|
|
177
|
+
selections (Sequence[RapidataSelection], optional): The list of selections for the classification. Defaults to []. Decides in what order the tasks should be shown.
|
|
178
|
+
private_notes (list[str], optional): The list of private notes for the classification. Defaults to None.
|
|
179
|
+
If provided has to be the same length as datapoints.\n
|
|
180
|
+
This will NOT be shown to the labelers but will be included in the result purely for your own reference.
|
|
163
181
|
"""
|
|
164
182
|
|
|
165
183
|
if data_type == RapidataDataTypes.MEDIA:
|
|
@@ -183,7 +201,8 @@ class RapidataOrderManager:
|
|
|
183
201
|
confidence_threshold=confidence_threshold,
|
|
184
202
|
filters=filters,
|
|
185
203
|
selections=selections,
|
|
186
|
-
settings=settings
|
|
204
|
+
settings=settings,
|
|
205
|
+
private_notes=private_notes
|
|
187
206
|
)
|
|
188
207
|
|
|
189
208
|
def create_compare_order(self,
|
|
@@ -197,7 +216,8 @@ class RapidataOrderManager:
|
|
|
197
216
|
confidence_threshold: float | None = None,
|
|
198
217
|
filters: Sequence[RapidataFilter] = [],
|
|
199
218
|
settings: Sequence[RapidataSetting] = [],
|
|
200
|
-
selections: Sequence[RapidataSelection]
|
|
219
|
+
selections: Sequence[RapidataSelection] = [],
|
|
220
|
+
private_notes: list[str] | None = None,
|
|
201
221
|
) -> RapidataOrder:
|
|
202
222
|
"""Create a compare order.
|
|
203
223
|
|
|
@@ -217,7 +237,10 @@ class RapidataOrderManager:
|
|
|
217
237
|
If provided, the comparison datapoint will stop after the threshold is reached or at the number of responses, whatever happens first.
|
|
218
238
|
filters (Sequence[RapidataFilter], optional): The list of filters for the comparison. Defaults to []. Decides who the tasks should be shown to.
|
|
219
239
|
settings (Sequence[RapidataSetting], optional): The list of settings for the comparison. Defaults to []. Decides how the tasks should be shown.
|
|
220
|
-
selections (Sequence[RapidataSelection], optional): The list of selections for the comparison. Defaults to
|
|
240
|
+
selections (Sequence[RapidataSelection], optional): The list of selections for the comparison. Defaults to []. Decides in what order the tasks should be shown.
|
|
241
|
+
private_notes (list[str], optional): The list of private notes for the comparison. Defaults to None.\n
|
|
242
|
+
If provided has to be the same length as datapoints.\n
|
|
243
|
+
This will NOT be shown to the labelers but will be included in the result purely for your own reference.
|
|
221
244
|
"""
|
|
222
245
|
|
|
223
246
|
if data_type == RapidataDataTypes.MEDIA:
|
|
@@ -240,7 +263,8 @@ class RapidataOrderManager:
|
|
|
240
263
|
confidence_threshold=confidence_threshold,
|
|
241
264
|
filters=filters,
|
|
242
265
|
selections=selections,
|
|
243
|
-
settings=settings
|
|
266
|
+
settings=settings,
|
|
267
|
+
private_notes=private_notes
|
|
244
268
|
)
|
|
245
269
|
|
|
246
270
|
def create_ranking_order(self,
|
|
@@ -255,7 +279,7 @@ class RapidataOrderManager:
|
|
|
255
279
|
validation_set_id: Optional[str] = None,
|
|
256
280
|
filters: Sequence[RapidataFilter] = [],
|
|
257
281
|
settings: Sequence[RapidataSetting] = [],
|
|
258
|
-
selections:
|
|
282
|
+
selections: Sequence[RapidataSelection] = []
|
|
259
283
|
) -> RapidataOrder:
|
|
260
284
|
"""
|
|
261
285
|
Create a ranking order.
|
|
@@ -276,7 +300,7 @@ class RapidataOrderManager:
|
|
|
276
300
|
If provided, one validation task will be shown infront of the datapoints that will be labeled.
|
|
277
301
|
filters (Sequence[RapidataFilter], optional): The list of filters for the order. Defaults to []. Decides who the tasks should be shown to.
|
|
278
302
|
settings (Sequence[RapidataSetting], optional): The list of settings for the order. Defaults to []. Decides how the tasks should be shown.
|
|
279
|
-
selections (Sequence[RapidataSelection], optional): The list of selections for the order. Defaults to
|
|
303
|
+
selections (Sequence[RapidataSelection], optional): The list of selections for the order. Defaults to []. Decides in what order the tasks should be shown.
|
|
280
304
|
"""
|
|
281
305
|
|
|
282
306
|
if data_type == RapidataDataTypes.MEDIA:
|
|
@@ -299,7 +323,7 @@ class RapidataOrderManager:
|
|
|
299
323
|
validation_set_id=validation_set_id,
|
|
300
324
|
filters=filters,
|
|
301
325
|
selections=selections,
|
|
302
|
-
settings=settings
|
|
326
|
+
settings=settings,
|
|
303
327
|
)
|
|
304
328
|
|
|
305
329
|
def create_free_text_order(self,
|
|
@@ -310,7 +334,8 @@ class RapidataOrderManager:
|
|
|
310
334
|
responses_per_datapoint: int = 10,
|
|
311
335
|
filters: Sequence[RapidataFilter] = [],
|
|
312
336
|
settings: Sequence[RapidataSetting] = [],
|
|
313
|
-
selections: Sequence[RapidataSelection]
|
|
337
|
+
selections: Sequence[RapidataSelection] = [],
|
|
338
|
+
private_notes: list[str] | None = None,
|
|
314
339
|
) -> RapidataOrder:
|
|
315
340
|
"""Create a free text order.
|
|
316
341
|
|
|
@@ -323,7 +348,10 @@ class RapidataOrderManager:
|
|
|
323
348
|
responses_per_datapoint (int, optional): The number of responses that will be collected per datapoint. Defaults to 10.
|
|
324
349
|
filters (Sequence[RapidataFilter], optional): The list of filters for the free text. Defaults to []. Decides who the tasks should be shown to.
|
|
325
350
|
settings (Sequence[RapidataSetting], optional): The list of settings for the free text. Defaults to []. Decides how the tasks should be shown.
|
|
326
|
-
selections (Sequence[RapidataSelection], optional): The list of selections for the free text. Defaults to
|
|
351
|
+
selections (Sequence[RapidataSelection], optional): The list of selections for the free text. Defaults to []. Decides in what order the tasks should be shown.
|
|
352
|
+
private_notes (list[str], optional): The list of private notes for the free text. Defaults to None.\n
|
|
353
|
+
If provided has to be the same length as datapoints.\n
|
|
354
|
+
This will NOT be shown to the labelers but will be included in the result purely for your own reference.
|
|
327
355
|
"""
|
|
328
356
|
|
|
329
357
|
if data_type == RapidataDataTypes.MEDIA:
|
|
@@ -344,7 +372,8 @@ class RapidataOrderManager:
|
|
|
344
372
|
filters=filters,
|
|
345
373
|
selections=selections,
|
|
346
374
|
settings=settings,
|
|
347
|
-
default_labeling_amount=1
|
|
375
|
+
default_labeling_amount=1,
|
|
376
|
+
private_notes=private_notes
|
|
348
377
|
)
|
|
349
378
|
|
|
350
379
|
def create_select_words_order(self,
|
|
@@ -356,7 +385,8 @@ class RapidataOrderManager:
|
|
|
356
385
|
validation_set_id: str | None = None,
|
|
357
386
|
filters: Sequence[RapidataFilter] = [],
|
|
358
387
|
settings: Sequence[RapidataSetting] = [],
|
|
359
|
-
selections: Sequence[RapidataSelection]
|
|
388
|
+
selections: Sequence[RapidataSelection] = [],
|
|
389
|
+
private_notes: list[str] | None = None,
|
|
360
390
|
) -> RapidataOrder:
|
|
361
391
|
"""Create a select words order.
|
|
362
392
|
|
|
@@ -371,7 +401,10 @@ class RapidataOrderManager:
|
|
|
371
401
|
If provided, one validation task will be shown infront of the datapoints that will be labeled.
|
|
372
402
|
filters (Sequence[RapidataFilter], optional): The list of filters for the select words. Defaults to []. Decides who the tasks should be shown to.
|
|
373
403
|
settings (Sequence[RapidataSetting], optional): The list of settings for the select words. Defaults to []. Decides how the tasks should be shown.
|
|
374
|
-
selections (Sequence[RapidataSelection], optional): The list of selections for the select words. Defaults to
|
|
404
|
+
selections (Sequence[RapidataSelection], optional): The list of selections for the select words. Defaults to []. Decides in what order the tasks should be shown.
|
|
405
|
+
private_notes (list[str], optional): The list of private notes for the select words. Defaults to None.\n
|
|
406
|
+
If provided has to be the same length as datapoints.\n
|
|
407
|
+
This will NOT be shown to the labelers but will be included in the result purely for your own reference.
|
|
375
408
|
"""
|
|
376
409
|
|
|
377
410
|
assets = [MediaAsset(path=path) for path in datapoints]
|
|
@@ -388,7 +421,8 @@ class RapidataOrderManager:
|
|
|
388
421
|
selections=selections,
|
|
389
422
|
settings=settings,
|
|
390
423
|
sentences=sentences,
|
|
391
|
-
default_labeling_amount=2
|
|
424
|
+
default_labeling_amount=2,
|
|
425
|
+
private_notes=private_notes
|
|
392
426
|
)
|
|
393
427
|
|
|
394
428
|
def create_locate_order(self,
|
|
@@ -400,7 +434,8 @@ class RapidataOrderManager:
|
|
|
400
434
|
validation_set_id: str | None = None,
|
|
401
435
|
filters: Sequence[RapidataFilter] = [],
|
|
402
436
|
settings: Sequence[RapidataSetting] = [],
|
|
403
|
-
selections: Sequence[RapidataSelection]
|
|
437
|
+
selections: Sequence[RapidataSelection] = [],
|
|
438
|
+
private_notes: list[str] | None = None,
|
|
404
439
|
) -> RapidataOrder:
|
|
405
440
|
"""Create a locate order.
|
|
406
441
|
|
|
@@ -416,7 +451,10 @@ class RapidataOrderManager:
|
|
|
416
451
|
If provided, one validation task will be shown infront of the datapoints that will be labeled.
|
|
417
452
|
filters (Sequence[RapidataFilter], optional): The list of filters for the locate. Defaults to []. Decides who the tasks should be shown to.
|
|
418
453
|
settings (Sequence[RapidataSetting], optional): The list of settings for the locate. Defaults to []. Decides how the tasks should be shown.
|
|
419
|
-
selections (Sequence[RapidataSelection], optional): The list of selections for the locate. Defaults to
|
|
454
|
+
selections (Sequence[RapidataSelection], optional): The list of selections for the locate. Defaults to []. Decides in what order the tasks should be shown.
|
|
455
|
+
private_notes (list[str], optional): The list of private notes for the locate. Defaults to None.\n
|
|
456
|
+
If provided has to be the same length as datapoints.\n
|
|
457
|
+
This will NOT be shown to the labelers but will be included in the result purely for your own reference.
|
|
420
458
|
"""
|
|
421
459
|
|
|
422
460
|
assets = [MediaAsset(path=path) for path in datapoints]
|
|
@@ -430,7 +468,8 @@ class RapidataOrderManager:
|
|
|
430
468
|
validation_set_id=validation_set_id,
|
|
431
469
|
filters=filters,
|
|
432
470
|
selections=selections,
|
|
433
|
-
settings=settings
|
|
471
|
+
settings=settings,
|
|
472
|
+
private_notes=private_notes
|
|
434
473
|
)
|
|
435
474
|
|
|
436
475
|
def create_draw_order(self,
|
|
@@ -442,7 +481,8 @@ class RapidataOrderManager:
|
|
|
442
481
|
validation_set_id: str | None = None,
|
|
443
482
|
filters: Sequence[RapidataFilter] = [],
|
|
444
483
|
settings: Sequence[RapidataSetting] = [],
|
|
445
|
-
selections: Sequence[RapidataSelection]
|
|
484
|
+
selections: Sequence[RapidataSelection] = [],
|
|
485
|
+
private_notes: list[str] | None = None,
|
|
446
486
|
) -> RapidataOrder:
|
|
447
487
|
"""Create a draw order.
|
|
448
488
|
|
|
@@ -458,7 +498,10 @@ class RapidataOrderManager:
|
|
|
458
498
|
If provided, one validation task will be shown infront of the datapoints that will be labeled.
|
|
459
499
|
filters (Sequence[RapidataFilter], optional): The list of filters for the draw lines. Defaults to []. Decides who the tasks should be shown to.
|
|
460
500
|
settings (Sequence[RapidataSetting], optional): The list of settings for the draw lines. Defaults to []. Decides how the tasks should be shown.
|
|
461
|
-
selections (Sequence[RapidataSelection], optional): The list of selections for the draw lines. Defaults to
|
|
501
|
+
selections (Sequence[RapidataSelection], optional): The list of selections for the draw lines. Defaults to []. Decides in what order the tasks should be shown.
|
|
502
|
+
private_notes (list[str], optional): The list of private notes for the draw lines. Defaults to None.\n
|
|
503
|
+
If provided has to be the same length as datapoints.\n
|
|
504
|
+
This will NOT be shown to the labelers but will be included in the result purely for your own reference.
|
|
462
505
|
"""
|
|
463
506
|
|
|
464
507
|
assets = [MediaAsset(path=path) for path in datapoints]
|
|
@@ -472,7 +515,8 @@ class RapidataOrderManager:
|
|
|
472
515
|
validation_set_id=validation_set_id,
|
|
473
516
|
filters=filters,
|
|
474
517
|
selections=selections,
|
|
475
|
-
settings=settings
|
|
518
|
+
settings=settings,
|
|
519
|
+
private_notes=private_notes
|
|
476
520
|
)
|
|
477
521
|
|
|
478
522
|
def create_timestamp_order(self,
|
|
@@ -484,7 +528,8 @@ class RapidataOrderManager:
|
|
|
484
528
|
validation_set_id: str | None = None,
|
|
485
529
|
filters: Sequence[RapidataFilter] = [],
|
|
486
530
|
settings: Sequence[RapidataSetting] = [],
|
|
487
|
-
selections: Sequence[RapidataSelection]
|
|
531
|
+
selections: Sequence[RapidataSelection] = [],
|
|
532
|
+
private_notes: list[str] | None = None,
|
|
488
533
|
) -> RapidataOrder:
|
|
489
534
|
"""Create a timestamp order.
|
|
490
535
|
|
|
@@ -497,9 +542,13 @@ class RapidataOrderManager:
|
|
|
497
542
|
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)
|
|
498
543
|
Will be match up with the datapoints using the list index.
|
|
499
544
|
validation_set_id (str, optional): The ID of the validation set. Defaults to None.\n
|
|
545
|
+
If provided, one validation task will be shown infront of the datapoints that will be labeled.
|
|
500
546
|
filters (Sequence[RapidataFilter], optional): The list of filters for the timestamp. Defaults to []. Decides who the tasks should be shown to.
|
|
501
547
|
settings (Sequence[RapidataSetting], optional): The list of settings for the timestamp. Defaults to []. Decides how the tasks should be shown.
|
|
502
|
-
selections (Sequence[RapidataSelection], optional): The list of selections for the timestamp. Defaults to
|
|
548
|
+
selections (Sequence[RapidataSelection], optional): The list of selections for the timestamp. Defaults to []. Decides in what order the tasks should be shown.
|
|
549
|
+
private_notes (list[str], optional): The list of private notes for the timestamp. Defaults to None.\n
|
|
550
|
+
If provided has to be the same length as datapoints.\n
|
|
551
|
+
This will NOT be shown to the labelers but will be included in the result purely for your own reference.
|
|
503
552
|
"""
|
|
504
553
|
|
|
505
554
|
assets = [MediaAsset(path=path) for path in datapoints]
|
|
@@ -520,7 +569,8 @@ class RapidataOrderManager:
|
|
|
520
569
|
filters=filters,
|
|
521
570
|
selections=selections,
|
|
522
571
|
settings=settings,
|
|
523
|
-
default_labeling_amount=2
|
|
572
|
+
default_labeling_amount=2,
|
|
573
|
+
private_notes=private_notes
|
|
524
574
|
)
|
|
525
575
|
|
|
526
576
|
def get_order_by_id(self, order_id: str) -> RapidataOrder:
|
|
@@ -2,6 +2,7 @@ import pandas as pd
|
|
|
2
2
|
from typing import Any
|
|
3
3
|
from pandas.core.indexes.base import Index
|
|
4
4
|
import json
|
|
5
|
+
from rapidata.rapidata_client.logging import managed_print
|
|
5
6
|
|
|
6
7
|
class RapidataResults(dict):
|
|
7
8
|
"""
|
|
@@ -32,7 +33,7 @@ class RapidataResults(dict):
|
|
|
32
33
|
return pd.DataFrame()
|
|
33
34
|
|
|
34
35
|
if self["info"].get("orderType") is None:
|
|
35
|
-
|
|
36
|
+
managed_print("Warning: Results are old and Order type is not specified. Dataframe might be wrong.")
|
|
36
37
|
|
|
37
38
|
# Check for detailed results if split_details is True
|
|
38
39
|
if split_details:
|
|
@@ -8,6 +8,7 @@ from rapidata.rapidata_client.validation.validation_set_manager import (
|
|
|
8
8
|
|
|
9
9
|
from rapidata.rapidata_client.demographic.demographic_manager import DemographicManager
|
|
10
10
|
|
|
11
|
+
from rapidata.rapidata_client.logging import logger
|
|
11
12
|
|
|
12
13
|
class RapidataClient:
|
|
13
14
|
"""The Rapidata client is the main entry point for interacting with the Rapidata API. It allows you to create orders and validation sets."""
|
|
@@ -38,6 +39,7 @@ class RapidataClient:
|
|
|
38
39
|
order (RapidataOrderManager): The RapidataOrderManager instance.
|
|
39
40
|
validation (ValidationSetManager): The ValidationSetManager instance.
|
|
40
41
|
"""
|
|
42
|
+
logger.debug("Initializing OpenAPIService")
|
|
41
43
|
self._openapi_service = OpenAPIService(
|
|
42
44
|
client_id=client_id,
|
|
43
45
|
client_secret=client_secret,
|
|
@@ -48,12 +50,15 @@ class RapidataClient:
|
|
|
48
50
|
leeway=leeway,
|
|
49
51
|
)
|
|
50
52
|
|
|
53
|
+
logger.debug("Initializing RapidataOrderManager")
|
|
51
54
|
self.order = RapidataOrderManager(openapi_service=self._openapi_service)
|
|
52
55
|
|
|
56
|
+
logger.debug("Initializing ValidationSetManager")
|
|
53
57
|
self.validation = ValidationSetManager(openapi_service=self._openapi_service)
|
|
54
58
|
|
|
59
|
+
logger.debug("Initializing DemographicManager")
|
|
55
60
|
self._demographic = DemographicManager(openapi_service=self._openapi_service)
|
|
56
|
-
|
|
61
|
+
|
|
57
62
|
def reset_credentials(self):
|
|
58
63
|
"""Reset the credentials saved in the configuration file for the current environment."""
|
|
59
64
|
self._openapi_service.reset_credentials()
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
from rapidata.rapidata_client.selection._base_selection import RapidataSelection
|
|
3
|
+
from rapidata.rapidata_client.selection.retrieval_modes import RetrievalMode
|
|
3
4
|
from rapidata.api_client.models.labeling_selection import (
|
|
4
5
|
LabelingSelection as LabelingSelectionModel,
|
|
5
6
|
)
|
|
@@ -12,10 +13,15 @@ class LabelingSelection(RapidataSelection):
|
|
|
12
13
|
|
|
13
14
|
Args:
|
|
14
15
|
amount (int): The amount of labeling rapids that will be shown per session.
|
|
16
|
+
retrieval_mode (RetrievalMode): The retrieval mode to use. Defaults to "Random".
|
|
17
|
+
max_iterations (int | None): The maximum number an annotator can see the same task. Defaults to None.
|
|
18
|
+
This parameter is only taken into account when using "Shuffled" or "Sequential" retrieval modes.
|
|
15
19
|
"""
|
|
16
20
|
|
|
17
|
-
def __init__(self, amount: int):
|
|
21
|
+
def __init__(self, amount: int, retrieval_mode: RetrievalMode = RetrievalMode.Random, max_iterations: int | None = None):
|
|
18
22
|
self.amount = amount
|
|
23
|
+
self.retrieval_mode = retrieval_mode
|
|
24
|
+
self.max_iterations = max_iterations
|
|
19
25
|
|
|
20
26
|
def _to_model(self) -> Any:
|
|
21
|
-
return LabelingSelectionModel(_t="LabelingSelection", amount=self.amount)
|
|
27
|
+
return LabelingSelectionModel(_t="LabelingSelection", amount=self.amount, retrievalMode=self.retrieval_mode.value, maxIterations=self.max_iterations)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
class RetrievalMode(Enum):
|
|
4
|
+
# Will just randomly shuffle the datapoints. This is the default and will NOT take into account the "max_iterations" parameter.
|
|
5
|
+
Random = "Random"
|
|
6
|
+
# Will shuffle the datapoints randomly for each user. The user will then see the datapoints in that order. This will take into account the "max_iterations" parameter.
|
|
7
|
+
Shuffled = "Shuffled"
|
|
8
|
+
# Will show the datapoints in the order they are in the dataset. This will take into account the "max_iterations" parameter.
|
|
9
|
+
Sequential = "Sequential"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
|
|
2
|
+
from rapidata.rapidata_client.logging import managed_print
|
|
2
3
|
|
|
3
4
|
class AlertOnFastResponse(RapidataSetting):
|
|
4
5
|
"""
|
|
@@ -12,7 +13,7 @@ class AlertOnFastResponse(RapidataSetting):
|
|
|
12
13
|
if not isinstance(threshold, int):
|
|
13
14
|
raise ValueError("The alert must be an integer.")
|
|
14
15
|
if threshold < 10:
|
|
15
|
-
|
|
16
|
+
managed_print(f"Warning: Are you sure you want to set the threshold so low ({threshold} milliseconds)?")
|
|
16
17
|
if threshold > 25000:
|
|
17
18
|
raise ValueError("The alert must be less than 25000 milliseconds.")
|
|
18
19
|
if threshold < 0:
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
|
|
2
|
+
from rapidata.rapidata_client.logging import managed_print, logger
|
|
2
3
|
|
|
3
4
|
class FreeTextMinimumCharacters(RapidataSetting):
|
|
4
5
|
"""
|
|
@@ -12,5 +13,5 @@ class FreeTextMinimumCharacters(RapidataSetting):
|
|
|
12
13
|
if value < 1:
|
|
13
14
|
raise ValueError("The minimum number of characters must be greater than or equal to 1.")
|
|
14
15
|
if value > 40:
|
|
15
|
-
|
|
16
|
+
managed_print(f"Warning: Are you sure you want to set the minimum number of characters at {value}?")
|
|
16
17
|
super().__init__(key="free_text_minimum_characters", value=value)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from rapidata.rapidata_client.validation.rapids.rapids import Rapid
|
|
2
2
|
from rapidata.service.openapi_service import OpenAPIService
|
|
3
|
-
from
|
|
4
|
-
import requests
|
|
3
|
+
from rapidata.rapidata_client.logging import logger
|
|
5
4
|
from rapidata.api_client.models.update_dimensions_model import UpdateDimensionsModel
|
|
6
5
|
from rapidata.rapidata_client.assets._sessions import SessionManager
|
|
7
6
|
|
|
@@ -37,6 +36,7 @@ class RapidataValidationSet:
|
|
|
37
36
|
Args:
|
|
38
37
|
dimensions (list[str]): The new dimensions of the validation set.
|
|
39
38
|
"""
|
|
39
|
+
logger.debug(f"Updating dimensions for validation set {self.id} to {dimensions}")
|
|
40
40
|
self.__openapi_service.validation_api.validation_validation_set_id_dimensions_patch(self.id, UpdateDimensionsModel(dimensions=dimensions))
|
|
41
41
|
return self
|
|
42
42
|
|
|
@@ -19,7 +19,8 @@ from rapidata.api_client.models.create_datapoint_from_files_model_metadata_inner
|
|
|
19
19
|
|
|
20
20
|
from rapidata.service.openapi_service import OpenAPIService
|
|
21
21
|
|
|
22
|
-
import
|
|
22
|
+
from rapidata.rapidata_client.logging import logger
|
|
23
|
+
|
|
23
24
|
|
|
24
25
|
class Rapid():
|
|
25
26
|
def __init__(self, asset: MediaAsset | TextAsset | MultiAsset, metadata: Sequence[Metadata], payload: Any, truth: Any, randomCorrectProbability: float, explanation: str | None):
|
|
@@ -29,6 +30,7 @@ class Rapid():
|
|
|
29
30
|
self.truth = truth
|
|
30
31
|
self.randomCorrectProbability = randomCorrectProbability
|
|
31
32
|
self.explanation = explanation
|
|
33
|
+
logger.debug(f"Created Rapid with asset: {self.asset}, metadata: {self.metadata}, payload: {self.payload}, truth: {self.truth}, randomCorrectProbability: {self.randomCorrectProbability}, explanation: {self.explanation}")
|
|
32
34
|
|
|
33
35
|
def _add_to_validation_set(self, validationSetId: str, openapi_service: OpenAPIService) -> None:
|
|
34
36
|
if isinstance(self.asset, TextAsset) or (isinstance(self.asset, MultiAsset) and isinstance(self.asset.assets[0], TextAsset)):
|