rapidata 2.37.0__py3-none-any.whl → 2.38.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rapidata might be problematic. Click here for more details.

Files changed (65) hide show
  1. rapidata/__init__.py +3 -4
  2. rapidata/rapidata_client/__init__.py +1 -4
  3. rapidata/rapidata_client/api/{rapidata_exception.py → rapidata_api_client.py} +119 -2
  4. rapidata/rapidata_client/benchmark/leaderboard/rapidata_leaderboard.py +88 -46
  5. rapidata/rapidata_client/benchmark/participant/_participant.py +26 -9
  6. rapidata/rapidata_client/benchmark/rapidata_benchmark.py +274 -205
  7. rapidata/rapidata_client/benchmark/rapidata_benchmark_manager.py +98 -76
  8. rapidata/rapidata_client/config/__init__.py +3 -0
  9. rapidata/rapidata_client/config/logger.py +135 -0
  10. rapidata/rapidata_client/config/logging_config.py +58 -0
  11. rapidata/rapidata_client/config/managed_print.py +6 -0
  12. rapidata/rapidata_client/config/order_config.py +14 -0
  13. rapidata/rapidata_client/config/rapidata_config.py +14 -9
  14. rapidata/rapidata_client/config/tracer.py +130 -0
  15. rapidata/rapidata_client/config/upload_config.py +14 -0
  16. rapidata/rapidata_client/datapoints/_datapoint.py +1 -1
  17. rapidata/rapidata_client/datapoints/assets/_media_asset.py +1 -1
  18. rapidata/rapidata_client/datapoints/assets/_sessions.py +2 -2
  19. rapidata/rapidata_client/demographic/demographic_manager.py +16 -14
  20. rapidata/rapidata_client/filter/_base_filter.py +11 -5
  21. rapidata/rapidata_client/filter/age_filter.py +9 -3
  22. rapidata/rapidata_client/filter/and_filter.py +20 -5
  23. rapidata/rapidata_client/filter/campaign_filter.py +7 -1
  24. rapidata/rapidata_client/filter/country_filter.py +8 -2
  25. rapidata/rapidata_client/filter/custom_filter.py +9 -3
  26. rapidata/rapidata_client/filter/gender_filter.py +9 -3
  27. rapidata/rapidata_client/filter/language_filter.py +12 -5
  28. rapidata/rapidata_client/filter/new_user_filter.py +3 -4
  29. rapidata/rapidata_client/filter/not_filter.py +17 -5
  30. rapidata/rapidata_client/filter/or_filter.py +20 -5
  31. rapidata/rapidata_client/filter/response_count_filter.py +6 -0
  32. rapidata/rapidata_client/filter/user_score_filter.py +17 -5
  33. rapidata/rapidata_client/order/_rapidata_dataset.py +45 -17
  34. rapidata/rapidata_client/order/_rapidata_order_builder.py +19 -13
  35. rapidata/rapidata_client/order/rapidata_order.py +60 -48
  36. rapidata/rapidata_client/order/rapidata_order_manager.py +231 -197
  37. rapidata/rapidata_client/order/rapidata_results.py +71 -57
  38. rapidata/rapidata_client/rapidata_client.py +36 -23
  39. rapidata/rapidata_client/selection/_base_selection.py +6 -0
  40. rapidata/rapidata_client/selection/static_selection.py +5 -10
  41. rapidata/rapidata_client/settings/_rapidata_setting.py +8 -0
  42. rapidata/rapidata_client/settings/alert_on_fast_response.py +8 -5
  43. rapidata/rapidata_client/settings/free_text_minimum_characters.py +9 -4
  44. rapidata/rapidata_client/validation/rapidata_validation_set.py +20 -16
  45. rapidata/rapidata_client/validation/rapids/rapids.py +7 -1
  46. rapidata/rapidata_client/validation/validation_set_manager.py +285 -268
  47. rapidata/rapidata_client/workflow/_base_workflow.py +6 -1
  48. rapidata/rapidata_client/workflow/_classify_workflow.py +6 -0
  49. rapidata/rapidata_client/workflow/_compare_workflow.py +6 -0
  50. rapidata/rapidata_client/workflow/_draw_workflow.py +6 -0
  51. rapidata/rapidata_client/workflow/_evaluation_workflow.py +6 -0
  52. rapidata/rapidata_client/workflow/_free_text_workflow.py +6 -0
  53. rapidata/rapidata_client/workflow/_locate_workflow.py +6 -0
  54. rapidata/rapidata_client/workflow/_ranking_workflow.py +12 -0
  55. rapidata/rapidata_client/workflow/_select_words_workflow.py +6 -0
  56. rapidata/rapidata_client/workflow/_timestamp_workflow.py +6 -0
  57. rapidata/service/credential_manager.py +1 -1
  58. rapidata/service/openapi_service.py +2 -2
  59. {rapidata-2.37.0.dist-info → rapidata-2.38.0.dist-info}/METADATA +4 -1
  60. {rapidata-2.37.0.dist-info → rapidata-2.38.0.dist-info}/RECORD +62 -59
  61. rapidata/rapidata_client/logging/__init__.py +0 -2
  62. rapidata/rapidata_client/logging/logger.py +0 -122
  63. rapidata/rapidata_client/logging/output_manager.py +0 -20
  64. {rapidata-2.37.0.dist-info → rapidata-2.38.0.dist-info}/LICENSE +0 -0
  65. {rapidata-2.37.0.dist-info → rapidata-2.38.0.dist-info}/WHEEL +0 -0
@@ -19,10 +19,11 @@ from rapidata.rapidata_client.exceptions.failed_upload_exception import (
19
19
  _parse_failed_uploads,
20
20
  )
21
21
  from rapidata.rapidata_client.filter import RapidataFilter
22
- from rapidata.rapidata_client.logging import (
22
+ from rapidata.rapidata_client.config import (
23
23
  logger,
24
24
  managed_print,
25
- RapidataOutputManager,
25
+ rapidata_config,
26
+ tracer,
26
27
  )
27
28
  from rapidata.rapidata_client.validation.validation_set_manager import (
28
29
  ValidationSetManager,
@@ -35,9 +36,9 @@ from rapidata.rapidata_client.selection._base_selection import RapidataSelection
35
36
  from rapidata.rapidata_client.settings import RapidataSetting
36
37
  from rapidata.rapidata_client.workflow import Workflow
37
38
  from rapidata.service.openapi_service import OpenAPIService
38
- from rapidata.rapidata_client.config.rapidata_config import rapidata_config
39
- from rapidata.rapidata_client.api.rapidata_exception import (
39
+ from rapidata.rapidata_client.api.rapidata_api_client import (
40
40
  suppress_rapidata_error_logging,
41
+ RapidataApiClient,
41
42
  )
42
43
 
43
44
 
@@ -153,14 +154,19 @@ class RapidataOrderBuilder:
153
154
  "Using recommended validation set with ID: %s", self.__validation_set_id
154
155
  )
155
156
  except Exception as e:
156
- logger.info("No recommended validation set found, creating new one.")
157
+ logger.debug("No recommended validation set found, error: %s", e)
157
158
 
158
- if len(self.__datapoints) < rapidata_config.minOrderDatapointsForValidation:
159
+ if (
160
+ len(self.__datapoints)
161
+ < rapidata_config.order.minOrderDatapointsForValidation
162
+ ):
159
163
  logger.debug(
160
164
  "No recommended validation set found, dataset too small to create one."
161
165
  )
162
166
  return
163
167
 
168
+ logger.info("No recommended validation set found, creating new one.")
169
+
164
170
  managed_print()
165
171
  managed_print(
166
172
  f"No recommended validation set found, new one will be created.\nWe recommend adding some truths to ensure the order is accurate."
@@ -170,7 +176,9 @@ class RapidataOrderBuilder:
170
176
  order_name=self._name,
171
177
  datapoints=random.sample(
172
178
  self.__datapoints,
173
- min(rapidata_config.autoValidationSetSize, len(self.__datapoints)),
179
+ min(
180
+ rapidata_config.order.autoValidationSetSize, len(self.__datapoints)
181
+ ),
174
182
  ),
175
183
  settings=self.__settings,
176
184
  )
@@ -182,9 +190,6 @@ class RapidataOrderBuilder:
182
190
  """
183
191
  Create the Rapidata order by making the necessary API calls based on the builder's configuration.
184
192
 
185
- Args:
186
- max_upload_workers (int, optional): The maximum number of worker threads for processing media paths. Defaults to 10.
187
-
188
193
  Raises:
189
194
  ValueError: If both media paths and texts are provided, or if neither is provided.
190
195
  AssertionError: If the workflow is a CompareWorkflow and media paths are not in pairs.
@@ -225,10 +230,11 @@ class RapidataOrderBuilder:
225
230
  logger.debug("Adding media to the order.")
226
231
 
227
232
  if self.__dataset:
228
- _, failed_uploads = self.__dataset.add_datapoints(self.__datapoints)
233
+ with tracer.start_as_current_span("add_datapoints"):
234
+ _, failed_uploads = self.__dataset.add_datapoints(self.__datapoints)
229
235
 
230
- if failed_uploads:
231
- raise FailedUploadException(self.__dataset, order, failed_uploads)
236
+ if failed_uploads:
237
+ raise FailedUploadException(self.__dataset, order, failed_uploads)
232
238
 
233
239
  else:
234
240
  raise RuntimeError(
@@ -20,12 +20,13 @@ from rapidata.api_client.models.preliminary_download_model import (
20
20
  from rapidata.api_client.models.workflow_artifact_model import WorkflowArtifactModel
21
21
  from rapidata.rapidata_client.order.rapidata_results import RapidataResults
22
22
  from rapidata.service.openapi_service import OpenAPIService
23
- from rapidata.rapidata_client.logging import (
23
+ from rapidata.rapidata_client.config import (
24
24
  logger,
25
25
  managed_print,
26
- RapidataOutputManager,
26
+ rapidata_config,
27
+ tracer,
27
28
  )
28
- from rapidata.rapidata_client.api.rapidata_exception import (
29
+ from rapidata.rapidata_client.api.rapidata_api_client import (
29
30
  suppress_rapidata_error_logging,
30
31
  )
31
32
 
@@ -74,36 +75,40 @@ class RapidataOrder:
74
75
 
75
76
  def run(self) -> "RapidataOrder":
76
77
  """Runs the order to start collecting responses."""
77
- logger.info("Starting order '%s'", self)
78
- self.__openapi_service.order_api.order_order_id_submit_post(
79
- self.id, SubmitOrderModel(ignoreFailedDatapoints=True)
80
- )
81
- logger.debug("Order '%s' has been started.", self)
82
- managed_print(
83
- f"Order '{self.name}' is now viewable under: {self.order_details_page}"
84
- )
85
- return self
78
+ with tracer.start_as_current_span("RapidataOrder.run"):
79
+ logger.info("Starting order '%s'", self)
80
+ self.__openapi_service.order_api.order_order_id_submit_post(
81
+ self.id, SubmitOrderModel(ignoreFailedDatapoints=True)
82
+ )
83
+ logger.debug("Order '%s' has been started.", self)
84
+ managed_print(
85
+ f"Order '{self.name}' is now viewable under: {self.order_details_page}"
86
+ )
87
+ return self
86
88
 
87
89
  def pause(self) -> None:
88
90
  """Pauses the order."""
89
- logger.info("Pausing order '%s'", self)
90
- self.__openapi_service.order_api.order_order_id_pause_post(self.id)
91
- logger.debug("Order '%s' has been paused.", self)
92
- managed_print(f"Order '{self}' has been paused.")
91
+ with tracer.start_as_current_span("RapidataOrder.pause"):
92
+ logger.info("Pausing order '%s'", self)
93
+ self.__openapi_service.order_api.order_order_id_pause_post(self.id)
94
+ logger.debug("Order '%s' has been paused.", self)
95
+ managed_print(f"Order '{self}' has been paused.")
93
96
 
94
97
  def unpause(self) -> None:
95
98
  """Unpauses/resumes the order."""
96
- logger.info("Unpausing order '%s'", self)
97
- self.__openapi_service.order_api.order_order_id_resume_post(self.id)
98
- logger.debug("Order '%s' has been unpaused.", self)
99
- managed_print(f"Order '{self}' has been unpaused.")
99
+ with tracer.start_as_current_span("RapidataOrder.unpause"):
100
+ logger.info("Unpausing order '%s'", self)
101
+ self.__openapi_service.order_api.order_order_id_resume_post(self.id)
102
+ logger.debug("Order '%s' has been unpaused.", self)
103
+ managed_print(f"Order '{self}' has been unpaused.")
100
104
 
101
105
  def delete(self) -> None:
102
106
  """Deletes the order."""
103
- logger.info("Deleting order '%s'", self)
104
- self.__openapi_service.order_api.order_order_id_delete(self.id)
105
- logger.debug("Order '%s' has been deleted.", self)
106
- managed_print(f"Order '{self}' has been deleted.")
107
+ with tracer.start_as_current_span("RapidataOrder.delete"):
108
+ logger.info("Deleting order '%s'", self)
109
+ self.__openapi_service.order_api.order_order_id_delete(self.id)
110
+ logger.debug("Order '%s' has been deleted.", self)
111
+ managed_print(f"Order '{self}' has been deleted.")
107
112
 
108
113
  def get_status(self) -> str:
109
114
  """
@@ -119,7 +124,8 @@ class RapidataOrder:
119
124
  Completed: The order has been completed.\n
120
125
  Failed: The order has failed.
121
126
  """
122
- return self.__openapi_service.order_api.order_order_id_get(self.id).state
127
+ with tracer.start_as_current_span("RapidataOrder.get_status"):
128
+ return self.__openapi_service.order_api.order_order_id_get(self.id).state
123
129
 
124
130
  def display_progress_bar(self, refresh_rate: int = 5) -> None:
125
131
  """
@@ -150,7 +156,7 @@ class RapidataOrder:
150
156
  desc="Processing order",
151
157
  unit="%",
152
158
  bar_format="{desc}: {percentage:3.0f}%|{bar}| completed [{elapsed}<{remaining}, {rate_fmt}]",
153
- disable=RapidataOutputManager.silent_mode,
159
+ disable=rapidata_config.logging.silent_mode,
154
160
  ) as pbar:
155
161
  last_percentage = 0
156
162
  while True:
@@ -193,31 +199,37 @@ class RapidataOrder:
193
199
  preliminary_results: If True, returns the preliminary results of the order. Defaults to False.
194
200
  Note that preliminary results are not final and may not contain all the datapoints & responses. Only the onese that are already available.
195
201
  """
196
- logger.info("Getting results for order '%s'...", self)
197
- if preliminary_results and self.get_status() not in [OrderState.COMPLETED]:
198
- return self.__get_preliminary_results()
199
-
200
- elif preliminary_results and self.get_status() in [OrderState.COMPLETED]:
201
- managed_print("Order is already completed. Returning final results.")
202
-
203
- while self.get_status() not in [
204
- OrderState.COMPLETED,
205
- OrderState.PAUSED,
206
- OrderState.MANUALREVIEW,
207
- OrderState.FAILED,
208
- ]:
209
- sleep(5)
202
+ with tracer.start_as_current_span("RapidataOrder.get_results"):
203
+ logger.info("Getting results for order '%s'...", self)
204
+ if preliminary_results and self.get_status() not in [OrderState.COMPLETED]:
205
+ return self.__get_preliminary_results()
206
+
207
+ elif preliminary_results and self.get_status() in [OrderState.COMPLETED]:
208
+ managed_print("Order is already completed. Returning final results.")
209
+
210
+ while (state := self.get_status()) not in [
211
+ OrderState.COMPLETED,
212
+ OrderState.PAUSED,
213
+ OrderState.MANUALREVIEW,
214
+ OrderState.FAILED,
215
+ ]:
216
+ sleep(5)
217
+ logger.debug(
218
+ "Order '%s' is in state %s not yet completed. Waiting...",
219
+ self,
220
+ state,
221
+ )
210
222
 
211
- try:
212
- return RapidataResults(
213
- json.loads(
214
- self.__openapi_service.order_api.order_order_id_download_results_get(
215
- order_id=self.id
223
+ try:
224
+ return RapidataResults(
225
+ json.loads(
226
+ self.__openapi_service.order_api.order_order_id_download_results_get(
227
+ order_id=self.id
228
+ )
216
229
  )
217
230
  )
218
- )
219
- except (ApiException, json.JSONDecodeError) as e:
220
- raise Exception(f"Failed to get order results: {str(e)}") from e
231
+ except (ApiException, json.JSONDecodeError) as e:
232
+ raise Exception(f"Failed to get order results: {str(e)}") from e
221
233
 
222
234
  def view(self) -> None:
223
235
  """