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
@@ -0,0 +1,14 @@
1
+ from pydantic import BaseModel, Field
2
+
3
+
4
+ class UploadConfig(BaseModel):
5
+ """
6
+ Holds the configuration for the upload process.
7
+
8
+ Attributes:
9
+ maxWorkers (int): The maximum number of worker threads for processing media paths. Defaults to 10.
10
+ maxRetries (int): The maximum number of retries for failed uploads. Defaults to 3.
11
+ """
12
+
13
+ maxWorkers: int = Field(default=10)
14
+ maxRetries: int = Field(default=3)
@@ -24,7 +24,7 @@ from rapidata.rapidata_client.datapoints.metadata._media_asset_metadata import (
24
24
  MediaAssetMetadata,
25
25
  )
26
26
  from rapidata.rapidata_client.datapoints.metadata._prompt_metadata import PromptMetadata
27
- from rapidata.rapidata_client.logging import logger
27
+ from rapidata.rapidata_client.config import logger
28
28
 
29
29
 
30
30
  class Datapoint:
@@ -2,6 +2,7 @@
2
2
 
3
3
  This package provides classes for different types of assets, including MediaAsset, TextAsset, and MultiAsset.
4
4
  """
5
+
5
6
  from ._base_asset import BaseAsset
6
7
  from ._media_asset import MediaAsset
7
8
  from ._text_asset import TextAsset
@@ -3,9 +3,11 @@
3
3
  Defines the BaseAsset class, which serves as the abstract base class for all asset types.
4
4
  """
5
5
 
6
+
6
7
  class BaseAsset:
7
8
  """BaseAsset Class
8
9
 
9
10
  An abstract base class for different types of assets. This class is intended to be subclassed by specific asset types.
10
11
  """
12
+
11
13
  pass
@@ -17,7 +17,7 @@ from pydantic import StrictStr, StrictBytes
17
17
  import logging
18
18
  from functools import cached_property
19
19
  from rapidata.rapidata_client.datapoints.assets._sessions import SessionManager
20
- from rapidata.rapidata_client.logging import logger
20
+ from rapidata.rapidata_client.config import logger
21
21
  from rapidata.rapidata_client.datapoints.assets.constants import (
22
22
  ALLOWED_IMAGE_EXTENSIONS,
23
23
  ALLOWED_MEDIA_EXTENSIONS,
@@ -18,8 +18,8 @@ class SessionManager:
18
18
  requests.Session: A singleton requests session with retry logic.
19
19
  """
20
20
  if cls._session is None:
21
- max_retries: int = rapidata_config.uploadMaxRetries
22
- max_workers: int = rapidata_config.maxUploadWorkers
21
+ max_retries: int = rapidata_config.upload.maxRetries
22
+ max_workers: int = rapidata_config.upload.maxWorkers
23
23
  cls._session = requests.Session()
24
24
  retries = Retry(
25
25
  total=max_retries,
@@ -24,11 +24,11 @@ class TextAsset(BaseAsset):
24
24
  """
25
25
  if not isinstance(text, str):
26
26
  raise ValueError(f"Text must be a string, got {type(text)}")
27
-
27
+
28
28
  self.text = text
29
29
 
30
30
  def __str__(self) -> str:
31
31
  return f"TextAsset(text={self.text})"
32
-
32
+
33
33
  def __repr__(self) -> str:
34
34
  return f"TextAsset(text={self.text})"
@@ -1,6 +1,6 @@
1
1
  class RapidataDataTypes:
2
2
  # deprecated use Literal["media", "text"] instead
3
- MEDIA = "media" # any form of image, video or audio
3
+ MEDIA = "media" # any form of image, video or audio
4
4
  TEXT = "text"
5
5
 
6
6
  @classmethod
@@ -1,7 +1,11 @@
1
- from rapidata.api_client.models.prompt_asset_metadata_input import PromptAssetMetadataInput
1
+ from rapidata.api_client.models.prompt_asset_metadata_input import (
2
+ PromptAssetMetadataInput,
3
+ )
2
4
  from rapidata.api_client.models.url_asset_input import UrlAssetInput
3
5
  from rapidata.rapidata_client.datapoints.metadata._base_metadata import Metadata
4
- from rapidata.api_client.models.prompt_asset_metadata_input_asset import PromptAssetMetadataInputAsset
6
+ from rapidata.api_client.models.prompt_asset_metadata_input_asset import (
7
+ PromptAssetMetadataInputAsset,
8
+ )
5
9
 
6
10
 
7
11
  class MediaAssetMetadata(Metadata):
@@ -12,11 +16,8 @@ class MediaAssetMetadata(Metadata):
12
16
 
13
17
  def to_model(self):
14
18
  return PromptAssetMetadataInput(
15
- _t="PromptAssetMetadataInput",
19
+ _t="PromptAssetMetadataInput",
16
20
  asset=PromptAssetMetadataInputAsset(
17
- actual_instance=UrlAssetInput(
18
- _t="UrlAssetInput",
19
- url=self._url
20
- )
21
- )
21
+ actual_instance=UrlAssetInput(_t="UrlAssetInput", url=self._url)
22
+ ),
22
23
  )
@@ -10,9 +10,8 @@ class PromptMetadata(Metadata):
10
10
 
11
11
  if not isinstance(prompt, str):
12
12
  raise ValueError("Prompt must be a string")
13
-
13
+
14
14
  self._prompt = prompt
15
-
16
15
 
17
16
  def to_model(self):
18
17
  return PromptMetadataInput(_t="PromptMetadataInput", prompt=self._prompt)
@@ -1,29 +1,31 @@
1
1
  from rapidata.service.openapi_service import OpenAPIService
2
2
  from rapidata.rapidata_client.datapoints.assets import MediaAsset
3
- from rapidata.api_client.models.create_demographic_rapid_model import CreateDemographicRapidModel
3
+ from rapidata.api_client.models.create_demographic_rapid_model import (
4
+ CreateDemographicRapidModel,
5
+ )
4
6
  from rapidata.api_client.models.classify_payload import ClassifyPayload
5
- from rapidata.rapidata_client.logging import logger
7
+ from rapidata.rapidata_client.config import logger
8
+
6
9
 
7
10
  class DemographicManager:
8
11
  def __init__(self, openapi_service: OpenAPIService):
9
12
  self._openapi_service = openapi_service
10
13
  logger.debug("DemographicManager initialized")
11
-
12
- def create_demographic_rapid(self,
13
- instruction: str,
14
- answer_options: list[str],
15
- datapoint: str,
16
- key: str):
17
-
14
+
15
+ def create_demographic_rapid(
16
+ self, instruction: str, answer_options: list[str], datapoint: str, key: str
17
+ ):
18
+
18
19
  media = MediaAsset(path=datapoint)
19
20
  model = CreateDemographicRapidModel(
20
21
  key=key,
21
22
  payload=ClassifyPayload(
22
23
  _t="ClassifyPayload",
23
24
  possibleCategories=answer_options,
24
- title=instruction
25
- )
25
+ title=instruction,
26
+ ),
27
+ )
28
+
29
+ self._openapi_service.rapid_api.rapid_demographic_post(
30
+ model=model, file=[media.to_file()]
26
31
  )
27
-
28
- self._openapi_service.rapid_api.rapid_demographic_post(model=model, file=[media.to_file()])
29
-
@@ -13,9 +13,9 @@ class RapidataFilter:
13
13
  """Enable the | operator to create OrFilter combinations."""
14
14
  if not isinstance(other, RapidataFilter):
15
15
  return NotImplemented
16
-
16
+
17
17
  from rapidata.rapidata_client.filter.or_filter import OrFilter
18
-
18
+
19
19
  # If self is already an OrFilter, extend its filters list
20
20
  if isinstance(self, OrFilter):
21
21
  if isinstance(other, OrFilter):
@@ -33,9 +33,9 @@ class RapidataFilter:
33
33
  """Enable the & operator to create AndFilter combinations."""
34
34
  if not isinstance(other, RapidataFilter):
35
35
  return NotImplemented
36
-
36
+
37
37
  from rapidata.rapidata_client.filter.and_filter import AndFilter
38
-
38
+
39
39
  # If self is already an AndFilter, extend its filters list
40
40
  if isinstance(self, AndFilter):
41
41
  if isinstance(other, AndFilter):
@@ -52,10 +52,16 @@ class RapidataFilter:
52
52
  def __invert__(self):
53
53
  """Enable the ~ operator to create NotFilter negations."""
54
54
  from rapidata.rapidata_client.filter.not_filter import NotFilter
55
-
55
+
56
56
  # If self is already a NotFilter, return the original filter (double negation)
57
57
  if isinstance(self, NotFilter):
58
58
  return self.filter
59
59
  # Create a new NotFilter
60
60
  else:
61
61
  return NotFilter(self)
62
+
63
+ def __str__(self) -> str:
64
+ return f"{self.__class__.__name__}()"
65
+
66
+ def __repr__(self) -> str:
67
+ return f"{self.__class__.__name__}()"
@@ -6,10 +6,10 @@ from rapidata.rapidata_client.filter.models.age_group import AgeGroup
6
6
 
7
7
  class AgeFilter(RapidataFilter):
8
8
  """AgeFilter Class
9
-
9
+
10
10
  Can be used to filter who to target based on age groups.
11
-
12
-
11
+
12
+
13
13
  Args:
14
14
  age_groups (list[AgeGroup]): List of age groups to filter by."""
15
15
 
@@ -21,3 +21,9 @@ class AgeFilter(RapidataFilter):
21
21
  _t="AgeFilter",
22
22
  ageGroups=[age_group._to_backend_model() for age_group in self.age_groups],
23
23
  )
24
+
25
+ def __str__(self) -> str:
26
+ return f"AgeFilter(age_groups={self.age_groups})"
27
+
28
+ def __repr__(self) -> str:
29
+ return f"AgeFilter(age_groups={self.age_groups!r})"
@@ -1,7 +1,9 @@
1
1
  from typing import Any
2
2
  from rapidata.rapidata_client.filter._base_filter import RapidataFilter
3
3
  from rapidata.api_client.models.and_user_filter_model import AndUserFilterModel
4
- from rapidata.api_client.models.and_user_filter_model_filters_inner import AndUserFilterModelFiltersInner
4
+ from rapidata.api_client.models.and_user_filter_model_filters_inner import (
5
+ AndUserFilterModelFiltersInner,
6
+ )
5
7
 
6
8
 
7
9
  class AndFilter(RapidataFilter):
@@ -10,21 +12,34 @@ class AndFilter(RapidataFilter):
10
12
 
11
13
  Args:
12
14
  filters (list[RapidataFilter]): A list of filters to be combined with AND.
13
-
15
+
14
16
  Example:
15
17
  ```python
16
18
  from rapidata import AndFilter, LanguageFilter, CountryFilter
17
19
 
18
- AndFilter([LanguageFilter(["en"]), CountryFilter(["US"])])
20
+ AndFilter([LanguageFilter(["en"]), CountryFilter(["US"])])
19
21
  ```
20
22
 
21
23
  This will match users who have their phone set to English AND are located in the United States.
22
24
  """
25
+
23
26
  def __init__(self, filters: list[RapidataFilter]):
24
27
  if not all(isinstance(filter, RapidataFilter) for filter in filters):
25
28
  raise ValueError("Filters must be a RapidataFilter object")
26
-
29
+
27
30
  self.filters = filters
28
31
 
29
32
  def _to_model(self):
30
- return AndUserFilterModel(_t="AndFilter", filters=[AndUserFilterModelFiltersInner(filter._to_model()) for filter in self.filters])
33
+ return AndUserFilterModel(
34
+ _t="AndFilter",
35
+ filters=[
36
+ AndUserFilterModelFiltersInner(filter._to_model())
37
+ for filter in self.filters
38
+ ],
39
+ )
40
+
41
+ def __str__(self) -> str:
42
+ return f"AndFilter(filters={self.filters})"
43
+
44
+ def __repr__(self) -> str:
45
+ return f"AndFilter(filters={self.filters!r})"
@@ -11,7 +11,7 @@ class CampaignFilter(RapidataFilter):
11
11
  Can be used to filter who to target based on campaign IDs.
12
12
 
13
13
  This filter can only be used when directly in contact with Rapidata.
14
-
14
+
15
15
  Args:
16
16
  campaign_ids (list[str]): List of campaign IDs to filter by.
17
17
  """
@@ -24,3 +24,9 @@ class CampaignFilter(RapidataFilter):
24
24
  _t="CampaignFilter",
25
25
  campaignIds=self.campaign_ids,
26
26
  )
27
+
28
+ def __str__(self) -> str:
29
+ return f"CampaignFilter(campaign_ids={self.campaign_ids})"
30
+
31
+ def __repr__(self) -> str:
32
+ return f"CampaignFilter(campaign_ids={self.campaign_ids!r})"
@@ -7,7 +7,7 @@ class CountryFilter(RapidataFilter):
7
7
  """CountryFilter Class
8
8
 
9
9
  Can be used to filter who to target based on country codes.
10
-
10
+
11
11
  Args:
12
12
  country_codes (list[str]): List of country codes (capitalized) to filter by.
13
13
  """
@@ -16,7 +16,7 @@ class CountryFilter(RapidataFilter):
16
16
  # check that all characters in the country codes are uppercase
17
17
  if not isinstance(country_codes, list):
18
18
  raise ValueError("Country codes must be a list")
19
-
19
+
20
20
  if not all([code.isupper() for code in country_codes]):
21
21
  raise ValueError("Country codes must be uppercase")
22
22
 
@@ -24,3 +24,9 @@ class CountryFilter(RapidataFilter):
24
24
 
25
25
  def _to_model(self):
26
26
  return CountryUserFilterModel(_t="CountryFilter", countries=self.country_codes)
27
+
28
+ def __str__(self) -> str:
29
+ return f"CountryFilter(country_codes={self.country_codes})"
30
+
31
+ def __repr__(self) -> str:
32
+ return f"CountryFilter(country_codes={self.country_codes!r})"
@@ -8,10 +8,10 @@ class CustomFilter(RapidataFilter):
8
8
 
9
9
  Can be used to filter who to target based on custom filters.
10
10
 
11
- Ought to be used with contact to Rapidata.
12
-
11
+ Ought to be used with contact to Rapidata.
12
+
13
13
  Warning: If identifier does not exist, order will not get any responses.
14
-
14
+
15
15
  Args:
16
16
  identifier (str): Identifier of the custom filter.
17
17
  values (list[str]): List of values to filter by.
@@ -27,3 +27,9 @@ class CustomFilter(RapidataFilter):
27
27
  identifier=self.identifier,
28
28
  values=self.values,
29
29
  )
30
+
31
+ def __str__(self) -> str:
32
+ return f"CustomFilter(identifier={self.identifier}, values={self.values})"
33
+
34
+ def __repr__(self) -> str:
35
+ return f"CustomFilter(identifier={self.identifier!r}, values={self.values!r})"
@@ -6,10 +6,10 @@ from rapidata.rapidata_client.filter.models.gender import Gender
6
6
 
7
7
  class GenderFilter(RapidataFilter):
8
8
  """GenderFilter Class
9
-
9
+
10
10
  Can be used to filter who to target based on their gender.
11
-
12
-
11
+
12
+
13
13
  Args:
14
14
  genders (list[Gender]): List of genders to filter by."""
15
15
 
@@ -21,3 +21,9 @@ class GenderFilter(RapidataFilter):
21
21
  _t="GenderFilter",
22
22
  genders=[gender._to_backend_model() for gender in self.genders],
23
23
  )
24
+
25
+ def __str__(self) -> str:
26
+ return f"GenderFilter(genders={self.genders})"
27
+
28
+ def __repr__(self) -> str:
29
+ return f"GenderFilter(genders={self.genders!r})"
@@ -7,26 +7,27 @@ from rapidata.api_client.models.language_user_filter_model import (
7
7
 
8
8
  class LanguageFilter(RapidataFilter):
9
9
  """LanguageFilter Class
10
-
10
+
11
11
  Can be used to filter who to target based on language codes.
12
12
 
13
13
  Args:
14
14
  language_codes (list[str]): List of language codes to filter by.
15
-
16
- Example:
15
+
16
+ Example:
17
17
  ```python
18
18
  LanguageFilter(["en", "de"])
19
19
  ```
20
20
  This will limit the order to be shown to only people who have their phone set to english or german
21
21
  """
22
+
22
23
  def __init__(self, language_codes: list[str]):
23
24
  if not isinstance(language_codes, list):
24
25
  raise ValueError("Language codes must be a list")
25
-
26
+
26
27
  # check that all characters in the language codes are lowercase
27
28
  if not all([code.islower() for code in language_codes]):
28
29
  raise ValueError("Language codes must be lowercase")
29
-
30
+
30
31
  for code in language_codes:
31
32
  if not len(code) == 2:
32
33
  raise ValueError("Language codes must be two characters long")
@@ -35,3 +36,9 @@ class LanguageFilter(RapidataFilter):
35
36
 
36
37
  def _to_model(self):
37
38
  return LanguageUserFilterModel(_t="LanguageFilter", languages=self.languages)
39
+
40
+ def __str__(self):
41
+ return f"LanguageFilter({self.languages})"
42
+
43
+ def __repr__(self):
44
+ return f"LanguageFilter({self.languages})"
@@ -1,11 +1,12 @@
1
1
  from rapidata.api_client.models.age_group import AgeGroup as BackendAgeGroupModel
2
2
  from enum import Enum
3
3
 
4
+
4
5
  class AgeGroup(Enum):
5
6
  """AgeGroup Enum
6
-
7
+
7
8
  Represents the age group of a user. Used to filter who to target based on age groups.
8
-
9
+
9
10
  Attributes:
10
11
  UNDER_18 (AgeGroup): Represents the age group of users under 18.
11
12
  BETWEEN_18_29 (AgeGroup): Represents the age group of users between 18 and 29.
@@ -13,7 +14,7 @@ class AgeGroup(Enum):
13
14
  BETWEEN_40_49 (AgeGroup): Represents the age group of users between 40 and 49.
14
15
  BETWEEN_50_64 (AgeGroup): Represents the age group of users between 50 and 64.
15
16
  OVER_65 (AgeGroup): Represents the age group of users over 65."""
16
-
17
+
17
18
  UNDER_18 = BackendAgeGroupModel.ENUM_0_MINUS_17
18
19
  BETWEEN_18_29 = BackendAgeGroupModel.ENUM_18_MINUS_29
19
20
  BETWEEN_30_39 = BackendAgeGroupModel.ENUM_30_MINUS_39
@@ -23,4 +24,3 @@ class AgeGroup(Enum):
23
24
 
24
25
  def _to_backend_model(self) -> BackendAgeGroupModel:
25
26
  return BackendAgeGroupModel(self.value)
26
-
@@ -1,16 +1,18 @@
1
1
  from enum import Enum
2
2
  from rapidata.api_client.models.gender import Gender as BackendGenderModel
3
3
 
4
+
4
5
  class Gender(Enum):
5
6
  """Gender Enum
6
-
7
+
7
8
  Represents the gender of a user. Used to filter who to target based on genders.
8
-
9
+
9
10
  Attributes:
10
11
  MALE (Gender): Represents the Male gender.
11
12
  FEMALE (Gender): Represents the Female gender.
12
13
  OTHER (Gender): Represents any other gender.
13
14
  """
15
+
14
16
  MALE = BackendGenderModel.MALE
15
17
  FEMALE = BackendGenderModel.FEMALE
16
18
  OTHER = BackendGenderModel.OTHER
@@ -1,13 +1,12 @@
1
1
  from rapidata.rapidata_client.filter._base_filter import RapidataFilter
2
2
  from rapidata.api_client.models.new_user_filter_model import NewUserFilterModel
3
3
 
4
+
4
5
  class NewUserFilter(RapidataFilter):
5
6
  """NewUserFilter Class
6
-
7
+
7
8
  Can be used to filter new users.
8
9
  """
9
10
 
10
11
  def _to_model(self):
11
- return NewUserFilterModel(
12
- _t="NewUserFilter"
13
- )
12
+ return NewUserFilterModel(_t="NewUserFilter")
@@ -1,7 +1,9 @@
1
1
  from typing import Any
2
2
  from rapidata.rapidata_client.filter._base_filter import RapidataFilter
3
3
  from rapidata.api_client.models.not_user_filter_model import NotUserFilterModel
4
- from rapidata.api_client.models.and_user_filter_model_filters_inner import AndUserFilterModelFiltersInner
4
+ from rapidata.api_client.models.and_user_filter_model_filters_inner import (
5
+ AndUserFilterModelFiltersInner,
6
+ )
5
7
 
6
8
 
7
9
  class NotFilter(RapidataFilter):
@@ -10,21 +12,31 @@ class NotFilter(RapidataFilter):
10
12
 
11
13
  Args:
12
14
  filter (RapidataFilter): The filter whose condition should be negated.
13
-
15
+
14
16
  Example:
15
17
  ```python
16
18
  from rapidata import NotFilter, LanguageFilter
17
19
 
18
- NotFilter(LanguageFilter(["en"]))
20
+ NotFilter(LanguageFilter(["en"]))
19
21
  ```
20
22
 
21
23
  This will limit the order to be shown to only people who have their phone set to a language other than English.
22
24
  """
25
+
23
26
  def __init__(self, filter: RapidataFilter):
24
27
  if not isinstance(filter, RapidataFilter):
25
28
  raise ValueError("Filter must be a RapidataFilter object")
26
-
29
+
27
30
  self.filter = filter
28
31
 
29
32
  def _to_model(self):
30
- return NotUserFilterModel(_t="NotFilter", filter=AndUserFilterModelFiltersInner(self.filter._to_model()))
33
+ return NotUserFilterModel(
34
+ _t="NotFilter",
35
+ filter=AndUserFilterModelFiltersInner(self.filter._to_model()),
36
+ )
37
+
38
+ def __str__(self) -> str:
39
+ return f"NotFilter(filter={self.filter})"
40
+
41
+ def __repr__(self) -> str:
42
+ return f"NotFilter(filter={self.filter!r})"
@@ -1,7 +1,9 @@
1
1
  from typing import Any
2
2
  from rapidata.rapidata_client.filter._base_filter import RapidataFilter
3
3
  from rapidata.api_client.models.or_user_filter_model import OrUserFilterModel
4
- from rapidata.api_client.models.and_user_filter_model_filters_inner import AndUserFilterModelFiltersInner
4
+ from rapidata.api_client.models.and_user_filter_model_filters_inner import (
5
+ AndUserFilterModelFiltersInner,
6
+ )
5
7
 
6
8
 
7
9
  class OrFilter(RapidataFilter):
@@ -10,21 +12,34 @@ class OrFilter(RapidataFilter):
10
12
 
11
13
  Args:
12
14
  filters (list[RapidataFilter]): A list of filters to be combined with OR.
13
-
15
+
14
16
  Example:
15
17
  ```python
16
18
  from rapidata import OrFilter, LanguageFilter, CountryFilter
17
19
 
18
- OrFilter([LanguageFilter(["en"]), CountryFilter(["US"])])
20
+ OrFilter([LanguageFilter(["en"]), CountryFilter(["US"])])
19
21
  ```
20
22
 
21
23
  This will match users who either have their phone set to English OR are located in the United States.
22
24
  """
25
+
23
26
  def __init__(self, filters: list[RapidataFilter]):
24
27
  if not all(isinstance(filter, RapidataFilter) for filter in filters):
25
28
  raise ValueError("Filters must be a RapidataFilter object")
26
-
29
+
27
30
  self.filters = filters
28
31
 
29
32
  def _to_model(self):
30
- return OrUserFilterModel(_t="OrFilter", filters=[AndUserFilterModelFiltersInner(filter._to_model()) for filter in self.filters])
33
+ return OrUserFilterModel(
34
+ _t="OrFilter",
35
+ filters=[
36
+ AndUserFilterModelFiltersInner(filter._to_model())
37
+ for filter in self.filters
38
+ ],
39
+ )
40
+
41
+ def __str__(self) -> str:
42
+ return f"OrFilter(filters={self.filters})"
43
+
44
+ def __repr__(self) -> str:
45
+ return f"OrFilter(filters={self.filters!r})"
@@ -1,12 +1,14 @@
1
1
  from rapidata.rapidata_client.filter import (
2
- AgeFilter,
3
- CountryFilter,
4
- GenderFilter,
5
- LanguageFilter,
2
+ AgeFilter,
3
+ CountryFilter,
4
+ GenderFilter,
5
+ LanguageFilter,
6
6
  UserScoreFilter,
7
7
  NotFilter,
8
8
  OrFilter,
9
- AndFilter)
9
+ AndFilter,
10
+ )
11
+
10
12
 
11
13
  class RapidataFilters:
12
14
  """RapidataFilters Classes
@@ -15,9 +17,9 @@ class RapidataFilters:
15
17
 
16
18
  Note that adding multiple filters to the same order will result in a logical AND operation between the filters.
17
19
 
18
- Warning:
20
+ Warning:
19
21
  This might significantly slow down the number of responses you receive.
20
-
22
+
21
23
  Attributes:
22
24
  user_score (UserScoreFilter): Filters for users with a specific user score.
23
25
  age (AgeFilter): Filters for users with a specific age.
@@ -36,7 +38,7 @@ class RapidataFilters:
36
38
 
37
39
  This ensures the order is only shown to users in the US and Germany whose phones are set to English.
38
40
 
39
- Info:
41
+ Info:
40
42
  The OR, AND and NOT filter support the |, & and ~ operators respectively.
41
43
  The AND is additionally given by the elements in the list.
42
44
 
@@ -47,8 +49,9 @@ class RapidataFilters:
47
49
 
48
50
  This would return users who are not under 18 years old and are from the US or who are from Canada and whose phones are set to English.
49
51
  """
52
+
50
53
  user_score = UserScoreFilter
51
- age = AgeFilter
54
+ age = AgeFilter
52
55
  country = CountryFilter
53
56
  gender = GenderFilter
54
57
  language = LanguageFilter
@@ -49,3 +49,9 @@ class ResponseCountFilter(RapidataFilter):
49
49
  dimension=self.dimension,
50
50
  operator=self.operator,
51
51
  )
52
+
53
+ def __str__(self) -> str:
54
+ return f"ResponseCountFilter(response_count={self.response_count}, dimension={self.dimension}, operator={self.operator})"
55
+
56
+ def __repr__(self) -> str:
57
+ return f"ResponseCountFilter(response_count={self.response_count!r}, dimension={self.dimension!r}, operator={self.operator!r})"