rapidata 2.37.0__py3-none-any.whl → 2.39.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 (117) hide show
  1. rapidata/__init__.py +3 -4
  2. rapidata/api_client/__init__.py +4 -5
  3. rapidata/api_client/api/benchmark_api.py +289 -3
  4. rapidata/api_client/api/leaderboard_api.py +35 -1
  5. rapidata/api_client/api/participant_api.py +289 -3
  6. rapidata/api_client/api/validation_set_api.py +119 -400
  7. rapidata/api_client/models/__init__.py +4 -5
  8. rapidata/api_client/models/ab_test_selection_a_inner.py +1 -1
  9. rapidata/api_client/models/compare_workflow_model1.py +1 -8
  10. rapidata/api_client/models/conditional_validation_selection.py +4 -9
  11. rapidata/api_client/models/confidence_interval.py +98 -0
  12. rapidata/api_client/models/create_simple_pipeline_model_pipeline_steps_inner.py +8 -22
  13. rapidata/api_client/models/get_standing_by_id_result.py +7 -2
  14. rapidata/api_client/models/get_validation_set_by_id_result.py +4 -2
  15. rapidata/api_client/models/simple_workflow_model1.py +1 -8
  16. rapidata/api_client/models/standing_by_leaderboard.py +10 -4
  17. rapidata/api_client/models/update_benchmark_model.py +87 -0
  18. rapidata/api_client/models/update_participant_model.py +87 -0
  19. rapidata/api_client/models/update_validation_set_model.py +93 -0
  20. rapidata/api_client/models/validation_chance.py +20 -3
  21. rapidata/api_client/models/validation_set_model.py +5 -42
  22. rapidata/api_client_README.md +7 -7
  23. rapidata/rapidata_client/__init__.py +1 -4
  24. rapidata/rapidata_client/api/{rapidata_exception.py → rapidata_api_client.py} +119 -2
  25. rapidata/rapidata_client/benchmark/leaderboard/rapidata_leaderboard.py +88 -46
  26. rapidata/rapidata_client/benchmark/participant/_participant.py +26 -9
  27. rapidata/rapidata_client/benchmark/rapidata_benchmark.py +310 -210
  28. rapidata/rapidata_client/benchmark/rapidata_benchmark_manager.py +134 -75
  29. rapidata/rapidata_client/config/__init__.py +3 -0
  30. rapidata/rapidata_client/config/logger.py +135 -0
  31. rapidata/rapidata_client/config/logging_config.py +58 -0
  32. rapidata/rapidata_client/config/managed_print.py +6 -0
  33. rapidata/rapidata_client/config/order_config.py +14 -0
  34. rapidata/rapidata_client/config/rapidata_config.py +15 -10
  35. rapidata/rapidata_client/config/tracer.py +130 -0
  36. rapidata/rapidata_client/config/upload_config.py +14 -0
  37. rapidata/rapidata_client/datapoints/_datapoint.py +1 -1
  38. rapidata/rapidata_client/datapoints/assets/__init__.py +1 -0
  39. rapidata/rapidata_client/datapoints/assets/_base_asset.py +2 -0
  40. rapidata/rapidata_client/datapoints/assets/_media_asset.py +1 -1
  41. rapidata/rapidata_client/datapoints/assets/_sessions.py +2 -2
  42. rapidata/rapidata_client/datapoints/assets/_text_asset.py +2 -2
  43. rapidata/rapidata_client/datapoints/assets/data_type_enum.py +1 -1
  44. rapidata/rapidata_client/datapoints/metadata/_media_asset_metadata.py +9 -8
  45. rapidata/rapidata_client/datapoints/metadata/_prompt_metadata.py +1 -2
  46. rapidata/rapidata_client/demographic/demographic_manager.py +16 -14
  47. rapidata/rapidata_client/filter/_base_filter.py +11 -5
  48. rapidata/rapidata_client/filter/age_filter.py +9 -3
  49. rapidata/rapidata_client/filter/and_filter.py +20 -5
  50. rapidata/rapidata_client/filter/campaign_filter.py +7 -1
  51. rapidata/rapidata_client/filter/country_filter.py +8 -2
  52. rapidata/rapidata_client/filter/custom_filter.py +9 -3
  53. rapidata/rapidata_client/filter/gender_filter.py +9 -3
  54. rapidata/rapidata_client/filter/language_filter.py +12 -5
  55. rapidata/rapidata_client/filter/models/age_group.py +4 -4
  56. rapidata/rapidata_client/filter/models/gender.py +4 -2
  57. rapidata/rapidata_client/filter/new_user_filter.py +3 -4
  58. rapidata/rapidata_client/filter/not_filter.py +17 -5
  59. rapidata/rapidata_client/filter/or_filter.py +20 -5
  60. rapidata/rapidata_client/filter/rapidata_filters.py +12 -9
  61. rapidata/rapidata_client/filter/response_count_filter.py +6 -0
  62. rapidata/rapidata_client/filter/user_score_filter.py +17 -5
  63. rapidata/rapidata_client/order/_rapidata_dataset.py +45 -17
  64. rapidata/rapidata_client/order/_rapidata_order_builder.py +19 -13
  65. rapidata/rapidata_client/order/rapidata_order.py +60 -48
  66. rapidata/rapidata_client/order/rapidata_order_manager.py +231 -197
  67. rapidata/rapidata_client/order/rapidata_results.py +71 -57
  68. rapidata/rapidata_client/rapidata_client.py +36 -23
  69. rapidata/rapidata_client/referee/__init__.py +1 -1
  70. rapidata/rapidata_client/referee/_base_referee.py +3 -1
  71. rapidata/rapidata_client/referee/_early_stopping_referee.py +2 -2
  72. rapidata/rapidata_client/selection/_base_selection.py +6 -0
  73. rapidata/rapidata_client/selection/ab_test_selection.py +7 -3
  74. rapidata/rapidata_client/selection/capped_selection.py +2 -2
  75. rapidata/rapidata_client/selection/conditional_validation_selection.py +12 -6
  76. rapidata/rapidata_client/selection/demographic_selection.py +9 -6
  77. rapidata/rapidata_client/selection/rapidata_selections.py +11 -8
  78. rapidata/rapidata_client/selection/shuffling_selection.py +5 -5
  79. rapidata/rapidata_client/selection/static_selection.py +5 -10
  80. rapidata/rapidata_client/selection/validation_selection.py +9 -5
  81. rapidata/rapidata_client/settings/_rapidata_setting.py +8 -0
  82. rapidata/rapidata_client/settings/alert_on_fast_response.py +8 -5
  83. rapidata/rapidata_client/settings/allow_neither_both.py +1 -0
  84. rapidata/rapidata_client/settings/custom_setting.py +3 -2
  85. rapidata/rapidata_client/settings/free_text_minimum_characters.py +9 -4
  86. rapidata/rapidata_client/settings/models/translation_behaviour_options.py +3 -2
  87. rapidata/rapidata_client/settings/no_shuffle.py +4 -2
  88. rapidata/rapidata_client/settings/play_video_until_the_end.py +7 -4
  89. rapidata/rapidata_client/settings/rapidata_settings.py +4 -3
  90. rapidata/rapidata_client/settings/translation_behaviour.py +7 -5
  91. rapidata/rapidata_client/validation/rapidata_validation_set.py +23 -17
  92. rapidata/rapidata_client/validation/rapids/box.py +3 -1
  93. rapidata/rapidata_client/validation/rapids/rapids.py +7 -1
  94. rapidata/rapidata_client/validation/rapids/rapids_manager.py +174 -141
  95. rapidata/rapidata_client/validation/validation_set_manager.py +285 -268
  96. rapidata/rapidata_client/workflow/__init__.py +1 -1
  97. rapidata/rapidata_client/workflow/_base_workflow.py +6 -1
  98. rapidata/rapidata_client/workflow/_classify_workflow.py +6 -0
  99. rapidata/rapidata_client/workflow/_compare_workflow.py +6 -0
  100. rapidata/rapidata_client/workflow/_draw_workflow.py +6 -0
  101. rapidata/rapidata_client/workflow/_evaluation_workflow.py +6 -0
  102. rapidata/rapidata_client/workflow/_free_text_workflow.py +6 -0
  103. rapidata/rapidata_client/workflow/_locate_workflow.py +6 -0
  104. rapidata/rapidata_client/workflow/_ranking_workflow.py +12 -0
  105. rapidata/rapidata_client/workflow/_select_words_workflow.py +6 -0
  106. rapidata/rapidata_client/workflow/_timestamp_workflow.py +6 -0
  107. rapidata/service/__init__.py +1 -1
  108. rapidata/service/credential_manager.py +1 -1
  109. rapidata/service/local_file_service.py +9 -8
  110. rapidata/service/openapi_service.py +2 -2
  111. {rapidata-2.37.0.dist-info → rapidata-2.39.0.dist-info}/METADATA +4 -1
  112. {rapidata-2.37.0.dist-info → rapidata-2.39.0.dist-info}/RECORD +114 -107
  113. rapidata/rapidata_client/logging/__init__.py +0 -2
  114. rapidata/rapidata_client/logging/logger.py +0 -122
  115. rapidata/rapidata_client/logging/output_manager.py +0 -20
  116. {rapidata-2.37.0.dist-info → rapidata-2.39.0.dist-info}/LICENSE +0 -0
  117. {rapidata-2.37.0.dist-info → rapidata-2.39.0.dist-info}/WHEEL +0 -0
@@ -1,5 +1,6 @@
1
-
2
- from rapidata.api_client.models.validation_selection import ValidationSelection as ValidationSelectionModel
1
+ from rapidata.api_client.models.validation_selection import (
2
+ ValidationSelection as ValidationSelectionModel,
3
+ )
3
4
  from rapidata.rapidata_client.selection._base_selection import RapidataSelection
4
5
 
5
6
 
@@ -7,7 +8,7 @@ class ValidationSelection(RapidataSelection):
7
8
  """Validation selection class.
8
9
 
9
10
  Decides how many validation rapids you want to show per session.
10
-
11
+
11
12
  Args:
12
13
  validation_set_id (str): The id of the validation set to be used.
13
14
  amount (int): The amount of validation rapids that will be shown per session of this validation set.
@@ -18,5 +19,8 @@ class ValidationSelection(RapidataSelection):
18
19
  self.amount = amount
19
20
 
20
21
  def _to_model(self):
21
- return ValidationSelectionModel(_t="ValidationSelection", validationSetId=self.validation_set_id, amount=self.amount)
22
-
22
+ return ValidationSelectionModel(
23
+ _t="ValidationSelection",
24
+ validationSetId=self.validation_set_id,
25
+ amount=self.amount,
26
+ )
@@ -2,10 +2,18 @@ from pydantic import BaseModel
2
2
  from typing import Any
3
3
  from rapidata.api_client.models.feature_flag_model import FeatureFlagModel
4
4
 
5
+
5
6
  class RapidataSetting(BaseModel):
6
7
  """Base class for all settings"""
8
+
7
9
  key: str
8
10
  value: Any
9
11
 
10
12
  def _to_feature_flag(self) -> FeatureFlagModel:
11
13
  return FeatureFlagModel(key=self.key, value=str(self.value))
14
+
15
+ def __str__(self) -> str:
16
+ return f"{self.__class__.__name__}(key='{self.key}', value={self.value})"
17
+
18
+ def __repr__(self) -> str:
19
+ return f"{self.__class__.__name__}(key={self.key!r}, value={self.value!r})"
@@ -1,22 +1,25 @@
1
1
  from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
2
- from rapidata.rapidata_client.logging import managed_print
2
+ from rapidata.rapidata_client.config import managed_print
3
+
3
4
 
4
5
  class AlertOnFastResponse(RapidataSetting):
5
6
  """
6
7
  Gives an alert as a pop up on the UI when the response time is less than the milliseconds.
7
-
8
+
8
9
  Args:
9
10
  threshold (int): if the user responds in less than this time, an alert will be shown.
10
11
  """
11
-
12
+
12
13
  def __init__(self, threshold: int):
13
14
  if not isinstance(threshold, int):
14
15
  raise ValueError("The alert must be an integer.")
15
16
  if threshold < 10:
16
- managed_print(f"Warning: Are you sure you want to set the threshold so low ({threshold} milliseconds)?")
17
+ managed_print(
18
+ f"Warning: Are you sure you want to set the threshold so low ({threshold} milliseconds)?"
19
+ )
17
20
  if threshold > 25000:
18
21
  raise ValueError("The alert must be less than 25000 milliseconds.")
19
22
  if threshold < 0:
20
23
  raise ValueError("The alert must be greater than or equal to 0.")
21
-
24
+
22
25
  super().__init__(key="alert_on_fast_response", value=threshold)
@@ -1,5 +1,6 @@
1
1
  from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
2
2
 
3
+
3
4
  class AllowNeitherBoth(RapidataSetting):
4
5
  """
5
6
  Set whether to allow neither or both options.
@@ -1,9 +1,10 @@
1
1
  from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
2
2
 
3
+
3
4
  class CustomSetting(RapidataSetting):
4
5
  """
5
6
  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
+
7
8
  Args:
8
9
  key (str): The key for the custom setting.
9
10
  value (str): The value for the custom setting.
@@ -12,5 +13,5 @@ class CustomSetting(RapidataSetting):
12
13
  def __init__(self, key: str, value: str):
13
14
  if not isinstance(key, str):
14
15
  raise ValueError("The key must be a string.")
15
-
16
+
16
17
  super().__init__(key=key, value=value)
@@ -1,17 +1,22 @@
1
1
  from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
2
- from rapidata.rapidata_client.logging import managed_print, logger
2
+ from rapidata.rapidata_client.config import managed_print
3
+
3
4
 
4
5
  class FreeTextMinimumCharacters(RapidataSetting):
5
6
  """
6
7
  Set the minimum number of characters a user has to type.
7
-
8
+
8
9
  Args:
9
10
  value (int): The minimum number of characters for free text.
10
11
  """
11
12
 
12
13
  def __init__(self, value: int):
13
14
  if value < 1:
14
- raise ValueError("The minimum number of characters must be greater than or equal to 1.")
15
+ raise ValueError(
16
+ "The minimum number of characters must be greater than or equal to 1."
17
+ )
15
18
  if value > 40:
16
- managed_print(f"Warning: Are you sure you want to set the minimum number of characters at {value}?")
19
+ managed_print(
20
+ f"Warning: Are you sure you want to set the minimum number of characters at {value}?"
21
+ )
17
22
  super().__init__(key="free_text_minimum_characters", value=value)
@@ -1,14 +1,15 @@
1
1
  from enum import Enum
2
2
 
3
+
3
4
  class TranslationBehaviourOptions(Enum):
4
5
  """The options for the translation behaviour setting.
5
-
6
+
6
7
  Attributes:
7
8
  BOTH: Show both the original and the translated text.
8
9
  May clutter the screen if the options are too long.
9
10
  ONLY_ORIGINAL: Show only the original text.
10
11
  ONLY_TRANSLATED: Show only the translated text."""
11
-
12
+
12
13
  BOTH = "both"
13
14
  ONLY_ORIGINAL = "only original"
14
15
  ONLY_TRANSLATED = "only translated"
@@ -1,16 +1,18 @@
1
1
  from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
2
2
 
3
+
3
4
  class NoShuffle(RapidataSetting):
4
5
  """
5
6
  Only for classification and compare tasks. If true, the order of the categories / images will not be shuffled and presented in the same order as specified.
6
7
 
7
8
  If this is not added to the order, the shuffling will be active.
8
-
9
+
9
10
  Args:
10
11
  value (bool, optional): Whether to disable shuffling. Defaults to True for function call.
11
12
  """
13
+
12
14
  def __init__(self, value: bool = True):
13
15
  if not isinstance(value, bool):
14
16
  raise ValueError("The value must be a boolean.")
15
-
17
+
16
18
  super().__init__(key="no_shuffle", value=value)
@@ -1,16 +1,19 @@
1
1
  from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
2
2
 
3
+
3
4
  class PlayVideoUntilTheEnd(RapidataSetting):
4
5
  """
5
6
  Allows users to only answer once the video has finished playing.
6
7
  The additional time gets added on top of the video duration. Can be negative to allow answers before the video ends.
7
-
8
+
8
9
  Args:
9
10
  additional_time (int, optional): Additional time in milliseconds. Defaults to 0.
10
11
  """
11
-
12
+
12
13
  def __init__(self, additional_time: int = 0):
13
14
  if additional_time < -25000 or additional_time > 25000:
14
15
  raise ValueError("The additional time must be between -25000 and 25000.")
15
-
16
- super().__init__(key="alert_on_fast_response_add_media_duration", value=additional_time)
16
+
17
+ super().__init__(
18
+ key="alert_on_fast_response_add_media_duration", value=additional_time
19
+ )
@@ -5,14 +5,15 @@ from rapidata.rapidata_client.settings import (
5
5
  NoShuffle,
6
6
  PlayVideoUntilTheEnd,
7
7
  AllowNeitherBoth,
8
- )
8
+ )
9
+
9
10
 
10
11
  class RapidataSettings:
11
12
  """
12
13
  Container class for all setting factory functions
13
14
 
14
15
  Settings can be added to an order to determine the behaviour of the task.
15
-
16
+
16
17
  Attributes:
17
18
  alert_on_fast_response (AlertOnFastResponse): Gives an alert as a pop up on the UI when the response time is less than the milliseconds.
18
19
  translation_behaviour (TranslationBehaviour): Defines what's the behaviour of the translation in the UI.
@@ -27,7 +28,7 @@ class RapidataSettings:
27
28
  settings=[FreeTextMinimumCharacters(10)]
28
29
  ```
29
30
 
30
- This can be used in a free text order to set the minimum number of characters required to submit the task.
31
+ This can be used in a free text order to set the minimum number of characters required to submit the task.
31
32
  """
32
33
 
33
34
  alert_on_fast_response = AlertOnFastResponse
@@ -1,18 +1,20 @@
1
- from rapidata.rapidata_client.settings.models.translation_behaviour_options import TranslationBehaviourOptions
1
+ from rapidata.rapidata_client.settings.models.translation_behaviour_options import (
2
+ TranslationBehaviourOptions,
3
+ )
2
4
  from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
3
5
 
6
+
4
7
  class TranslationBehaviour(RapidataSetting):
5
8
  """
6
9
  Defines what's the behaviour of the translation in the UI.
7
10
  Will not translate text datapoints or sentences.
8
-
11
+
9
12
  Args:
10
13
  value (TranslationBehaviourOptions): The translation behaviour.
11
14
  """
12
-
15
+
13
16
  def __init__(self, value: TranslationBehaviourOptions):
14
17
  if not isinstance(value, TranslationBehaviourOptions):
15
18
  raise ValueError("The value must be a TranslationBehaviourOptions.")
16
-
17
- super().__init__(key="translation_behaviour", value=value)
18
19
 
20
+ super().__init__(key="translation_behaviour", value=value)
@@ -3,8 +3,10 @@ import urllib.parse
3
3
  from colorama import Fore
4
4
  from rapidata.rapidata_client.validation.rapids.rapids import Rapid
5
5
  from rapidata.service.openapi_service import OpenAPIService
6
- from rapidata.rapidata_client.logging import logger, managed_print
7
- from rapidata.api_client.models.update_dimensions_model import UpdateDimensionsModel
6
+ from rapidata.rapidata_client.config import logger, managed_print, tracer
7
+ from rapidata.api_client.models.update_validation_set_model import (
8
+ UpdateValidationSetModel,
9
+ )
8
10
  from rapidata.api_client.models.update_should_alert_model import UpdateShouldAlertModel
9
11
 
10
12
 
@@ -34,7 +36,9 @@ class RapidataValidationSet:
34
36
  Args:
35
37
  rapid (Rapid): The Rapid to add to the validation set.
36
38
  """
37
- rapid._add_to_validation_set(self.id, self.__openapi_service)
39
+ with tracer.start_as_current_span("RapidataValidationSet.add_rapid"):
40
+ logger.debug("Adding rapid %s to validation set %s", rapid, self.id)
41
+ rapid._add_to_validation_set(self.id, self.__openapi_service)
38
42
  return self
39
43
 
40
44
  def update_dimensions(self, dimensions: list[str]):
@@ -43,13 +47,14 @@ class RapidataValidationSet:
43
47
  Args:
44
48
  dimensions (list[str]): The new dimensions of the validation set.
45
49
  """
46
- logger.debug(
47
- "Updating dimensions for validation set %s to %s", self.id, dimensions
48
- )
49
- self.__openapi_service.validation_api.validation_set_validation_set_id_dimensions_put(
50
- self.id, UpdateDimensionsModel(dimensions=dimensions)
51
- )
52
- return self
50
+ with tracer.start_as_current_span("RapidataValidationSet.update_dimensions"):
51
+ logger.debug(
52
+ "Updating dimensions for validation set %s to %s", self.id, dimensions
53
+ )
54
+ self.__openapi_service.validation_api.validation_set_validation_set_id_patch(
55
+ self.id, UpdateValidationSetModel(dimensions=dimensions)
56
+ )
57
+ return self
53
58
 
54
59
  def update_should_alert(self, should_alert: bool):
55
60
  """Determines whether users should be alerted if they answer incorrectly.
@@ -60,13 +65,14 @@ class RapidataValidationSet:
60
65
  Note:
61
66
  The userScore dimensions which are updated when a user answers a validation task are updated regardless of the value of `should_alert`.
62
67
  """
63
- logger.debug(
64
- "Setting shouldAlert for validation set %s to %s", self.id, should_alert
65
- )
66
- self.__openapi_service.validation_api.validation_set_validation_set_id_shouldalert_patch(
67
- self.id, UpdateShouldAlertModel(shouldAlert=should_alert)
68
- )
69
- return self
68
+ with tracer.start_as_current_span("RapidataValidationSet.update_should_alert"):
69
+ logger.debug(
70
+ "Setting shouldAlert for validation set %s to %s", self.id, should_alert
71
+ )
72
+ self.__openapi_service.validation_api.validation_set_validation_set_id_patch(
73
+ self.id, UpdateValidationSetModel(shouldAlert=should_alert)
74
+ )
75
+ return self
70
76
 
71
77
  def view(self) -> None:
72
78
  """
@@ -1,15 +1,17 @@
1
1
  from rapidata.api_client.models.box_shape import BoxShape
2
2
 
3
+
3
4
  class Box:
4
5
  """
5
6
  Used in the Locate and Draw Validation sets. All coordinates are in pixels.
6
-
7
+
7
8
  Args:
8
9
  x_min (float): The minimum x value of the box.
9
10
  y_min (float): The minimum y value of the box.
10
11
  x_max (float): The maximum x value of the box.
11
12
  y_max (float): The maximum y value of the box.
12
13
  """
14
+
13
15
  def __init__(self, x_min: float, y_min: float, x_max: float, y_max: float):
14
16
  self.x_min = x_min
15
17
  self.y_min = y_min
@@ -15,7 +15,7 @@ from rapidata.api_client.models.dataset_dataset_id_datapoints_post_request_metad
15
15
  )
16
16
  from rapidata.service.openapi_service import OpenAPIService
17
17
 
18
- from rapidata.rapidata_client.logging import logger
18
+ from rapidata.rapidata_client.config import logger
19
19
  from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
20
20
 
21
21
 
@@ -109,3 +109,9 @@ class Rapid:
109
109
  else None
110
110
  ),
111
111
  )
112
+
113
+ def __str__(self) -> str:
114
+ return f"Rapid(asset={self.asset}, metadata={self.metadata}, payload={self.payload}, truth={self.truth}, randomCorrectProbability={self.randomCorrectProbability}, explanation={self.explanation}, settings={self.settings})"
115
+
116
+ def __repr__(self) -> str:
117
+ return self.__str__()