rapidata 1.10.1__py3-none-any.whl → 2.0.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 +21 -17
- rapidata/api_client/__init__.py +15 -5
- rapidata/api_client/api/coco_api.py +14 -29
- rapidata/api_client/api/dataset_api.py +6 -6
- rapidata/api_client/api/identity_api.py +3 -3
- rapidata/api_client/api/pipeline_api.py +1008 -95
- rapidata/api_client/api/rapid_api.py +6 -6
- rapidata/api_client/api/validation_api.py +12 -42
- rapidata/api_client/models/__init__.py +15 -5
- rapidata/api_client/models/add_campaign_model.py +1 -3
- rapidata/api_client/models/add_validation_text_rapid_model.py +1 -1
- rapidata/api_client/models/age_group.py +5 -4
- rapidata/api_client/models/base_error.py +1 -4
- rapidata/api_client/models/compare_workflow_config.py +9 -24
- rapidata/api_client/models/compare_workflow_config_model.py +9 -29
- rapidata/api_client/models/compare_workflow_config_model_pair_maker_config.py +140 -0
- rapidata/api_client/models/compare_workflow_config_pair_maker_config.py +140 -0
- rapidata/api_client/models/compare_workflow_model.py +7 -3
- rapidata/api_client/models/compare_workflow_model1.py +7 -3
- rapidata/api_client/models/compare_workflow_model1_pair_maker_information.py +140 -0
- rapidata/api_client/models/compare_workflow_model_pair_maker_config.py +140 -0
- rapidata/api_client/models/file_asset_model_metadata_inner.py +8 -22
- rapidata/api_client/models/get_classify_workflow_result_overview_result.py +144 -0
- rapidata/api_client/models/get_pipeline_by_id_result.py +13 -3
- rapidata/api_client/models/identity_read_bridge_token_get202_response.py +140 -0
- rapidata/api_client/models/not_available_yet_result.py +96 -0
- rapidata/api_client/models/online_pair_maker_config.py +98 -0
- rapidata/api_client/models/online_pair_maker_config_model.py +98 -0
- rapidata/api_client/models/online_pair_maker_information.py +100 -0
- rapidata/api_client/models/pipeline_id_workflow_put_request.py +140 -0
- rapidata/api_client/models/pre_arranged_pair_maker_config.py +100 -0
- rapidata/api_client/models/pre_arranged_pair_maker_config_model.py +96 -0
- rapidata/api_client/models/pre_arranged_pair_maker_information.py +102 -0
- rapidata/api_client/models/read_bridge_token_keys_result.py +11 -2
- rapidata/api_client/models/simple_workflow_config.py +7 -26
- rapidata/api_client/models/simple_workflow_config_model.py +4 -28
- rapidata/api_client/models/simple_workflow_get_result_overview_get200_response.py +16 -16
- rapidata/api_client/models/simple_workflow_model1.py +3 -3
- rapidata/api_client/models/update_campaign_model.py +99 -0
- rapidata/api_client/models/validation_import_post_request_blueprint.py +1 -1
- rapidata/api_client_README.md +20 -7
- rapidata/rapidata_client/__init__.py +18 -9
- rapidata/rapidata_client/assets/__init__.py +5 -4
- rapidata/rapidata_client/assets/{media_asset.py → _media_asset.py} +32 -11
- rapidata/rapidata_client/assets/{multi_asset.py → _multi_asset.py} +1 -1
- rapidata/rapidata_client/assets/{text_asset.py → _text_asset.py} +1 -1
- rapidata/rapidata_client/assets/data_type_enum.py +7 -0
- rapidata/rapidata_client/filter/__init__.py +1 -1
- rapidata/rapidata_client/filter/_base_filter.py +10 -0
- rapidata/rapidata_client/filter/age_filter.py +12 -5
- rapidata/rapidata_client/filter/campaign_filter.py +12 -3
- rapidata/rapidata_client/filter/country_filter.py +10 -3
- rapidata/rapidata_client/filter/gender_filter.py +12 -5
- rapidata/rapidata_client/filter/language_filter.py +14 -3
- rapidata/rapidata_client/filter/models/age_group.py +26 -0
- rapidata/rapidata_client/filter/models/gender.py +19 -0
- rapidata/rapidata_client/filter/rapidata_filters.py +31 -0
- rapidata/rapidata_client/filter/user_score_filter.py +20 -4
- rapidata/rapidata_client/metadata/__init__.py +5 -5
- rapidata/rapidata_client/metadata/{base_metadata.py → _base_metadata.py} +2 -1
- rapidata/rapidata_client/metadata/{private_text_metadata.py → _private_text_metadata.py} +2 -2
- rapidata/rapidata_client/metadata/{prompt_metadata.py → _prompt_metadata.py} +3 -2
- rapidata/rapidata_client/metadata/{public_text_metadata.py → _public_text_metadata.py} +2 -2
- rapidata/rapidata_client/metadata/{select_words_metadata.py → _select_words_metadata.py} +3 -2
- rapidata/rapidata_client/{dataset/rapidata_dataset.py → order/_rapidata_dataset.py} +7 -8
- rapidata/rapidata_client/order/_rapidata_order_builder.py +365 -0
- rapidata/rapidata_client/order/rapidata_order.py +49 -31
- rapidata/rapidata_client/order/rapidata_order_manager.py +461 -0
- rapidata/rapidata_client/rapidata_client.py +12 -201
- rapidata/rapidata_client/referee/__init__.py +3 -3
- rapidata/rapidata_client/referee/{base_referee.py → _base_referee.py} +3 -3
- rapidata/rapidata_client/referee/{early_stopping_referee.py → _early_stopping_referee.py} +14 -11
- rapidata/rapidata_client/referee/{naive_referee.py → _naive_referee.py} +9 -9
- rapidata/rapidata_client/selection/__init__.py +1 -1
- rapidata/rapidata_client/{filter/base_filter.py → selection/_base_selection.py} +2 -2
- rapidata/rapidata_client/selection/capped_selection.py +15 -5
- rapidata/rapidata_client/selection/conditional_validation_selection.py +17 -4
- rapidata/rapidata_client/selection/demographic_selection.py +18 -7
- rapidata/rapidata_client/selection/labeling_selection.py +10 -3
- rapidata/rapidata_client/selection/rapidata_selections.py +21 -0
- rapidata/rapidata_client/selection/validation_selection.py +11 -4
- rapidata/rapidata_client/settings/__init__.py +9 -2
- rapidata/rapidata_client/settings/_rapidata_setting.py +11 -0
- rapidata/rapidata_client/settings/alert_on_fast_response.py +21 -0
- rapidata/rapidata_client/settings/custom_setting.py +16 -0
- rapidata/rapidata_client/settings/free_text_minimum_characters.py +16 -0
- rapidata/rapidata_client/settings/models/__init__.py +1 -0
- rapidata/rapidata_client/settings/models/translation_behaviour_options.py +14 -0
- rapidata/rapidata_client/settings/no_shuffle.py +16 -0
- rapidata/rapidata_client/settings/play_video_until_the_end.py +16 -0
- rapidata/rapidata_client/settings/rapidata_settings.py +31 -0
- rapidata/rapidata_client/settings/translation_behaviour.py +18 -0
- rapidata/rapidata_client/validation/__init__.py +1 -0
- rapidata/rapidata_client/{dataset/validation_rapid_parts.py → validation/_validation_rapid_parts.py} +7 -6
- rapidata/rapidata_client/validation/_validation_set_builder.py +371 -0
- rapidata/rapidata_client/{dataset → validation}/rapidata_validation_set.py +54 -50
- rapidata/rapidata_client/validation/rapids/__init__.py +1 -0
- rapidata/rapidata_client/validation/rapids/box.py +17 -0
- rapidata/rapidata_client/validation/rapids/rapids.py +94 -0
- rapidata/rapidata_client/validation/rapids/rapids_manager.py +163 -0
- rapidata/rapidata_client/validation/validation_set_manager.py +335 -0
- rapidata/rapidata_client/workflow/__init__.py +8 -6
- rapidata/rapidata_client/workflow/_base_workflow.py +25 -0
- rapidata/rapidata_client/workflow/{classify_workflow.py → _classify_workflow.py} +6 -6
- rapidata/rapidata_client/workflow/{compare_workflow.py → _compare_workflow.py} +10 -16
- rapidata/rapidata_client/workflow/_draw_workflow.py +22 -0
- rapidata/rapidata_client/workflow/_evaluation_workflow.py +26 -0
- rapidata/rapidata_client/workflow/{free_text_workflow.py → _free_text_workflow.py} +10 -16
- rapidata/rapidata_client/workflow/_locate_workflow.py +22 -0
- rapidata/rapidata_client/workflow/{select_words_workflow.py → _select_words_workflow.py} +2 -8
- rapidata/service/credential_manager.py +11 -1
- rapidata/service/openapi_service.py +23 -4
- {rapidata-1.10.1.dist-info → rapidata-2.0.0.dist-info}/METADATA +2 -1
- {rapidata-1.10.1.dist-info → rapidata-2.0.0.dist-info}/RECORD +118 -94
- rapidata/constants.py +0 -1
- rapidata/rapidata_client/dataset/rapid_builders/__init__.py +0 -4
- rapidata/rapidata_client/dataset/rapid_builders/base_rapid_builder.py +0 -33
- rapidata/rapidata_client/dataset/rapid_builders/classify_rapid_builders.py +0 -166
- rapidata/rapidata_client/dataset/rapid_builders/compare_rapid_builders.py +0 -145
- rapidata/rapidata_client/dataset/rapid_builders/rapids.py +0 -33
- rapidata/rapidata_client/dataset/rapid_builders/select_words_rapid_builders.py +0 -124
- rapidata/rapidata_client/dataset/validation_set_builder.py +0 -336
- rapidata/rapidata_client/order/order_builder.py +0 -25
- rapidata/rapidata_client/order/rapidata_order_builder.py +0 -463
- rapidata/rapidata_client/selection/base_selection.py +0 -9
- rapidata/rapidata_client/settings/feature_flags.py +0 -125
- rapidata/rapidata_client/settings/settings.py +0 -124
- rapidata/rapidata_client/simple_builders/__init__.py +0 -0
- rapidata/rapidata_client/simple_builders/simple_classification_builders.py +0 -271
- rapidata/rapidata_client/simple_builders/simple_compare_builders.py +0 -267
- rapidata/rapidata_client/simple_builders/simple_free_text_builders.py +0 -192
- rapidata/rapidata_client/simple_builders/simple_select_words_builders.py +0 -196
- rapidata/rapidata_client/workflow/base_workflow.py +0 -42
- rapidata/rapidata_client/workflow/evaluation_workflow.py +0 -15
- /rapidata/rapidata_client/assets/{base_asset.py → _base_asset.py} +0 -0
- /rapidata/rapidata_client/{dataset → filter/models}/__init__.py +0 -0
- {rapidata-1.10.1.dist-info → rapidata-2.0.0.dist-info}/LICENSE +0 -0
- {rapidata-1.10.1.dist-info → rapidata-2.0.0.dist-info}/WHEEL +0 -0
|
@@ -1,31 +1,8 @@
|
|
|
1
|
-
from rapidata.rapidata_client.dataset.rapidata_validation_set import RapidataValidationSet
|
|
2
|
-
from rapidata.rapidata_client.dataset.validation_set_builder import ValidationSetBuilder
|
|
3
|
-
from rapidata.rapidata_client.order.rapidata_order_builder import RapidataOrderBuilder
|
|
4
1
|
from rapidata.service.openapi_service import OpenAPIService
|
|
5
|
-
from rapidata.rapidata_client.order.rapidata_order import RapidataOrder
|
|
6
|
-
from rapidata.rapidata_client.dataset.rapidata_dataset import RapidataDataset
|
|
7
2
|
|
|
8
|
-
from rapidata.rapidata_client.order.
|
|
3
|
+
from rapidata.rapidata_client.order.rapidata_order_manager import RapidataOrderManager
|
|
9
4
|
|
|
10
|
-
from rapidata.rapidata_client.
|
|
11
|
-
from rapidata.rapidata_client.simple_builders.simple_compare_builders import CompareCriteriaBuilder
|
|
12
|
-
from rapidata.rapidata_client.simple_builders.simple_free_text_builders import FreeTextQuestionBuilder
|
|
13
|
-
from rapidata.rapidata_client.simple_builders.simple_select_words_builders import SelectWordsInstructionBuilder
|
|
14
|
-
|
|
15
|
-
from rapidata.rapidata_client.dataset.rapid_builders import BaseRapidBuilder
|
|
16
|
-
|
|
17
|
-
from rapidata.api_client.exceptions import BadRequestException
|
|
18
|
-
from urllib3._collections import HTTPHeaderDict
|
|
19
|
-
|
|
20
|
-
from rapidata.api_client.models.query_model import QueryModel
|
|
21
|
-
from rapidata.api_client.models.page_info import PageInfo
|
|
22
|
-
from rapidata.api_client.models.root_filter import RootFilter
|
|
23
|
-
from rapidata.api_client.models.filter import Filter
|
|
24
|
-
from rapidata.api_client.models.sort_criterion import SortCriterion
|
|
25
|
-
|
|
26
|
-
from rapidata.api_client.models.query_validation_set_model import QueryValidationSetModel
|
|
27
|
-
|
|
28
|
-
from deprecated import deprecated
|
|
5
|
+
from rapidata.rapidata_client.validation.validation_set_manager import ValidationSetManager
|
|
29
6
|
|
|
30
7
|
|
|
31
8
|
class RapidataClient:
|
|
@@ -39,14 +16,19 @@ class RapidataClient:
|
|
|
39
16
|
oauth_scope: str = "openid",
|
|
40
17
|
cert_path: str | None = None,
|
|
41
18
|
):
|
|
42
|
-
"""Initialize the RapidataClient.
|
|
19
|
+
"""Initialize the RapidataClient. If both the client_id and client_secret are None, it will try using your credentials under "~/.config/rapidata/credentials.json".
|
|
20
|
+
If this is not successful, it will open a browser windown and ask you to log in, then save your new credentials in said json file.
|
|
43
21
|
|
|
44
22
|
Args:
|
|
45
23
|
client_id (str): The client ID for authentication.
|
|
46
24
|
client_secret (str): The client secret for authentication.
|
|
47
|
-
|
|
25
|
+
enviroment (str, optional): The API endpoint.
|
|
26
|
+
|
|
27
|
+
Attributes:
|
|
28
|
+
order (RapidataOrderManager): The RapidataOrderManager instance.
|
|
29
|
+
validation (ValidationSetManager): The ValidationSetManager instance.
|
|
48
30
|
"""
|
|
49
|
-
self.
|
|
31
|
+
self._openapi_service = OpenAPIService(
|
|
50
32
|
client_id=client_id,
|
|
51
33
|
client_secret=client_secret,
|
|
52
34
|
enviroment=enviroment,
|
|
@@ -54,177 +36,6 @@ class RapidataClient:
|
|
|
54
36
|
cert_path=cert_path
|
|
55
37
|
)
|
|
56
38
|
|
|
57
|
-
self.
|
|
58
|
-
|
|
59
|
-
self.order_builder = BaseOrderBuilder(openapi_service=self.openapi_service)
|
|
60
|
-
|
|
61
|
-
@deprecated("Use the order_builder instead.")
|
|
62
|
-
def new_order(self, name: str) -> RapidataOrderBuilder:
|
|
63
|
-
"""Create a new order using a RapidataOrderBuilder instance.
|
|
64
|
-
|
|
65
|
-
Args:
|
|
66
|
-
name (str): The name of the order.
|
|
67
|
-
|
|
68
|
-
Returns:
|
|
69
|
-
RapidataOrderBuilder: A RapidataOrderBuilder instance.
|
|
70
|
-
"""
|
|
71
|
-
return self.new_advanced_order(name)
|
|
72
|
-
|
|
73
|
-
@deprecated("Use the order_builder instead.")
|
|
74
|
-
def new_advanced_order(self, name: str) -> RapidataOrderBuilder:
|
|
75
|
-
"""Create a new order using a RapidataOrderBuilder instance.
|
|
76
|
-
This method is intended for creating orders with complex requirements that can not be fulfilled with the specific builders.
|
|
77
|
-
For any other order, it is recommended to use the specific builder methods.
|
|
78
|
-
example: create_classify_order, create_compare_order, create_free_text_order, create_select_words_order
|
|
79
|
-
|
|
80
|
-
Args:
|
|
81
|
-
name (str): The name of the order.
|
|
82
|
-
|
|
83
|
-
Returns:
|
|
84
|
-
RapidataOrderBuilder: A RapidataOrderBuilder instance.
|
|
85
|
-
"""
|
|
86
|
-
return RapidataOrderBuilder(name=name, openapi_service=self.openapi_service)
|
|
87
|
-
|
|
88
|
-
def new_validation_set(self, name: str) -> ValidationSetBuilder:
|
|
89
|
-
"""Create a new validation set using a ValidationDatasetBuilder instance.
|
|
90
|
-
|
|
91
|
-
Args:
|
|
92
|
-
name (str): The name of the validation set.
|
|
93
|
-
|
|
94
|
-
Returns:
|
|
95
|
-
ValidationSetBuilder: A ValidationDatasetBuilder instance.
|
|
96
|
-
"""
|
|
97
|
-
return ValidationSetBuilder(name=name, openapi_service=self.openapi_service)
|
|
98
|
-
|
|
99
|
-
def get_order(self, order_id: str) -> RapidataOrder:
|
|
100
|
-
"""Get an order by ID.
|
|
101
|
-
|
|
102
|
-
Args:
|
|
103
|
-
order_id (str): The ID of the order.
|
|
104
|
-
|
|
105
|
-
Returns:
|
|
106
|
-
RapidataOrder: The Order instance.
|
|
107
|
-
"""
|
|
108
|
-
|
|
109
|
-
# TODO: check the pipeline for the dataset id - not really necessary atm
|
|
110
|
-
# order = self.openapi_service.order_api.order_get_by_id_get(order_id)
|
|
111
|
-
# pipeline = self.openapi_service..pipeline_get_by_id_get(order.pipeline_id)
|
|
112
|
-
try:
|
|
113
|
-
order = self.openapi_service.order_api.order_get_by_id_get(order_id)
|
|
114
|
-
except Exception:
|
|
115
|
-
raise ValueError(f"Order with ID {order_id} not found.")
|
|
116
|
-
|
|
117
|
-
temp_dataset = RapidataDataset("temp", self.openapi_service)
|
|
118
|
-
return RapidataOrder(
|
|
119
|
-
dataset=temp_dataset,
|
|
120
|
-
order_id=order_id,
|
|
121
|
-
name=order.order_name,
|
|
122
|
-
openapi_service=self.openapi_service)
|
|
123
|
-
|
|
124
|
-
def find_orders(self, name: str = "", amount: int = 1) -> list[RapidataOrder]:
|
|
125
|
-
"""Find your recent orders given criteria. If nothing is provided, it will return the most recent order.
|
|
126
|
-
|
|
127
|
-
Args:
|
|
128
|
-
name (str, optional): The name of the order - matching order will contain the name. Defaults to "" for any order.
|
|
129
|
-
amount (int, optional): The amount of orders to return. Defaults to 1.
|
|
130
|
-
|
|
131
|
-
Returns:
|
|
132
|
-
list[RapidataOrder]: A list of RapidataOrder instances.
|
|
133
|
-
"""
|
|
134
|
-
try:
|
|
135
|
-
order_page_result = self.openapi_service.order_api.order_query_get(QueryModel(
|
|
136
|
-
page=PageInfo(index=1, size=amount),
|
|
137
|
-
filter=RootFilter(filters=[Filter(field="OrderName", operator="Contains", value=name)]),
|
|
138
|
-
sortCriteria=[SortCriterion(direction="Desc", propertyName="OrderDate")]
|
|
139
|
-
))
|
|
140
|
-
|
|
141
|
-
except BadRequestException as e:
|
|
142
|
-
raise ValueError(f"Error occured during request. \nError: {e.body} \nTraceid: {e.headers.get('X-Trace-Id') if isinstance(e.headers, HTTPHeaderDict) else 'Unknown'}")
|
|
143
|
-
|
|
144
|
-
except Exception as e:
|
|
145
|
-
raise ValueError(f"Unknown error occured: {e}")
|
|
146
|
-
|
|
147
|
-
orders = [self.get_order(order.id) for order in order_page_result.items]
|
|
148
|
-
return orders
|
|
149
|
-
|
|
150
|
-
def get_validation_set(self, validation_set_id: str) -> RapidataValidationSet:
|
|
151
|
-
"""Get a validation set by ID.
|
|
152
|
-
|
|
153
|
-
Args:
|
|
154
|
-
validation_set_id (str): The ID of the validation set.
|
|
155
|
-
|
|
156
|
-
Returns:
|
|
157
|
-
RapidataValidationSet: The ValidationSet instance.
|
|
158
|
-
"""
|
|
159
|
-
try:
|
|
160
|
-
validation_set = self.openapi_service.validation_api.validation_get_by_id_get(id=validation_set_id)
|
|
161
|
-
except Exception:
|
|
162
|
-
raise ValueError(f"ValidationSet with ID {validation_set_id} not found.")
|
|
39
|
+
self.order = RapidataOrderManager(openapi_service=self._openapi_service)
|
|
163
40
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
def find_validation_sets(self, name: str = "", amount: int = 1) -> list[RapidataValidationSet]:
|
|
167
|
-
try:
|
|
168
|
-
validation_page_result = self.openapi_service.validation_api.validation_query_validation_sets_get(QueryValidationSetModel(
|
|
169
|
-
pageInfo=PageInfo(index=1, size=amount),
|
|
170
|
-
filter=RootFilter(filters=[Filter(field="Name", operator="Contains", value=name)]),
|
|
171
|
-
sortCriteria=[SortCriterion(direction="Desc", propertyName="CreatedAt")]
|
|
172
|
-
))
|
|
173
|
-
|
|
174
|
-
except BadRequestException as e:
|
|
175
|
-
raise ValueError(f"Error occured during request. \nError: {e.body} \nTraceid: {e.headers.get('X-Trace-Id') if isinstance(e.headers, HTTPHeaderDict) else 'Unknown'}")
|
|
176
|
-
|
|
177
|
-
except Exception as e:
|
|
178
|
-
raise ValueError(f"Unknown error occured: {e}")
|
|
179
|
-
|
|
180
|
-
orders = [self.get_validation_set(validation_set.id) for validation_set in validation_page_result.items] # type: ignore # will be fixed with the next backend deployment
|
|
181
|
-
return orders
|
|
182
|
-
|
|
183
|
-
@deprecated("Use the order_builder instead.")
|
|
184
|
-
def create_classify_order(self, name: str) -> ClassificationQuestionBuilder:
|
|
185
|
-
"""Create a new classification order where people are asked to classify an image.
|
|
186
|
-
|
|
187
|
-
Args:
|
|
188
|
-
name (str): The name of the order.
|
|
189
|
-
|
|
190
|
-
Returns:
|
|
191
|
-
ClassificationQuestionBuilder: A ClassificationQuestionBuilder instance.
|
|
192
|
-
"""
|
|
193
|
-
return ClassificationQuestionBuilder(name=name, openapi_service=self.openapi_service)
|
|
194
|
-
|
|
195
|
-
@deprecated("Use the order_builder instead.")
|
|
196
|
-
def create_compare_order(self, name: str) -> CompareCriteriaBuilder:
|
|
197
|
-
"""Create a new comparison order where people are asked to compare two images.
|
|
198
|
-
|
|
199
|
-
Args:
|
|
200
|
-
name (str): The name of the order.
|
|
201
|
-
|
|
202
|
-
Returns:
|
|
203
|
-
CompareQuestionBuilder: A CompareQuestionBuilder instance.
|
|
204
|
-
"""
|
|
205
|
-
return CompareCriteriaBuilder(name=name, openapi_service=self.openapi_service)
|
|
206
|
-
|
|
207
|
-
@deprecated("Use the order_builder instead.")
|
|
208
|
-
def create_free_text_order(self, name: str) -> FreeTextQuestionBuilder:
|
|
209
|
-
"""Create a new free text order where people are asked to provide a free text answer.
|
|
210
|
-
|
|
211
|
-
Args:
|
|
212
|
-
name (str): The name of the order.
|
|
213
|
-
|
|
214
|
-
Returns:
|
|
215
|
-
FreeTextQuestionBuilder: A FreeTextQuestionBuilder instance.
|
|
216
|
-
"""
|
|
217
|
-
return FreeTextQuestionBuilder(name=name, openapi_service=self.openapi_service)
|
|
218
|
-
|
|
219
|
-
@deprecated("Use the order_builder instead.")
|
|
220
|
-
def create_select_words_order(self, name: str) -> SelectWordsInstructionBuilder:
|
|
221
|
-
"""Create a new select words order where people are asked to transcribe an audio file.
|
|
222
|
-
|
|
223
|
-
Args:
|
|
224
|
-
name (str): The name of the order.
|
|
225
|
-
|
|
226
|
-
Returns:
|
|
227
|
-
SelectWordsInstructionBuilder: A SelectWordsInstructionBuilder instance.
|
|
228
|
-
"""
|
|
229
|
-
return SelectWordsInstructionBuilder(name=name, openapi_service=self.openapi_service)
|
|
230
|
-
|
|
41
|
+
self.validation = ValidationSetManager(openapi_service=self._openapi_service)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
from .
|
|
2
|
-
from .
|
|
3
|
-
from .
|
|
1
|
+
from ._base_referee import Referee
|
|
2
|
+
from ._naive_referee import NaiveReferee #as MaxVoteReferee
|
|
3
|
+
from ._early_stopping_referee import EarlyStoppingReferee
|
|
@@ -6,15 +6,15 @@ class Referee(ABC):
|
|
|
6
6
|
The referee defines when a rapid is considered complete.
|
|
7
7
|
"""
|
|
8
8
|
@abstractmethod
|
|
9
|
-
def
|
|
9
|
+
def _to_dict(self) -> Mapping[str, str | int | float]:
|
|
10
10
|
"""
|
|
11
11
|
Convert the referee to a referee configuration dict.
|
|
12
12
|
"""
|
|
13
13
|
pass
|
|
14
14
|
|
|
15
15
|
@abstractmethod
|
|
16
|
-
def
|
|
16
|
+
def _to_model(self) -> Any:
|
|
17
17
|
"""
|
|
18
18
|
Convert the referee to a referee configuration model.
|
|
19
19
|
"""
|
|
20
|
-
pass
|
|
20
|
+
pass
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from typing import Any
|
|
2
|
-
from rapidata.rapidata_client.referee.
|
|
2
|
+
from rapidata.rapidata_client.referee._base_referee import Referee
|
|
3
3
|
from rapidata.api_client.models.early_stopping_referee_model import (
|
|
4
4
|
EarlyStoppingRefereeModel,
|
|
5
5
|
)
|
|
@@ -18,31 +18,34 @@ class EarlyStoppingReferee(Referee):
|
|
|
18
18
|
This referee is supported for the classification and compare tasks (in compare,
|
|
19
19
|
the two options are treated as the categories).
|
|
20
20
|
|
|
21
|
+
Args:
|
|
22
|
+
threshold (float, optional): The confidence threshold for early stopping.
|
|
23
|
+
Defaults to 0.999.
|
|
24
|
+
max_vote_count (int, optional): The maximum number of votes allowed
|
|
25
|
+
before stopping. Defaults to 100.
|
|
26
|
+
|
|
21
27
|
Attributes:
|
|
22
28
|
threshold (float): The confidence threshold for early stopping.
|
|
23
29
|
max_vote_count (int): The maximum number of votes allowed before stopping.
|
|
24
30
|
"""
|
|
25
31
|
|
|
26
32
|
def __init__(self, threshold: float = 0.999, max_vote_count: int = 100):
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
max_vote_count (int, optional): The maximum number of votes allowed
|
|
33
|
-
before stopping. Defaults to 100.
|
|
34
|
-
"""
|
|
33
|
+
if threshold <= 0 or threshold >= 1:
|
|
34
|
+
raise ValueError("The threshold must be between 0 and 1.")
|
|
35
|
+
if max_vote_count < 1:
|
|
36
|
+
raise ValueError("The number of responses must be greater than 0.")
|
|
37
|
+
|
|
35
38
|
self.threshold = threshold
|
|
36
39
|
self.max_vote_count = max_vote_count
|
|
37
40
|
|
|
38
|
-
def
|
|
41
|
+
def _to_dict(self):
|
|
39
42
|
return {
|
|
40
43
|
"_t": "ProbabilisticAttachCategoryRefereeConfig",
|
|
41
44
|
"threshold": self.threshold,
|
|
42
45
|
"maxVotes": self.max_vote_count,
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
def
|
|
48
|
+
def _to_model(self) -> Any:
|
|
46
49
|
return EarlyStoppingRefereeModel(
|
|
47
50
|
_t="EarlyStoppingReferee",
|
|
48
51
|
threshold=self.threshold,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from rapidata.api_client.models.naive_referee_model import NaiveRefereeModel
|
|
2
|
-
from rapidata.rapidata_client.referee.
|
|
2
|
+
from rapidata.rapidata_client.referee._base_referee import Referee
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class NaiveReferee(Referee):
|
|
@@ -9,25 +9,25 @@ class NaiveReferee(Referee):
|
|
|
9
9
|
where the task is considered finished after a predetermined number of
|
|
10
10
|
responses have been made, regardless of the content or quality of those responses.
|
|
11
11
|
|
|
12
|
+
Args:
|
|
13
|
+
responses (int, optional): The number of responses required
|
|
14
|
+
to complete the task. Defaults to 10. This is per media item.
|
|
15
|
+
|
|
12
16
|
Attributes:
|
|
13
17
|
responses (int): The number of responses required to complete the task.
|
|
14
18
|
"""
|
|
15
19
|
|
|
16
20
|
def __init__(self, responses: int = 10):
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Args:
|
|
20
|
-
responses (int, optional): The number of responses required
|
|
21
|
-
to complete the task. Defaults to 10. This is per media item.
|
|
22
|
-
"""
|
|
21
|
+
if responses < 1:
|
|
22
|
+
raise ValueError("The number of responses must be greater than 0.")
|
|
23
23
|
super().__init__()
|
|
24
24
|
self.responses = responses
|
|
25
25
|
|
|
26
|
-
def
|
|
26
|
+
def _to_dict(self):
|
|
27
27
|
return {
|
|
28
28
|
"_t": "NaiveRefereeConfig",
|
|
29
29
|
"guessesRequired": self.responses,
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
def
|
|
32
|
+
def _to_model(self):
|
|
33
33
|
return NaiveRefereeModel(_t="NaiveReferee", totalVotes=self.responses)
|
|
@@ -4,21 +4,31 @@ from rapidata.api_client.models.capped_selection import (
|
|
|
4
4
|
from rapidata.api_client.models.capped_selection_selections_inner import (
|
|
5
5
|
CappedSelectionSelectionsInner,
|
|
6
6
|
)
|
|
7
|
-
from rapidata.rapidata_client.selection.
|
|
7
|
+
from rapidata.rapidata_client.selection._base_selection import RapidataSelection
|
|
8
8
|
from typing import Sequence
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
class CappedSelection(
|
|
11
|
+
class CappedSelection(RapidataSelection):
|
|
12
|
+
"""CappedSelection Class
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
Takes in different selections and caps the amount of rapids that can be shown.
|
|
15
|
+
|
|
16
|
+
Useful for demographic and conditional validation selections.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
selections (Sequence[RapidataSelection]): List of selections to cap.
|
|
20
|
+
max_rapids (int): The maximum amount of rapids that can be shown for this selection.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(self, selections: Sequence[RapidataSelection], max_rapids: int):
|
|
14
24
|
self.selections = selections
|
|
15
25
|
self.max_rapids = max_rapids
|
|
16
26
|
|
|
17
|
-
def
|
|
27
|
+
def _to_model(self):
|
|
18
28
|
return CappedSelectionModel(
|
|
19
29
|
_t="CappedSelection",
|
|
20
30
|
selections=[
|
|
21
|
-
CappedSelectionSelectionsInner(selection.
|
|
31
|
+
CappedSelectionSelectionsInner(selection._to_model())
|
|
22
32
|
for selection in self.selections
|
|
23
33
|
],
|
|
24
34
|
maxRapids=self.max_rapids,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from rapidata.rapidata_client.selection.
|
|
1
|
+
from rapidata.rapidata_client.selection._base_selection import RapidataSelection
|
|
2
2
|
from rapidata.api_client.models.conditional_validation_rapid_selection_config import (
|
|
3
3
|
ValidationChance,
|
|
4
4
|
)
|
|
@@ -7,8 +7,17 @@ from rapidata.api_client.models.conditional_validation_selection import (
|
|
|
7
7
|
)
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
class ConditionalValidationSelection(
|
|
11
|
-
"""
|
|
10
|
+
class ConditionalValidationSelection(RapidataSelection):
|
|
11
|
+
"""Conditional validation selection class.
|
|
12
|
+
|
|
13
|
+
Probabilistically decides how many validation rapids you want to show per session based on the user score.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
validation_set_id (str): The id of the validation set to be used.
|
|
17
|
+
thresholds (list[float]): The thresholds to use for the user score.
|
|
18
|
+
chances (list[float]): The chances of showing a validation rapid for each threshold.
|
|
19
|
+
rapid_counts (list[int]): The amount of validation rapids that will be shown per session of this validation set for each threshold if selected by probability. (all or nothing)
|
|
20
|
+
"""
|
|
12
21
|
|
|
13
22
|
def __init__(
|
|
14
23
|
self,
|
|
@@ -17,12 +26,16 @@ class ConditionalValidationSelection(Selection):
|
|
|
17
26
|
chances: list[float],
|
|
18
27
|
rapid_counts: list[int],
|
|
19
28
|
):
|
|
29
|
+
if len(thresholds) != len(chances) or len(thresholds) != len(rapid_counts):
|
|
30
|
+
raise ValueError(
|
|
31
|
+
"The lengths of thresholds, chances and rapid_counts must be equal."
|
|
32
|
+
)
|
|
20
33
|
self.validation_set_id = validation_set_id
|
|
21
34
|
self.thresholds = thresholds
|
|
22
35
|
self.chances = chances
|
|
23
36
|
self.rapid_counts = rapid_counts
|
|
24
37
|
|
|
25
|
-
def
|
|
38
|
+
def _to_model(self):
|
|
26
39
|
return ConditionalValidationSelectionModel(
|
|
27
40
|
_t="ConditionalValidationSelection",
|
|
28
41
|
validationSetId=self.validation_set_id,
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
from rapidata.rapidata_client.selection.
|
|
1
|
+
from rapidata.rapidata_client.selection._base_selection import RapidataSelection
|
|
2
2
|
from rapidata.api_client.models.demographic_selection import DemographicSelection as DemographicSelectionModel
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class DemographicSelection(
|
|
6
|
-
"""Demographic selection class.
|
|
5
|
+
class DemographicSelection(RapidataSelection):
|
|
6
|
+
"""Demographic selection class.
|
|
7
|
+
|
|
8
|
+
This is used to ask demographic questions in an order.
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
The keys will select the rapids based on the confidence we already saved for each user.
|
|
11
|
+
|
|
12
|
+
If the confidence is high, the users will be selected to solve the rapids with lower probability.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
keys (list[str]): List of keys for the demographic rapids to be shown. As an example: "age"
|
|
16
|
+
max_rapids (int): The maximum number of rapids to run.\n
|
|
17
|
+
Allows to provide more keys, in case some of the earlier ones are not selected because of high confidence."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, keys: list[str], max_rapids: int):
|
|
9
20
|
self.keys = keys
|
|
10
|
-
self.
|
|
21
|
+
self.max_rapids = max_rapids
|
|
11
22
|
|
|
12
|
-
def
|
|
13
|
-
return DemographicSelectionModel(_t="DemographicSelection", keys=self.keys, maxRapids=self.
|
|
23
|
+
def _to_model(self):
|
|
24
|
+
return DemographicSelectionModel(_t="DemographicSelection", keys=self.keys, maxRapids=self.max_rapids)
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
from typing import Any
|
|
2
|
-
from rapidata.rapidata_client.selection.
|
|
2
|
+
from rapidata.rapidata_client.selection._base_selection import RapidataSelection
|
|
3
3
|
from rapidata.api_client.models.labeling_selection import (
|
|
4
4
|
LabelingSelection as LabelingSelectionModel,
|
|
5
5
|
)
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
class LabelingSelection(
|
|
8
|
+
class LabelingSelection(RapidataSelection):
|
|
9
|
+
"""Labeling selection class.
|
|
10
|
+
|
|
11
|
+
Decides how many actual datapoints you want to show per session.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
amount (int): The amount of labeling rapids that will be shown per session.
|
|
15
|
+
"""
|
|
9
16
|
|
|
10
17
|
def __init__(self, amount: int):
|
|
11
18
|
self.amount = amount
|
|
12
19
|
|
|
13
|
-
def
|
|
20
|
+
def _to_model(self) -> Any:
|
|
14
21
|
return LabelingSelectionModel(_t="LabelingSelection", amount=self.amount)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from rapidata.rapidata_client.selection import (
|
|
2
|
+
DemographicSelection,
|
|
3
|
+
LabelingSelection,
|
|
4
|
+
ValidationSelection,
|
|
5
|
+
ConditionalValidationSelection,
|
|
6
|
+
CappedSelection)
|
|
7
|
+
|
|
8
|
+
class RapidataSelections:
|
|
9
|
+
"""RapidataSelections Classes
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
demographic (DemographicSelection): The DemographicSelection instance.
|
|
13
|
+
labeling (LabelingSelection): The LabelingSelection instance.
|
|
14
|
+
validation (ValidationSelection): The ValidationSelection instance.
|
|
15
|
+
conditional_validation (ConditionalValidationSelection): The ConditionalValidationSelection instance.
|
|
16
|
+
capped (CappedSelection): The CappedSelection instance."""
|
|
17
|
+
demographic = DemographicSelection
|
|
18
|
+
labeling = LabelingSelection
|
|
19
|
+
validation = ValidationSelection
|
|
20
|
+
conditional_validation = ConditionalValidationSelection
|
|
21
|
+
capped = CappedSelection
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
|
|
2
2
|
from rapidata.api_client.models.validation_selection import ValidationSelection as ValidationSelectionModel
|
|
3
|
-
from rapidata.rapidata_client.selection.
|
|
3
|
+
from rapidata.rapidata_client.selection._base_selection import RapidataSelection
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
class ValidationSelection(
|
|
6
|
+
class ValidationSelection(RapidataSelection):
|
|
7
|
+
"""Validation selection class.
|
|
8
|
+
|
|
9
|
+
Decides how many validation rapids you want to show per session.
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
validation_set_id (str): The id of the validation set to be used.
|
|
13
|
+
amount (int): The amount of validation rapids that will be shown per session of this validation set.
|
|
14
|
+
"""
|
|
7
15
|
|
|
8
16
|
def __init__(self, validation_set_id: str, amount: int = 1):
|
|
9
17
|
self.validation_set_id = validation_set_id
|
|
10
18
|
self.amount = amount
|
|
11
19
|
|
|
12
|
-
|
|
13
|
-
def to_model(self):
|
|
20
|
+
def _to_model(self):
|
|
14
21
|
return ValidationSelectionModel(_t="ValidationSelection", validationSetId=self.validation_set_id, amount=self.amount)
|
|
15
22
|
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
from .
|
|
2
|
-
from .
|
|
1
|
+
from .models import TranslationBehaviourOptions
|
|
2
|
+
from .alert_on_fast_response import AlertOnFastResponse
|
|
3
|
+
from .translation_behaviour import TranslationBehaviour
|
|
4
|
+
from .free_text_minimum_characters import FreeTextMinimumCharacters
|
|
5
|
+
from .no_shuffle import NoShuffle
|
|
6
|
+
from .play_video_until_the_end import PlayVideoUntilTheEnd
|
|
7
|
+
from .custom_setting import CustomSetting
|
|
8
|
+
from .rapidata_settings import RapidataSettings
|
|
9
|
+
from ._rapidata_setting import RapidataSetting
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
from typing import Any
|
|
3
|
+
from rapidata.api_client.models.feature_flag_model import FeatureFlagModel
|
|
4
|
+
|
|
5
|
+
class RapidataSetting(BaseModel):
|
|
6
|
+
"""Base class for all settings"""
|
|
7
|
+
key: str
|
|
8
|
+
value: Any
|
|
9
|
+
|
|
10
|
+
def _to_feature_flag(self) -> FeatureFlagModel:
|
|
11
|
+
return FeatureFlagModel(key=self.key, value=str(self.value))
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
|
|
2
|
+
|
|
3
|
+
class AlertOnFastResponse(RapidataSetting):
|
|
4
|
+
"""
|
|
5
|
+
Gives an alert as a pop up on the UI when the response time is less than the milliseconds.
|
|
6
|
+
|
|
7
|
+
Args:
|
|
8
|
+
threshold (int): if the user responds in less than this time, an alert will be shown.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def __init__(self, threshold: int):
|
|
12
|
+
if not isinstance(threshold, int):
|
|
13
|
+
raise ValueError("The alert must be an integer.")
|
|
14
|
+
if threshold < 10:
|
|
15
|
+
print(f"Warning: Are you sure you want to set the threshold so low ({threshold} milliseconds)?")
|
|
16
|
+
if threshold > 25000:
|
|
17
|
+
raise ValueError("The alert must be less than 25000 milliseconds.")
|
|
18
|
+
if threshold < 0:
|
|
19
|
+
raise ValueError("The alert must be greater than or equal to 0.")
|
|
20
|
+
|
|
21
|
+
super().__init__(key="alert_on_fast_response", value=threshold)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
|
|
2
|
+
|
|
3
|
+
class CustomSetting(RapidataSetting):
|
|
4
|
+
"""
|
|
5
|
+
Set a custom setting with the given key and value. Use this to enable features that do not have a dedicated method (yet)
|
|
6
|
+
|
|
7
|
+
Args:
|
|
8
|
+
key (str): The key for the custom setting.
|
|
9
|
+
value (str): The value for the custom setting.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(self, key: str, value: str):
|
|
13
|
+
if not isinstance(key, str):
|
|
14
|
+
raise ValueError("The key must be a string.")
|
|
15
|
+
|
|
16
|
+
super().__init__(key=key, value=value)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
|
|
2
|
+
|
|
3
|
+
class FreeTextMinimumCharacters(RapidataSetting):
|
|
4
|
+
"""
|
|
5
|
+
Set the minimum number of characters a user has to type.
|
|
6
|
+
|
|
7
|
+
Args:
|
|
8
|
+
value (int): The minimum number of characters for free text.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def __init__(self, value: int):
|
|
12
|
+
if value < 1:
|
|
13
|
+
raise ValueError("The minimum number of characters must be greater than or equal to 1.")
|
|
14
|
+
if value > 40:
|
|
15
|
+
print(f"Warning: Are you sure you want to set the minimum number of characters at {value}?")
|
|
16
|
+
super().__init__(key="free_text_minimum_characters", value=value)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .translation_behaviour_options import TranslationBehaviourOptions
|