rapidata 1.1.0__py3-none-any.whl → 1.2.1__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.
- rapidata/__init__.py +1 -0
- rapidata/api_client/__init__.py +30 -8
- rapidata/api_client/api/__init__.py +2 -0
- rapidata/api_client/api/campaign_api.py +8 -4
- rapidata/api_client/api/coco_api.py +4 -2
- rapidata/api_client/api/compare_workflow_api.py +2 -1
- rapidata/api_client/api/datapoint_api.py +6 -3
- rapidata/api_client/api/dataset_api.py +404 -396
- rapidata/api_client/api/identity_api.py +329 -50
- rapidata/api_client/api/newsletter_api.py +4 -2
- rapidata/api_client/api/order_api.py +40 -20
- rapidata/api_client/api/pipeline_api.py +6 -3
- rapidata/api_client/api/rapid_api.py +10 -5
- rapidata/api_client/api/rapidata_identity_api_api.py +272 -0
- rapidata/api_client/api/simple_workflow_api.py +2 -1
- rapidata/api_client/api/user_info_api.py +272 -0
- rapidata/api_client/api/validation_api.py +14 -7
- rapidata/api_client/api/workflow_api.py +30 -1067
- rapidata/api_client/models/__init__.py +28 -8
- rapidata/api_client/models/classification_metadata_model.py +98 -0
- rapidata/api_client/models/compare_workflow_config.py +3 -3
- rapidata/api_client/models/compare_workflow_config_model.py +3 -3
- rapidata/api_client/models/compare_workflow_model1.py +4 -18
- rapidata/api_client/models/compare_workflow_model1_referee.py +154 -0
- rapidata/api_client/models/completed_rapid_model.py +3 -3
- rapidata/api_client/models/completed_rapid_model_asset.py +170 -0
- rapidata/api_client/models/count_metadata_model.py +98 -0
- rapidata/api_client/models/demographic_metadata_model.py +100 -0
- rapidata/api_client/models/file_asset_model.py +3 -3
- rapidata/api_client/models/file_asset_model1.py +108 -0
- rapidata/api_client/models/file_asset_model1_metadata_inner.py +252 -0
- rapidata/api_client/models/file_asset_model2.py +108 -0
- rapidata/api_client/models/file_asset_model_metadata_inner.py +252 -0
- rapidata/api_client/models/image_dimension_metadata_model.py +100 -0
- rapidata/api_client/models/in_progress_rapid_model.py +3 -3
- rapidata/api_client/models/issue_auth_token_result.py +1 -1
- rapidata/api_client/models/legacy_issue_client_auth_token_result.py +87 -0
- rapidata/api_client/models/legacy_request_password_reset_command.py +98 -0
- rapidata/api_client/models/legacy_submit_password_reset_command.py +102 -0
- rapidata/api_client/models/location_metadata_model.py +100 -0
- rapidata/api_client/models/multi_asset_model.py +3 -3
- rapidata/api_client/models/multi_asset_model1.py +118 -0
- rapidata/api_client/models/multi_asset_model1_assets_inner.py +170 -0
- rapidata/api_client/models/multi_asset_model2.py +118 -0
- rapidata/api_client/models/not_started_rapid_model.py +3 -3
- rapidata/api_client/models/null_asset_model.py +3 -3
- rapidata/api_client/models/null_asset_model1.py +106 -0
- rapidata/api_client/models/null_asset_model2.py +106 -0
- rapidata/api_client/models/original_filename_metadata_model.py +98 -0
- rapidata/api_client/models/prompt_metadata_model.py +98 -0
- rapidata/api_client/models/query_validation_rapids_result_asset.py +40 -40
- rapidata/api_client/models/ranked_datapoint_model.py +3 -3
- rapidata/api_client/models/simple_workflow_config.py +6 -6
- rapidata/api_client/models/simple_workflow_config_model.py +3 -3
- rapidata/api_client/models/simple_workflow_model1.py +7 -21
- rapidata/api_client/models/simple_workflow_model1_blueprint.py +238 -0
- rapidata/api_client/models/text_asset_model.py +3 -3
- rapidata/api_client/models/text_asset_model1.py +108 -0
- rapidata/api_client/models/text_asset_model2.py +108 -0
- rapidata/api_client/models/text_metadata_model.py +98 -0
- rapidata/api_client/models/transcription_metadata_model.py +98 -0
- rapidata/api_client/models/translated_prompt_metadata_model.py +102 -0
- rapidata/api_client/models/translated_string.py +93 -0
- rapidata/api_client_README.md +36 -13
- rapidata/rapidata_client/__init__.py +13 -2
- rapidata/rapidata_client/assets/media_asset.py +1 -1
- rapidata/rapidata_client/assets/multi_asset.py +14 -3
- rapidata/rapidata_client/dataset/rapidata_dataset.py +59 -21
- rapidata/rapidata_client/dataset/validation_set_builder.py +1 -1
- rapidata/rapidata_client/order/rapidata_order.py +49 -18
- rapidata/rapidata_client/order/rapidata_order_builder.py +99 -41
- rapidata/rapidata_client/selection/__init__.py +1 -0
- rapidata/rapidata_client/selection/capped_selection.py +25 -0
- rapidata/rapidata_client/selection/demographic_selection.py +3 -2
- rapidata/rapidata_client/simple_builders/__init__.py +0 -0
- rapidata/rapidata_client/simple_builders/simple_classification_builders.py +14 -9
- rapidata/rapidata_client/simple_builders/simple_compare_builders.py +6 -3
- rapidata/service/openapi_service.py +15 -0
- {rapidata-1.1.0.dist-info → rapidata-1.2.1.dist-info}/METADATA +1 -1
- {rapidata-1.1.0.dist-info → rapidata-1.2.1.dist-info}/RECORD +82 -50
- {rapidata-1.1.0.dist-info → rapidata-1.2.1.dist-info}/LICENSE +0 -0
- {rapidata-1.1.0.dist-info → rapidata-1.2.1.dist-info}/WHEEL +0 -0
|
@@ -28,6 +28,10 @@ from rapidata.service.openapi_service import OpenAPIService
|
|
|
28
28
|
|
|
29
29
|
from rapidata.rapidata_client.workflow.compare_workflow import CompareWorkflow
|
|
30
30
|
|
|
31
|
+
from rapidata.rapidata_client.assets import MediaAsset, TextAsset, MultiAsset
|
|
32
|
+
|
|
33
|
+
from typing import cast, Sequence
|
|
34
|
+
|
|
31
35
|
|
|
32
36
|
class RapidataOrderBuilder:
|
|
33
37
|
"""Builder object for creating Rapidata orders.
|
|
@@ -55,7 +59,6 @@ class RapidataOrderBuilder:
|
|
|
55
59
|
self._openapi_service = openapi_service
|
|
56
60
|
self._workflow: Workflow | None = None
|
|
57
61
|
self._referee: Referee | None = None
|
|
58
|
-
self._media_paths: list[str | list[str]] = []
|
|
59
62
|
self._metadata: list[Metadata] | None = None
|
|
60
63
|
self._aggregator: AggregatorType | None = None
|
|
61
64
|
self._validation_set_id: str | None = None
|
|
@@ -65,8 +68,7 @@ class RapidataOrderBuilder:
|
|
|
65
68
|
self._selections: list[Selection] = []
|
|
66
69
|
self._rapids_per_bag: int = 2
|
|
67
70
|
self._priority: int = 50
|
|
68
|
-
self.
|
|
69
|
-
self._media_paths: list[str | list[str]] = []
|
|
71
|
+
self._assets: list[MediaAsset] | list[TextAsset] | list[MultiAsset] = []
|
|
70
72
|
|
|
71
73
|
def _to_model(self) -> CreateOrderModel:
|
|
72
74
|
"""
|
|
@@ -139,13 +141,17 @@ class RapidataOrderBuilder:
|
|
|
139
141
|
Returns:
|
|
140
142
|
RapidataOrder: The created RapidataOrder instance.
|
|
141
143
|
"""
|
|
144
|
+
if not self._workflow or not self._assets:
|
|
145
|
+
raise ValueError(
|
|
146
|
+
"You must provide a workflow and assets to create an order. Use the .workflow() and .media() methods respecitvely."
|
|
147
|
+
)
|
|
142
148
|
order_model = self._to_model()
|
|
143
149
|
if isinstance(
|
|
144
150
|
self._workflow, CompareWorkflow
|
|
145
151
|
): # Temporary fix; will be handled by backend in the future
|
|
146
|
-
assert all(
|
|
147
|
-
|
|
148
|
-
)
|
|
152
|
+
assert all(isinstance(item, MultiAsset) for item in self._assets), (
|
|
153
|
+
"The media paths must be of type MultiAsset for comparison tasks."
|
|
154
|
+
)
|
|
149
155
|
|
|
150
156
|
result = self._openapi_service.order_api.order_create_post(
|
|
151
157
|
create_order_model=order_model
|
|
@@ -159,23 +165,38 @@ class RapidataOrderBuilder:
|
|
|
159
165
|
openapi_service=self._openapi_service,
|
|
160
166
|
)
|
|
161
167
|
|
|
162
|
-
if
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if not self._media_paths and not self._texts:
|
|
168
|
-
raise ValueError(
|
|
169
|
-
"You must provide either media paths or texts to the order."
|
|
168
|
+
if all(isinstance(item, MediaAsset) for item in self._assets):
|
|
169
|
+
assets = cast(list[MediaAsset], self._assets)
|
|
170
|
+
order.dataset.add_media_from_paths(
|
|
171
|
+
assets, self._metadata, max_workers
|
|
170
172
|
)
|
|
173
|
+
|
|
174
|
+
elif all(isinstance(item, TextAsset) for item in self._assets):
|
|
175
|
+
assets = cast(list[TextAsset], self._assets)
|
|
176
|
+
order.dataset.add_texts(assets)
|
|
177
|
+
|
|
178
|
+
elif all(isinstance(item, MultiAsset) for item in self._assets):
|
|
179
|
+
multi_assets = cast(list[MultiAsset], self._assets)
|
|
180
|
+
|
|
181
|
+
# Check if all MultiAssets contain the same type of assets
|
|
182
|
+
first_asset_type = type(multi_assets[0].assets[0])
|
|
183
|
+
if not all(isinstance(asset, first_asset_type) for multi_asset in multi_assets for asset in multi_asset.assets):
|
|
184
|
+
raise ValueError("All MultiAssets must contain the same type of assets (either all MediaAssets or all TextAssets).")
|
|
185
|
+
|
|
186
|
+
# Process based on the asset type
|
|
187
|
+
if issubclass(first_asset_type, MediaAsset):
|
|
188
|
+
order.dataset.add_media_from_paths(
|
|
189
|
+
multi_assets, self._metadata, max_workers
|
|
190
|
+
)
|
|
171
191
|
|
|
172
|
-
|
|
173
|
-
|
|
192
|
+
elif issubclass(first_asset_type, TextAsset):
|
|
193
|
+
order.dataset.add_texts(multi_assets)
|
|
174
194
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
195
|
+
else:
|
|
196
|
+
raise ValueError("MultiAsset must contain MediaAssets or TextAssets objects.")
|
|
197
|
+
|
|
198
|
+
else:
|
|
199
|
+
raise ValueError("Media paths must be of type MediaAsset, TextAsset, or MultiAsset.")
|
|
179
200
|
|
|
180
201
|
if submit:
|
|
181
202
|
order.submit()
|
|
@@ -192,6 +213,9 @@ class RapidataOrderBuilder:
|
|
|
192
213
|
Returns:
|
|
193
214
|
RapidataOrderBuilder: The updated RapidataOrderBuilder instance.
|
|
194
215
|
"""
|
|
216
|
+
if not isinstance(workflow, Workflow):
|
|
217
|
+
raise TypeError("Workflow must be of type Workflow.")
|
|
218
|
+
|
|
195
219
|
self._workflow = workflow
|
|
196
220
|
return self
|
|
197
221
|
|
|
@@ -205,39 +229,41 @@ class RapidataOrderBuilder:
|
|
|
205
229
|
Returns:
|
|
206
230
|
RapidataOrderBuilder: The updated RapidataOrderBuilder instance.
|
|
207
231
|
"""
|
|
232
|
+
if not isinstance(referee, Referee):
|
|
233
|
+
raise TypeError("Referee must be of type Referee.")
|
|
234
|
+
|
|
208
235
|
self._referee = referee
|
|
209
236
|
return self
|
|
210
237
|
|
|
211
238
|
def media(
|
|
212
239
|
self,
|
|
213
|
-
|
|
214
|
-
metadata:
|
|
240
|
+
asset: list[MediaAsset] | list[TextAsset] | list[MultiAsset],
|
|
241
|
+
metadata: Sequence[Metadata] | None = None,
|
|
215
242
|
) -> "RapidataOrderBuilder":
|
|
216
243
|
"""
|
|
217
244
|
Set the media assets for the order.
|
|
218
245
|
|
|
219
246
|
Args:
|
|
220
|
-
media_paths (list[
|
|
247
|
+
media_paths (list[MediaAsset] | list[TextAsset] | list[MultiAsset]): The paths of the media assets to be set.
|
|
221
248
|
metadata (list[Metadata] | None, optional): Metadata for the media assets. Defaults to None.
|
|
222
249
|
|
|
223
250
|
Returns:
|
|
224
251
|
RapidataOrderBuilder: The updated RapidataOrderBuilder instance.
|
|
225
252
|
"""
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
self._texts = texts
|
|
253
|
+
if not isinstance(asset, list):
|
|
254
|
+
raise TypeError("Media paths must be provided as a list of paths.")
|
|
255
|
+
|
|
256
|
+
for a in asset:
|
|
257
|
+
if not isinstance(a, (MediaAsset, TextAsset, MultiAsset)):
|
|
258
|
+
raise TypeError("Media paths must be of type MediaAsset, TextAsset, or MultiAsset.")
|
|
259
|
+
|
|
260
|
+
if metadata:
|
|
261
|
+
for data in metadata:
|
|
262
|
+
if not isinstance(data, Metadata):
|
|
263
|
+
raise TypeError("Metadata must be of type Metadata.")
|
|
264
|
+
|
|
265
|
+
self._assets = asset
|
|
266
|
+
self._metadata = metadata # type: ignore
|
|
241
267
|
return self
|
|
242
268
|
|
|
243
269
|
def feature_flags(self, feature_flags: FeatureFlags) -> "RapidataOrderBuilder":
|
|
@@ -250,6 +276,9 @@ class RapidataOrderBuilder:
|
|
|
250
276
|
Returns:
|
|
251
277
|
RapidataOrderBuilder: The updated RapidataOrderBuilder instance.
|
|
252
278
|
"""
|
|
279
|
+
if not isinstance(feature_flags, FeatureFlags):
|
|
280
|
+
raise TypeError("Feature flags must be of type FeatureFlags.")
|
|
281
|
+
|
|
253
282
|
self._feature_flags = feature_flags
|
|
254
283
|
return self
|
|
255
284
|
|
|
@@ -263,6 +292,13 @@ class RapidataOrderBuilder:
|
|
|
263
292
|
Returns:
|
|
264
293
|
RapidataOrderBuilder: The updated RapidataOrderBuilder instance.
|
|
265
294
|
"""
|
|
295
|
+
if not isinstance(country_codes, list):
|
|
296
|
+
raise TypeError("Country codes must be provided as a list of strings.")
|
|
297
|
+
|
|
298
|
+
for code in country_codes:
|
|
299
|
+
if not isinstance(code, str):
|
|
300
|
+
raise TypeError("Country codes must be of type str.")
|
|
301
|
+
|
|
266
302
|
self._country_codes = country_codes
|
|
267
303
|
return self
|
|
268
304
|
|
|
@@ -276,6 +312,12 @@ class RapidataOrderBuilder:
|
|
|
276
312
|
Returns:
|
|
277
313
|
RapidataOrderBuilder: The updated RapidataOrderBuilder instance.
|
|
278
314
|
"""
|
|
315
|
+
if not isinstance(language_codes, list):
|
|
316
|
+
raise TypeError("Language codes must be provided as a list of strings.")
|
|
317
|
+
|
|
318
|
+
if not all(isinstance(code, str) for code in language_codes):
|
|
319
|
+
raise TypeError("Language codes must be of type str.")
|
|
320
|
+
|
|
279
321
|
self._language_codes = language_codes
|
|
280
322
|
return self
|
|
281
323
|
|
|
@@ -289,6 +331,9 @@ class RapidataOrderBuilder:
|
|
|
289
331
|
Returns:
|
|
290
332
|
RapidataOrderBuilder: The updated RapidataOrderBuilder instance.
|
|
291
333
|
"""
|
|
334
|
+
if not isinstance(aggregator, AggregatorType):
|
|
335
|
+
raise TypeError("Aggregator must be of type AggregatorType.")
|
|
336
|
+
|
|
292
337
|
self._aggregator = aggregator
|
|
293
338
|
return self
|
|
294
339
|
|
|
@@ -302,6 +347,9 @@ class RapidataOrderBuilder:
|
|
|
302
347
|
Returns:
|
|
303
348
|
RapidataOrderBuilder: The updated RapidataOrderBuilder instance.
|
|
304
349
|
"""
|
|
350
|
+
if not isinstance(validation_set_id, str):
|
|
351
|
+
raise TypeError("Validation set ID must be of type str.")
|
|
352
|
+
|
|
305
353
|
self._validation_set_id = validation_set_id
|
|
306
354
|
return self
|
|
307
355
|
|
|
@@ -320,17 +368,24 @@ class RapidataOrderBuilder:
|
|
|
320
368
|
"""
|
|
321
369
|
raise NotImplementedError("Not implemented yet.")
|
|
322
370
|
|
|
323
|
-
def selections(self, selections:
|
|
371
|
+
def selections(self, selections: Sequence[Selection]) -> "RapidataOrderBuilder":
|
|
324
372
|
"""
|
|
325
373
|
Set the selections for the order.
|
|
326
374
|
|
|
327
375
|
Args:
|
|
328
|
-
selections (
|
|
376
|
+
selections (Sequence[Selection]): The selections to be set.
|
|
329
377
|
|
|
330
378
|
Returns:
|
|
331
379
|
RapidataOrderBuilder: The updated RapidataOrderBuilder instance.
|
|
332
380
|
"""
|
|
333
|
-
|
|
381
|
+
if not isinstance(selections, list):
|
|
382
|
+
raise TypeError("Selections must be provided as a list of Selection objects.")
|
|
383
|
+
|
|
384
|
+
for selection in selections:
|
|
385
|
+
if not isinstance(selection, Selection):
|
|
386
|
+
raise TypeError("Selections must be of type Selection.")
|
|
387
|
+
|
|
388
|
+
self._selections = selections # type: ignore
|
|
334
389
|
return self
|
|
335
390
|
|
|
336
391
|
def priority(self, priority: int) -> "RapidataOrderBuilder":
|
|
@@ -343,5 +398,8 @@ class RapidataOrderBuilder:
|
|
|
343
398
|
Returns:
|
|
344
399
|
RapidataOrderBuilder: The updated RapidataOrderBuilder instance.
|
|
345
400
|
"""
|
|
401
|
+
if not isinstance(priority, int):
|
|
402
|
+
raise TypeError("Priority must be of type int.")
|
|
403
|
+
|
|
346
404
|
self._priority = priority
|
|
347
405
|
return self
|
|
@@ -3,3 +3,4 @@ from .demographic_selection import DemographicSelection
|
|
|
3
3
|
from .labeling_selection import LabelingSelection
|
|
4
4
|
from .validation_selection import ValidationSelection
|
|
5
5
|
from .conditional_validation_selection import ConditionalValidationSelection
|
|
6
|
+
from .capped_selection import CappedSelection
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from rapidata.api_client.models.capped_selection import (
|
|
2
|
+
CappedSelection as CappedSelectionModel,
|
|
3
|
+
)
|
|
4
|
+
from rapidata.api_client.models.capped_selection_selections_inner import (
|
|
5
|
+
CappedSelectionSelectionsInner,
|
|
6
|
+
)
|
|
7
|
+
from rapidata.rapidata_client.selection.base_selection import Selection
|
|
8
|
+
from typing import Sequence
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CappedSelection(Selection):
|
|
12
|
+
|
|
13
|
+
def __init__(self, selections: Sequence[Selection], max_rapids: int):
|
|
14
|
+
self.selections = selections
|
|
15
|
+
self.max_rapids = max_rapids
|
|
16
|
+
|
|
17
|
+
def to_model(self):
|
|
18
|
+
return CappedSelectionModel(
|
|
19
|
+
_t="CappedSelection",
|
|
20
|
+
selections=[
|
|
21
|
+
CappedSelectionSelectionsInner(selection.to_model())
|
|
22
|
+
for selection in self.selections
|
|
23
|
+
],
|
|
24
|
+
max_rapids=self.max_rapids,
|
|
25
|
+
)
|
|
@@ -5,8 +5,9 @@ from rapidata.api_client.models.demographic_selection import DemographicSelectio
|
|
|
5
5
|
class DemographicSelection(Selection):
|
|
6
6
|
"""Demographic selection class."""
|
|
7
7
|
|
|
8
|
-
def __init__(self, keys: list[str]):
|
|
8
|
+
def __init__(self, keys: list[str], maxRapids: int):
|
|
9
9
|
self.keys = keys
|
|
10
|
+
self.maxRapids = maxRapids
|
|
10
11
|
|
|
11
12
|
def to_model(self):
|
|
12
|
-
return DemographicSelectionModel(_t="DemographicSelection", keys=self.keys)
|
|
13
|
+
return DemographicSelectionModel(_t="DemographicSelection", keys=self.keys, maxRapids=self.maxRapids)
|
|
File without changes
|
|
@@ -7,6 +7,8 @@ from rapidata.rapidata_client.workflow.classify_workflow import ClassifyWorkflow
|
|
|
7
7
|
from rapidata.rapidata_client.selection.validation_selection import ValidationSelection
|
|
8
8
|
from rapidata.rapidata_client.selection.labeling_selection import LabelingSelection
|
|
9
9
|
from rapidata.service.openapi_service import OpenAPIService
|
|
10
|
+
from rapidata.rapidata_client.assets import MediaAsset
|
|
11
|
+
from typing import Sequence
|
|
10
12
|
|
|
11
13
|
class ClassificationOrderBuilder:
|
|
12
14
|
def __init__(self, name: str, question: str, options: list[str], media_paths: list[str], openapi_service: OpenAPIService):
|
|
@@ -19,7 +21,7 @@ class ClassificationOrderBuilder:
|
|
|
19
21
|
self._metadata = None
|
|
20
22
|
self._validation_set_id = None
|
|
21
23
|
|
|
22
|
-
def metadata(self, metadata:
|
|
24
|
+
def metadata(self, metadata: Sequence[Metadata]):
|
|
23
25
|
"""Set the metadata for the classification order. Has to be the same lenght as the media paths."""
|
|
24
26
|
self._metadata = metadata
|
|
25
27
|
return self
|
|
@@ -28,27 +30,29 @@ class ClassificationOrderBuilder:
|
|
|
28
30
|
"""Set the number of responses required for the classification order."""
|
|
29
31
|
self._responses_required = responses_required
|
|
30
32
|
return self
|
|
31
|
-
|
|
33
|
+
|
|
32
34
|
def probability_threshold(self, probability_threshold: float):
|
|
33
35
|
"""Set the probability threshold for early stopping."""
|
|
34
36
|
self._probability_threshold = probability_threshold
|
|
35
37
|
return self
|
|
36
|
-
|
|
38
|
+
|
|
37
39
|
def validation_set_id(self, validation_set_id: str):
|
|
38
40
|
"""Set the validation set ID for the classification order."""
|
|
39
41
|
self._validation_set_id = validation_set_id
|
|
40
42
|
return self
|
|
41
|
-
|
|
43
|
+
|
|
42
44
|
def create(self, submit: bool = True, max_upload_workers: int = 10):
|
|
43
45
|
if self._probability_threshold and self._responses_required:
|
|
44
46
|
referee = ClassifyEarlyStoppingReferee(
|
|
45
47
|
max_vote_count=self._responses_required,
|
|
46
48
|
threshold=self._probability_threshold
|
|
47
49
|
)
|
|
48
|
-
|
|
50
|
+
|
|
49
51
|
else:
|
|
50
52
|
referee = NaiveReferee(required_guesses=self._responses_required)
|
|
51
|
-
|
|
53
|
+
|
|
54
|
+
assets = [MediaAsset(path=media_path) for media_path in self._media_paths]
|
|
55
|
+
|
|
52
56
|
selection: list[Selection] = ([ValidationSelection(amount=1, validation_set_id=self._validation_set_id), LabelingSelection(amount=2)]
|
|
53
57
|
if self._validation_set_id
|
|
54
58
|
else [LabelingSelection(amount=3)])
|
|
@@ -61,14 +65,15 @@ class ClassificationOrderBuilder:
|
|
|
61
65
|
)
|
|
62
66
|
)
|
|
63
67
|
.referee(referee)
|
|
64
|
-
.media(
|
|
68
|
+
.media(assets, metadata=self._metadata) # type: ignore
|
|
65
69
|
.selections(selection)
|
|
66
70
|
.create(submit=submit, max_workers=max_upload_workers))
|
|
67
71
|
|
|
68
72
|
return order
|
|
69
|
-
|
|
73
|
+
|
|
70
74
|
|
|
71
75
|
class ClassificationMediaBuilder:
|
|
76
|
+
"test"
|
|
72
77
|
def __init__(self, name: str, question: str, options: list[str], openapi_service: OpenAPIService):
|
|
73
78
|
self._openapi_service = openapi_service
|
|
74
79
|
self._name = name
|
|
@@ -85,7 +90,7 @@ class ClassificationMediaBuilder:
|
|
|
85
90
|
if self._media_paths is None:
|
|
86
91
|
raise ValueError("Media paths are required")
|
|
87
92
|
return ClassificationOrderBuilder(self._name, self._question, self._options, self._media_paths, openapi_service=self._openapi_service)
|
|
88
|
-
|
|
93
|
+
|
|
89
94
|
|
|
90
95
|
class ClassificationOptionsBuilder:
|
|
91
96
|
def __init__(self, name: str, question: str, openapi_service: OpenAPIService):
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
from rapidata.service.openapi_service import OpenAPIService
|
|
2
|
-
from rapidata.rapidata_client.metadata
|
|
2
|
+
from rapidata.rapidata_client.metadata import Metadata
|
|
3
3
|
from rapidata.rapidata_client.order.rapidata_order_builder import RapidataOrderBuilder
|
|
4
4
|
from rapidata.rapidata_client.workflow.compare_workflow import CompareWorkflow
|
|
5
5
|
from rapidata.rapidata_client.referee.naive_referee import NaiveReferee
|
|
6
6
|
from rapidata.rapidata_client.selection.validation_selection import ValidationSelection
|
|
7
7
|
from rapidata.rapidata_client.selection.labeling_selection import LabelingSelection
|
|
8
8
|
from rapidata.rapidata_client.selection.base_selection import Selection
|
|
9
|
+
from rapidata.rapidata_client.assets import MultiAsset, MediaAsset
|
|
10
|
+
from typing import Sequence
|
|
9
11
|
|
|
10
12
|
class CompareOrderBuilder:
|
|
11
13
|
def __init__(self, name:str, criteria: str, media_paths: list[list[str]], openapi_service: OpenAPIService):
|
|
@@ -22,7 +24,7 @@ class CompareOrderBuilder:
|
|
|
22
24
|
self._responses_required = responses_required
|
|
23
25
|
return self
|
|
24
26
|
|
|
25
|
-
def metadata(self, metadata:
|
|
27
|
+
def metadata(self, metadata: Sequence[Metadata]) -> 'CompareOrderBuilder':
|
|
26
28
|
"""Set the metadata for the comparison order. Has to be the same shape as the media paths."""
|
|
27
29
|
self._metadata = metadata
|
|
28
30
|
return self
|
|
@@ -37,6 +39,7 @@ class CompareOrderBuilder:
|
|
|
37
39
|
if self._validation_set_id
|
|
38
40
|
else [LabelingSelection(amount=3)])
|
|
39
41
|
|
|
42
|
+
media_paths = [MultiAsset([MediaAsset(path=path) for path in paths]) for paths in self._media_paths]
|
|
40
43
|
order = (self._order_builder
|
|
41
44
|
.workflow(
|
|
42
45
|
CompareWorkflow(
|
|
@@ -44,7 +47,7 @@ class CompareOrderBuilder:
|
|
|
44
47
|
)
|
|
45
48
|
)
|
|
46
49
|
.referee(NaiveReferee(required_guesses=self._responses_required))
|
|
47
|
-
.media(
|
|
50
|
+
.media(media_paths, metadata=self._metadata) # type: ignore
|
|
48
51
|
.selections(selection)
|
|
49
52
|
.create(submit=submit, max_workers=max_upload_workers))
|
|
50
53
|
|
|
@@ -5,6 +5,9 @@ from rapidata.api_client.api.rapid_api import RapidApi
|
|
|
5
5
|
from rapidata.api_client.api.validation_api import ValidationApi
|
|
6
6
|
from rapidata.api_client.api_client import ApiClient
|
|
7
7
|
from rapidata.api_client.configuration import Configuration
|
|
8
|
+
from rapidata.api_client.api.campaign_api import CampaignApi
|
|
9
|
+
from rapidata.api_client.api.pipeline_api import PipelineApi
|
|
10
|
+
from rapidata.api_client.api.workflow_api import WorkflowApi
|
|
8
11
|
|
|
9
12
|
|
|
10
13
|
class OpenAPIService:
|
|
@@ -45,3 +48,15 @@ class OpenAPIService:
|
|
|
45
48
|
@property
|
|
46
49
|
def rapid_api(self) -> RapidApi:
|
|
47
50
|
return RapidApi(self.api_client)
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def campaign_api(self) -> CampaignApi:
|
|
54
|
+
return CampaignApi(self.api_client)
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def pipeline_api(self) -> PipelineApi:
|
|
58
|
+
return PipelineApi(self.api_client)
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def workflow_api(self) -> WorkflowApi:
|
|
62
|
+
return WorkflowApi(self.api_client)
|