rapidata 1.10.1__py3-none-any.whl → 2.1.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.

Files changed (142) hide show
  1. rapidata/__init__.py +22 -17
  2. rapidata/api_client/__init__.py +16 -5
  3. rapidata/api_client/api/coco_api.py +14 -29
  4. rapidata/api_client/api/dataset_api.py +6 -6
  5. rapidata/api_client/api/identity_api.py +3 -3
  6. rapidata/api_client/api/pipeline_api.py +1008 -95
  7. rapidata/api_client/api/rapid_api.py +6 -6
  8. rapidata/api_client/api/validation_api.py +12 -42
  9. rapidata/api_client/models/__init__.py +16 -5
  10. rapidata/api_client/models/add_campaign_model.py +5 -5
  11. rapidata/api_client/models/add_validation_text_rapid_model.py +1 -1
  12. rapidata/api_client/models/age_group.py +5 -4
  13. rapidata/api_client/models/base_error.py +1 -4
  14. rapidata/api_client/models/compare_workflow_config.py +9 -24
  15. rapidata/api_client/models/compare_workflow_config_model.py +9 -29
  16. rapidata/api_client/models/compare_workflow_config_model_pair_maker_config.py +140 -0
  17. rapidata/api_client/models/compare_workflow_config_pair_maker_config.py +140 -0
  18. rapidata/api_client/models/compare_workflow_model.py +7 -3
  19. rapidata/api_client/models/compare_workflow_model1.py +7 -3
  20. rapidata/api_client/models/compare_workflow_model1_pair_maker_information.py +140 -0
  21. rapidata/api_client/models/compare_workflow_model_pair_maker_config.py +140 -0
  22. rapidata/api_client/models/create_order_model.py +4 -2
  23. rapidata/api_client/models/create_order_model_user_filters_inner.py +25 -11
  24. rapidata/api_client/models/custom_user_filter_model.py +98 -0
  25. rapidata/api_client/models/file_asset_model_metadata_inner.py +8 -22
  26. rapidata/api_client/models/get_classify_workflow_result_overview_result.py +144 -0
  27. rapidata/api_client/models/get_pipeline_by_id_result.py +13 -3
  28. rapidata/api_client/models/identity_read_bridge_token_get202_response.py +140 -0
  29. rapidata/api_client/models/not_available_yet_result.py +96 -0
  30. rapidata/api_client/models/online_pair_maker_config.py +98 -0
  31. rapidata/api_client/models/online_pair_maker_config_model.py +98 -0
  32. rapidata/api_client/models/online_pair_maker_information.py +100 -0
  33. rapidata/api_client/models/pipeline_id_workflow_put_request.py +140 -0
  34. rapidata/api_client/models/pre_arranged_pair_maker_config.py +100 -0
  35. rapidata/api_client/models/pre_arranged_pair_maker_config_model.py +96 -0
  36. rapidata/api_client/models/pre_arranged_pair_maker_information.py +102 -0
  37. rapidata/api_client/models/read_bridge_token_keys_result.py +11 -2
  38. rapidata/api_client/models/simple_workflow_config.py +7 -26
  39. rapidata/api_client/models/simple_workflow_config_model.py +4 -28
  40. rapidata/api_client/models/simple_workflow_get_result_overview_get200_response.py +16 -16
  41. rapidata/api_client/models/simple_workflow_model1.py +3 -3
  42. rapidata/api_client/models/update_campaign_model.py +99 -0
  43. rapidata/api_client/models/validation_import_post_request_blueprint.py +1 -1
  44. rapidata/api_client_README.md +21 -7
  45. rapidata/rapidata_client/__init__.py +20 -10
  46. rapidata/rapidata_client/assets/__init__.py +5 -4
  47. rapidata/rapidata_client/assets/{media_asset.py → _media_asset.py} +32 -11
  48. rapidata/rapidata_client/assets/{multi_asset.py → _multi_asset.py} +1 -1
  49. rapidata/rapidata_client/assets/{text_asset.py → _text_asset.py} +1 -1
  50. rapidata/rapidata_client/assets/data_type_enum.py +7 -0
  51. rapidata/rapidata_client/filter/__init__.py +2 -1
  52. rapidata/rapidata_client/filter/_base_filter.py +10 -0
  53. rapidata/rapidata_client/filter/age_filter.py +12 -5
  54. rapidata/rapidata_client/filter/campaign_filter.py +12 -3
  55. rapidata/rapidata_client/filter/country_filter.py +10 -3
  56. rapidata/rapidata_client/filter/custom_filter.py +29 -0
  57. rapidata/rapidata_client/filter/gender_filter.py +12 -5
  58. rapidata/rapidata_client/filter/language_filter.py +14 -3
  59. rapidata/rapidata_client/filter/models/age_group.py +26 -0
  60. rapidata/rapidata_client/filter/models/gender.py +19 -0
  61. rapidata/rapidata_client/filter/rapidata_filters.py +35 -0
  62. rapidata/rapidata_client/filter/user_score_filter.py +20 -4
  63. rapidata/rapidata_client/metadata/__init__.py +5 -5
  64. rapidata/rapidata_client/metadata/{base_metadata.py → _base_metadata.py} +2 -1
  65. rapidata/rapidata_client/metadata/{private_text_metadata.py → _private_text_metadata.py} +2 -2
  66. rapidata/rapidata_client/metadata/{prompt_metadata.py → _prompt_metadata.py} +3 -2
  67. rapidata/rapidata_client/metadata/{public_text_metadata.py → _public_text_metadata.py} +2 -2
  68. rapidata/rapidata_client/metadata/{select_words_metadata.py → _select_words_metadata.py} +3 -2
  69. rapidata/rapidata_client/{dataset/rapidata_dataset.py → order/_rapidata_dataset.py} +7 -8
  70. rapidata/rapidata_client/order/_rapidata_order_builder.py +365 -0
  71. rapidata/rapidata_client/order/rapidata_order.py +50 -32
  72. rapidata/rapidata_client/order/rapidata_order_manager.py +461 -0
  73. rapidata/rapidata_client/rapidata_client.py +12 -201
  74. rapidata/rapidata_client/referee/__init__.py +3 -3
  75. rapidata/rapidata_client/referee/{base_referee.py → _base_referee.py} +3 -3
  76. rapidata/rapidata_client/referee/{early_stopping_referee.py → _early_stopping_referee.py} +14 -11
  77. rapidata/rapidata_client/referee/{naive_referee.py → _naive_referee.py} +9 -9
  78. rapidata/rapidata_client/selection/__init__.py +1 -1
  79. rapidata/rapidata_client/{filter/base_filter.py → selection/_base_selection.py} +2 -2
  80. rapidata/rapidata_client/selection/capped_selection.py +15 -5
  81. rapidata/rapidata_client/selection/conditional_validation_selection.py +17 -4
  82. rapidata/rapidata_client/selection/demographic_selection.py +18 -7
  83. rapidata/rapidata_client/selection/labeling_selection.py +10 -3
  84. rapidata/rapidata_client/selection/rapidata_selections.py +21 -0
  85. rapidata/rapidata_client/selection/validation_selection.py +11 -4
  86. rapidata/rapidata_client/settings/__init__.py +9 -2
  87. rapidata/rapidata_client/settings/_rapidata_setting.py +11 -0
  88. rapidata/rapidata_client/settings/alert_on_fast_response.py +21 -0
  89. rapidata/rapidata_client/settings/custom_setting.py +16 -0
  90. rapidata/rapidata_client/settings/free_text_minimum_characters.py +16 -0
  91. rapidata/rapidata_client/settings/models/__init__.py +1 -0
  92. rapidata/rapidata_client/settings/models/translation_behaviour_options.py +14 -0
  93. rapidata/rapidata_client/settings/no_shuffle.py +16 -0
  94. rapidata/rapidata_client/settings/play_video_until_the_end.py +16 -0
  95. rapidata/rapidata_client/settings/rapidata_settings.py +31 -0
  96. rapidata/rapidata_client/settings/translation_behaviour.py +18 -0
  97. rapidata/rapidata_client/validation/__init__.py +1 -0
  98. rapidata/rapidata_client/{dataset/validation_rapid_parts.py → validation/_validation_rapid_parts.py} +7 -6
  99. rapidata/rapidata_client/validation/_validation_set_builder.py +371 -0
  100. rapidata/rapidata_client/{dataset → validation}/rapidata_validation_set.py +54 -50
  101. rapidata/rapidata_client/validation/rapids/__init__.py +1 -0
  102. rapidata/rapidata_client/validation/rapids/box.py +17 -0
  103. rapidata/rapidata_client/validation/rapids/rapids.py +94 -0
  104. rapidata/rapidata_client/validation/rapids/rapids_manager.py +163 -0
  105. rapidata/rapidata_client/validation/validation_set_manager.py +338 -0
  106. rapidata/rapidata_client/workflow/__init__.py +8 -6
  107. rapidata/rapidata_client/workflow/_base_workflow.py +25 -0
  108. rapidata/rapidata_client/workflow/{classify_workflow.py → _classify_workflow.py} +6 -6
  109. rapidata/rapidata_client/workflow/{compare_workflow.py → _compare_workflow.py} +10 -16
  110. rapidata/rapidata_client/workflow/_draw_workflow.py +22 -0
  111. rapidata/rapidata_client/workflow/_evaluation_workflow.py +26 -0
  112. rapidata/rapidata_client/workflow/{free_text_workflow.py → _free_text_workflow.py} +10 -16
  113. rapidata/rapidata_client/workflow/_locate_workflow.py +22 -0
  114. rapidata/rapidata_client/workflow/{select_words_workflow.py → _select_words_workflow.py} +2 -8
  115. rapidata/service/credential_manager.py +11 -1
  116. rapidata/service/openapi_service.py +23 -4
  117. {rapidata-1.10.1.dist-info → rapidata-2.1.0.dist-info}/METADATA +2 -1
  118. {rapidata-1.10.1.dist-info → rapidata-2.1.0.dist-info}/RECORD +122 -96
  119. rapidata/constants.py +0 -1
  120. rapidata/rapidata_client/dataset/rapid_builders/__init__.py +0 -4
  121. rapidata/rapidata_client/dataset/rapid_builders/base_rapid_builder.py +0 -33
  122. rapidata/rapidata_client/dataset/rapid_builders/classify_rapid_builders.py +0 -166
  123. rapidata/rapidata_client/dataset/rapid_builders/compare_rapid_builders.py +0 -145
  124. rapidata/rapidata_client/dataset/rapid_builders/rapids.py +0 -33
  125. rapidata/rapidata_client/dataset/rapid_builders/select_words_rapid_builders.py +0 -124
  126. rapidata/rapidata_client/dataset/validation_set_builder.py +0 -336
  127. rapidata/rapidata_client/order/order_builder.py +0 -25
  128. rapidata/rapidata_client/order/rapidata_order_builder.py +0 -463
  129. rapidata/rapidata_client/selection/base_selection.py +0 -9
  130. rapidata/rapidata_client/settings/feature_flags.py +0 -125
  131. rapidata/rapidata_client/settings/settings.py +0 -124
  132. rapidata/rapidata_client/simple_builders/__init__.py +0 -0
  133. rapidata/rapidata_client/simple_builders/simple_classification_builders.py +0 -271
  134. rapidata/rapidata_client/simple_builders/simple_compare_builders.py +0 -267
  135. rapidata/rapidata_client/simple_builders/simple_free_text_builders.py +0 -192
  136. rapidata/rapidata_client/simple_builders/simple_select_words_builders.py +0 -196
  137. rapidata/rapidata_client/workflow/base_workflow.py +0 -42
  138. rapidata/rapidata_client/workflow/evaluation_workflow.py +0 -15
  139. /rapidata/rapidata_client/assets/{base_asset.py → _base_asset.py} +0 -0
  140. /rapidata/rapidata_client/{dataset → filter/models}/__init__.py +0 -0
  141. {rapidata-1.10.1.dist-info → rapidata-2.1.0.dist-info}/LICENSE +0 -0
  142. {rapidata-1.10.1.dist-info → rapidata-2.1.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.order_builder import BaseOrderBuilder
3
+ from rapidata.rapidata_client.order.rapidata_order_manager import RapidataOrderManager
9
4
 
10
- from rapidata.rapidata_client.simple_builders.simple_classification_builders import ClassificationQuestionBuilder
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. Best practice is to store the client ID and client secret in environment variables. Ask your Rapidata representative for the client ID and client secret.
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
- endpoint (str, optional): The API endpoint URL.
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.openapi_service = OpenAPIService(
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.rapid_builder = BaseRapidBuilder()
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
- return RapidataValidationSet(validation_set_id, self.openapi_service, validation_set.name)
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 .base_referee import Referee
2
- from .naive_referee import NaiveReferee #as MaxVoteReferee
3
- from .early_stopping_referee import EarlyStoppingReferee
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 to_dict(self) -> Mapping[str, str | int | float]:
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 to_model(self) -> Any:
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.base_referee import 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
- """Initialize the EarlyStoppingReferee.
28
-
29
- Args:
30
- threshold (float, optional): The confidence threshold for early stopping.
31
- Defaults to 0.999.
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 to_dict(self):
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 to_model(self) -> Any:
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.base_referee import 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
- """Initialize the NaiveReferee.
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 to_dict(self):
26
+ def _to_dict(self):
27
27
  return {
28
28
  "_t": "NaiveRefereeConfig",
29
29
  "guessesRequired": self.responses,
30
30
  }
31
31
 
32
- def to_model(self):
32
+ def _to_model(self):
33
33
  return NaiveRefereeModel(_t="NaiveReferee", totalVotes=self.responses)
@@ -1,4 +1,4 @@
1
- from .base_selection import Selection
1
+ from ._base_selection import RapidataSelection
2
2
  from .demographic_selection import DemographicSelection
3
3
  from .labeling_selection import LabelingSelection
4
4
  from .validation_selection import ValidationSelection
@@ -2,8 +2,8 @@ from abc import abstractmethod
2
2
  from typing import Any
3
3
 
4
4
 
5
- class Filter:
5
+ class RapidataSelection:
6
6
 
7
7
  @abstractmethod
8
- def to_model(self) -> Any:
8
+ def _to_model(self) -> Any:
9
9
  pass
@@ -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.base_selection import Selection
7
+ from rapidata.rapidata_client.selection._base_selection import RapidataSelection
8
8
  from typing import Sequence
9
9
 
10
10
 
11
- class CappedSelection(Selection):
11
+ class CappedSelection(RapidataSelection):
12
+ """CappedSelection Class
12
13
 
13
- def __init__(self, selections: Sequence[Selection], max_rapids: int):
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 to_model(self):
27
+ def _to_model(self):
18
28
  return CappedSelectionModel(
19
29
  _t="CappedSelection",
20
30
  selections=[
21
- CappedSelectionSelectionsInner(selection.to_model())
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.base_selection import 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(Selection):
11
- """Demographic selection class."""
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 to_model(self):
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.base_selection import 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(Selection):
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
- def __init__(self, keys: list[str], maxRapids: int):
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.maxRapids = maxRapids
21
+ self.max_rapids = max_rapids
11
22
 
12
- def to_model(self):
13
- return DemographicSelectionModel(_t="DemographicSelection", keys=self.keys, maxRapids=self.maxRapids)
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.base_selection import 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(Selection):
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 to_model(self) -> Any:
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.base_selection import Selection
3
+ from rapidata.rapidata_client.selection._base_selection import RapidataSelection
4
4
 
5
5
 
6
- class ValidationSelection(Selection):
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 .feature_flags import FeatureFlags
2
- from .settings import Settings, TranslationBehaviour
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