rapidata 1.10.1__py3-none-any.whl → 2.0.0__py3-none-any.whl

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

Potentially problematic release.


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

Files changed (138) hide show
  1. rapidata/__init__.py +21 -17
  2. rapidata/api_client/__init__.py +15 -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 +15 -5
  10. rapidata/api_client/models/add_campaign_model.py +1 -3
  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/file_asset_model_metadata_inner.py +8 -22
  23. rapidata/api_client/models/get_classify_workflow_result_overview_result.py +144 -0
  24. rapidata/api_client/models/get_pipeline_by_id_result.py +13 -3
  25. rapidata/api_client/models/identity_read_bridge_token_get202_response.py +140 -0
  26. rapidata/api_client/models/not_available_yet_result.py +96 -0
  27. rapidata/api_client/models/online_pair_maker_config.py +98 -0
  28. rapidata/api_client/models/online_pair_maker_config_model.py +98 -0
  29. rapidata/api_client/models/online_pair_maker_information.py +100 -0
  30. rapidata/api_client/models/pipeline_id_workflow_put_request.py +140 -0
  31. rapidata/api_client/models/pre_arranged_pair_maker_config.py +100 -0
  32. rapidata/api_client/models/pre_arranged_pair_maker_config_model.py +96 -0
  33. rapidata/api_client/models/pre_arranged_pair_maker_information.py +102 -0
  34. rapidata/api_client/models/read_bridge_token_keys_result.py +11 -2
  35. rapidata/api_client/models/simple_workflow_config.py +7 -26
  36. rapidata/api_client/models/simple_workflow_config_model.py +4 -28
  37. rapidata/api_client/models/simple_workflow_get_result_overview_get200_response.py +16 -16
  38. rapidata/api_client/models/simple_workflow_model1.py +3 -3
  39. rapidata/api_client/models/update_campaign_model.py +99 -0
  40. rapidata/api_client/models/validation_import_post_request_blueprint.py +1 -1
  41. rapidata/api_client_README.md +20 -7
  42. rapidata/rapidata_client/__init__.py +18 -9
  43. rapidata/rapidata_client/assets/__init__.py +5 -4
  44. rapidata/rapidata_client/assets/{media_asset.py → _media_asset.py} +32 -11
  45. rapidata/rapidata_client/assets/{multi_asset.py → _multi_asset.py} +1 -1
  46. rapidata/rapidata_client/assets/{text_asset.py → _text_asset.py} +1 -1
  47. rapidata/rapidata_client/assets/data_type_enum.py +7 -0
  48. rapidata/rapidata_client/filter/__init__.py +1 -1
  49. rapidata/rapidata_client/filter/_base_filter.py +10 -0
  50. rapidata/rapidata_client/filter/age_filter.py +12 -5
  51. rapidata/rapidata_client/filter/campaign_filter.py +12 -3
  52. rapidata/rapidata_client/filter/country_filter.py +10 -3
  53. rapidata/rapidata_client/filter/gender_filter.py +12 -5
  54. rapidata/rapidata_client/filter/language_filter.py +14 -3
  55. rapidata/rapidata_client/filter/models/age_group.py +26 -0
  56. rapidata/rapidata_client/filter/models/gender.py +19 -0
  57. rapidata/rapidata_client/filter/rapidata_filters.py +31 -0
  58. rapidata/rapidata_client/filter/user_score_filter.py +20 -4
  59. rapidata/rapidata_client/metadata/__init__.py +5 -5
  60. rapidata/rapidata_client/metadata/{base_metadata.py → _base_metadata.py} +2 -1
  61. rapidata/rapidata_client/metadata/{private_text_metadata.py → _private_text_metadata.py} +2 -2
  62. rapidata/rapidata_client/metadata/{prompt_metadata.py → _prompt_metadata.py} +3 -2
  63. rapidata/rapidata_client/metadata/{public_text_metadata.py → _public_text_metadata.py} +2 -2
  64. rapidata/rapidata_client/metadata/{select_words_metadata.py → _select_words_metadata.py} +3 -2
  65. rapidata/rapidata_client/{dataset/rapidata_dataset.py → order/_rapidata_dataset.py} +7 -8
  66. rapidata/rapidata_client/order/_rapidata_order_builder.py +365 -0
  67. rapidata/rapidata_client/order/rapidata_order.py +49 -31
  68. rapidata/rapidata_client/order/rapidata_order_manager.py +461 -0
  69. rapidata/rapidata_client/rapidata_client.py +12 -201
  70. rapidata/rapidata_client/referee/__init__.py +3 -3
  71. rapidata/rapidata_client/referee/{base_referee.py → _base_referee.py} +3 -3
  72. rapidata/rapidata_client/referee/{early_stopping_referee.py → _early_stopping_referee.py} +14 -11
  73. rapidata/rapidata_client/referee/{naive_referee.py → _naive_referee.py} +9 -9
  74. rapidata/rapidata_client/selection/__init__.py +1 -1
  75. rapidata/rapidata_client/{filter/base_filter.py → selection/_base_selection.py} +2 -2
  76. rapidata/rapidata_client/selection/capped_selection.py +15 -5
  77. rapidata/rapidata_client/selection/conditional_validation_selection.py +17 -4
  78. rapidata/rapidata_client/selection/demographic_selection.py +18 -7
  79. rapidata/rapidata_client/selection/labeling_selection.py +10 -3
  80. rapidata/rapidata_client/selection/rapidata_selections.py +21 -0
  81. rapidata/rapidata_client/selection/validation_selection.py +11 -4
  82. rapidata/rapidata_client/settings/__init__.py +9 -2
  83. rapidata/rapidata_client/settings/_rapidata_setting.py +11 -0
  84. rapidata/rapidata_client/settings/alert_on_fast_response.py +21 -0
  85. rapidata/rapidata_client/settings/custom_setting.py +16 -0
  86. rapidata/rapidata_client/settings/free_text_minimum_characters.py +16 -0
  87. rapidata/rapidata_client/settings/models/__init__.py +1 -0
  88. rapidata/rapidata_client/settings/models/translation_behaviour_options.py +14 -0
  89. rapidata/rapidata_client/settings/no_shuffle.py +16 -0
  90. rapidata/rapidata_client/settings/play_video_until_the_end.py +16 -0
  91. rapidata/rapidata_client/settings/rapidata_settings.py +31 -0
  92. rapidata/rapidata_client/settings/translation_behaviour.py +18 -0
  93. rapidata/rapidata_client/validation/__init__.py +1 -0
  94. rapidata/rapidata_client/{dataset/validation_rapid_parts.py → validation/_validation_rapid_parts.py} +7 -6
  95. rapidata/rapidata_client/validation/_validation_set_builder.py +371 -0
  96. rapidata/rapidata_client/{dataset → validation}/rapidata_validation_set.py +54 -50
  97. rapidata/rapidata_client/validation/rapids/__init__.py +1 -0
  98. rapidata/rapidata_client/validation/rapids/box.py +17 -0
  99. rapidata/rapidata_client/validation/rapids/rapids.py +94 -0
  100. rapidata/rapidata_client/validation/rapids/rapids_manager.py +163 -0
  101. rapidata/rapidata_client/validation/validation_set_manager.py +335 -0
  102. rapidata/rapidata_client/workflow/__init__.py +8 -6
  103. rapidata/rapidata_client/workflow/_base_workflow.py +25 -0
  104. rapidata/rapidata_client/workflow/{classify_workflow.py → _classify_workflow.py} +6 -6
  105. rapidata/rapidata_client/workflow/{compare_workflow.py → _compare_workflow.py} +10 -16
  106. rapidata/rapidata_client/workflow/_draw_workflow.py +22 -0
  107. rapidata/rapidata_client/workflow/_evaluation_workflow.py +26 -0
  108. rapidata/rapidata_client/workflow/{free_text_workflow.py → _free_text_workflow.py} +10 -16
  109. rapidata/rapidata_client/workflow/_locate_workflow.py +22 -0
  110. rapidata/rapidata_client/workflow/{select_words_workflow.py → _select_words_workflow.py} +2 -8
  111. rapidata/service/credential_manager.py +11 -1
  112. rapidata/service/openapi_service.py +23 -4
  113. {rapidata-1.10.1.dist-info → rapidata-2.0.0.dist-info}/METADATA +2 -1
  114. {rapidata-1.10.1.dist-info → rapidata-2.0.0.dist-info}/RECORD +118 -94
  115. rapidata/constants.py +0 -1
  116. rapidata/rapidata_client/dataset/rapid_builders/__init__.py +0 -4
  117. rapidata/rapidata_client/dataset/rapid_builders/base_rapid_builder.py +0 -33
  118. rapidata/rapidata_client/dataset/rapid_builders/classify_rapid_builders.py +0 -166
  119. rapidata/rapidata_client/dataset/rapid_builders/compare_rapid_builders.py +0 -145
  120. rapidata/rapidata_client/dataset/rapid_builders/rapids.py +0 -33
  121. rapidata/rapidata_client/dataset/rapid_builders/select_words_rapid_builders.py +0 -124
  122. rapidata/rapidata_client/dataset/validation_set_builder.py +0 -336
  123. rapidata/rapidata_client/order/order_builder.py +0 -25
  124. rapidata/rapidata_client/order/rapidata_order_builder.py +0 -463
  125. rapidata/rapidata_client/selection/base_selection.py +0 -9
  126. rapidata/rapidata_client/settings/feature_flags.py +0 -125
  127. rapidata/rapidata_client/settings/settings.py +0 -124
  128. rapidata/rapidata_client/simple_builders/__init__.py +0 -0
  129. rapidata/rapidata_client/simple_builders/simple_classification_builders.py +0 -271
  130. rapidata/rapidata_client/simple_builders/simple_compare_builders.py +0 -267
  131. rapidata/rapidata_client/simple_builders/simple_free_text_builders.py +0 -192
  132. rapidata/rapidata_client/simple_builders/simple_select_words_builders.py +0 -196
  133. rapidata/rapidata_client/workflow/base_workflow.py +0 -42
  134. rapidata/rapidata_client/workflow/evaluation_workflow.py +0 -15
  135. /rapidata/rapidata_client/assets/{base_asset.py → _base_asset.py} +0 -0
  136. /rapidata/rapidata_client/{dataset → filter/models}/__init__.py +0 -0
  137. {rapidata-1.10.1.dist-info → rapidata-2.0.0.dist-info}/LICENSE +0 -0
  138. {rapidata-1.10.1.dist-info → rapidata-2.0.0.dist-info}/WHEEL +0 -0
@@ -17,11 +17,10 @@ import pprint
17
17
  import re # noqa: F401
18
18
  import json
19
19
 
20
- from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
21
- from typing import Any, ClassVar, Dict, List, Optional
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
21
+ from typing import Any, ClassVar, Dict, List
22
22
  from rapidata.api_client.models.compare_workflow_model1_referee import CompareWorkflowModel1Referee
23
- from rapidata.api_client.models.feature_flag import FeatureFlag
24
- from rapidata.api_client.models.simple_workflow_model1_blueprint import SimpleWorkflowModel1Blueprint
23
+ from rapidata.api_client.models.validation_import_post_request_blueprint import ValidationImportPostRequestBlueprint
25
24
  from typing import Optional, Set
26
25
  from typing_extensions import Self
27
26
 
@@ -31,12 +30,9 @@ class SimpleWorkflowConfig(BaseModel):
31
30
  """ # noqa: E501
32
31
  t: StrictStr = Field(description="Discriminator value for SimpleWorkflowConfig", alias="_t")
33
32
  referee: CompareWorkflowModel1Referee
34
- blueprint: SimpleWorkflowModel1Blueprint
33
+ blueprint: ValidationImportPostRequestBlueprint
35
34
  target_country_codes: List[StrictStr] = Field(alias="targetCountryCodes")
36
- feature_flags: Optional[List[FeatureFlag]] = Field(default=None, alias="featureFlags")
37
- priority: Optional[StrictStr] = None
38
- is_fallback: Optional[StrictBool] = Field(default=None, alias="isFallback")
39
- __properties: ClassVar[List[str]] = ["_t", "referee", "blueprint", "targetCountryCodes", "featureFlags", "priority", "isFallback"]
35
+ __properties: ClassVar[List[str]] = ["_t", "referee", "blueprint", "targetCountryCodes"]
40
36
 
41
37
  @field_validator('t')
42
38
  def t_validate_enum(cls, value):
@@ -90,18 +86,6 @@ class SimpleWorkflowConfig(BaseModel):
90
86
  # override the default output from pydantic by calling `to_dict()` of blueprint
91
87
  if self.blueprint:
92
88
  _dict['blueprint'] = self.blueprint.to_dict()
93
- # override the default output from pydantic by calling `to_dict()` of each item in feature_flags (list)
94
- _items = []
95
- if self.feature_flags:
96
- for _item_feature_flags in self.feature_flags:
97
- if _item_feature_flags:
98
- _items.append(_item_feature_flags.to_dict())
99
- _dict['featureFlags'] = _items
100
- # set to None if priority (nullable) is None
101
- # and model_fields_set contains the field
102
- if self.priority is None and "priority" in self.model_fields_set:
103
- _dict['priority'] = None
104
-
105
89
  return _dict
106
90
 
107
91
  @classmethod
@@ -116,11 +100,8 @@ class SimpleWorkflowConfig(BaseModel):
116
100
  _obj = cls.model_validate({
117
101
  "_t": obj.get("_t") if obj.get("_t") is not None else 'SimpleWorkflowConfig',
118
102
  "referee": CompareWorkflowModel1Referee.from_dict(obj["referee"]) if obj.get("referee") is not None else None,
119
- "blueprint": SimpleWorkflowModel1Blueprint.from_dict(obj["blueprint"]) if obj.get("blueprint") is not None else None,
120
- "targetCountryCodes": obj.get("targetCountryCodes"),
121
- "featureFlags": [FeatureFlag.from_dict(_item) for _item in obj["featureFlags"]] if obj.get("featureFlags") is not None else None,
122
- "priority": obj.get("priority"),
123
- "isFallback": obj.get("isFallback")
103
+ "blueprint": ValidationImportPostRequestBlueprint.from_dict(obj["blueprint"]) if obj.get("blueprint") is not None else None,
104
+ "targetCountryCodes": obj.get("targetCountryCodes")
124
105
  })
125
106
  return _obj
126
107
 
@@ -17,10 +17,9 @@ import pprint
17
17
  import re # noqa: F401
18
18
  import json
19
19
 
20
- from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
21
- from typing import Any, ClassVar, Dict, List, Optional
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
21
+ from typing import Any, ClassVar, Dict, List
22
22
  from rapidata.api_client.models.compare_workflow_model1_referee import CompareWorkflowModel1Referee
23
- from rapidata.api_client.models.feature_flag import FeatureFlag
24
23
  from rapidata.api_client.models.simple_workflow_config_model_blueprint import SimpleWorkflowConfigModelBlueprint
25
24
  from typing import Optional, Set
26
25
  from typing_extensions import Self
@@ -33,10 +32,7 @@ class SimpleWorkflowConfigModel(BaseModel):
33
32
  referee: CompareWorkflowModel1Referee
34
33
  blueprint: SimpleWorkflowConfigModelBlueprint
35
34
  target_country_codes: List[StrictStr] = Field(description="A list of country codes that this workflow is targeting.", alias="targetCountryCodes")
36
- feature_flags: Optional[List[FeatureFlag]] = Field(default=None, alias="featureFlags")
37
- priority: Optional[StrictStr] = None
38
- is_fallback: Optional[StrictBool] = Field(default=None, alias="isFallback")
39
- __properties: ClassVar[List[str]] = ["_t", "referee", "blueprint", "targetCountryCodes", "featureFlags", "priority", "isFallback"]
35
+ __properties: ClassVar[List[str]] = ["_t", "referee", "blueprint", "targetCountryCodes"]
40
36
 
41
37
  @field_validator('t')
42
38
  def t_validate_enum(cls, value):
@@ -90,23 +86,6 @@ class SimpleWorkflowConfigModel(BaseModel):
90
86
  # override the default output from pydantic by calling `to_dict()` of blueprint
91
87
  if self.blueprint:
92
88
  _dict['blueprint'] = self.blueprint.to_dict()
93
- # override the default output from pydantic by calling `to_dict()` of each item in feature_flags (list)
94
- _items = []
95
- if self.feature_flags:
96
- for _item_feature_flags in self.feature_flags:
97
- if _item_feature_flags:
98
- _items.append(_item_feature_flags.to_dict())
99
- _dict['featureFlags'] = _items
100
- # set to None if priority (nullable) is None
101
- # and model_fields_set contains the field
102
- if self.priority is None and "priority" in self.model_fields_set:
103
- _dict['priority'] = None
104
-
105
- # set to None if is_fallback (nullable) is None
106
- # and model_fields_set contains the field
107
- if self.is_fallback is None and "is_fallback" in self.model_fields_set:
108
- _dict['isFallback'] = None
109
-
110
89
  return _dict
111
90
 
112
91
  @classmethod
@@ -122,10 +101,7 @@ class SimpleWorkflowConfigModel(BaseModel):
122
101
  "_t": obj.get("_t") if obj.get("_t") is not None else 'SimpleWorkflowConfig',
123
102
  "referee": CompareWorkflowModel1Referee.from_dict(obj["referee"]) if obj.get("referee") is not None else None,
124
103
  "blueprint": SimpleWorkflowConfigModelBlueprint.from_dict(obj["blueprint"]) if obj.get("blueprint") is not None else None,
125
- "targetCountryCodes": obj.get("targetCountryCodes"),
126
- "featureFlags": [FeatureFlag.from_dict(_item) for _item in obj["featureFlags"]] if obj.get("featureFlags") is not None else None,
127
- "priority": obj.get("priority"),
128
- "isFallback": obj.get("isFallback")
104
+ "targetCountryCodes": obj.get("targetCountryCodes")
129
105
  })
130
106
  return _obj
131
107
 
@@ -17,24 +17,24 @@ import json
17
17
  import pprint
18
18
  from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
19
19
  from typing import Any, List, Optional
20
- from rapidata.api_client.models.get_attach_category_workflow_result_overview_result import GetAttachCategoryWorkflowResultOverviewResult
20
+ from rapidata.api_client.models.get_classify_workflow_result_overview_result import GetClassifyWorkflowResultOverviewResult
21
21
  from rapidata.api_client.models.get_simple_workflow_result_overview_result import GetSimpleWorkflowResultOverviewResult
22
22
  from pydantic import StrictStr, Field
23
23
  from typing import Union, List, Set, Optional, Dict
24
24
  from typing_extensions import Literal, Self
25
25
 
26
- SIMPLEWORKFLOWGETRESULTOVERVIEWGET200RESPONSE_ONE_OF_SCHEMAS = ["GetAttachCategoryWorkflowResultOverviewResult", "GetSimpleWorkflowResultOverviewResult"]
26
+ SIMPLEWORKFLOWGETRESULTOVERVIEWGET200RESPONSE_ONE_OF_SCHEMAS = ["GetClassifyWorkflowResultOverviewResult", "GetSimpleWorkflowResultOverviewResult"]
27
27
 
28
28
  class SimpleWorkflowGetResultOverviewGet200Response(BaseModel):
29
29
  """
30
30
  SimpleWorkflowGetResultOverviewGet200Response
31
31
  """
32
- # data type: GetAttachCategoryWorkflowResultOverviewResult
33
- oneof_schema_1_validator: Optional[GetAttachCategoryWorkflowResultOverviewResult] = None
32
+ # data type: GetClassifyWorkflowResultOverviewResult
33
+ oneof_schema_1_validator: Optional[GetClassifyWorkflowResultOverviewResult] = None
34
34
  # data type: GetSimpleWorkflowResultOverviewResult
35
35
  oneof_schema_2_validator: Optional[GetSimpleWorkflowResultOverviewResult] = None
36
- actual_instance: Optional[Union[GetAttachCategoryWorkflowResultOverviewResult, GetSimpleWorkflowResultOverviewResult]] = None
37
- one_of_schemas: Set[str] = { "GetAttachCategoryWorkflowResultOverviewResult", "GetSimpleWorkflowResultOverviewResult" }
36
+ actual_instance: Optional[Union[GetClassifyWorkflowResultOverviewResult, GetSimpleWorkflowResultOverviewResult]] = None
37
+ one_of_schemas: Set[str] = { "GetClassifyWorkflowResultOverviewResult", "GetSimpleWorkflowResultOverviewResult" }
38
38
 
39
39
  model_config = ConfigDict(
40
40
  validate_assignment=True,
@@ -57,9 +57,9 @@ class SimpleWorkflowGetResultOverviewGet200Response(BaseModel):
57
57
  instance = SimpleWorkflowGetResultOverviewGet200Response.model_construct()
58
58
  error_messages = []
59
59
  match = 0
60
- # validate data type: GetAttachCategoryWorkflowResultOverviewResult
61
- if not isinstance(v, GetAttachCategoryWorkflowResultOverviewResult):
62
- error_messages.append(f"Error! Input type `{type(v)}` is not `GetAttachCategoryWorkflowResultOverviewResult`")
60
+ # validate data type: GetClassifyWorkflowResultOverviewResult
61
+ if not isinstance(v, GetClassifyWorkflowResultOverviewResult):
62
+ error_messages.append(f"Error! Input type `{type(v)}` is not `GetClassifyWorkflowResultOverviewResult`")
63
63
  else:
64
64
  match += 1
65
65
  # validate data type: GetSimpleWorkflowResultOverviewResult
@@ -69,10 +69,10 @@ class SimpleWorkflowGetResultOverviewGet200Response(BaseModel):
69
69
  match += 1
70
70
  if match > 1:
71
71
  # more than 1 match
72
- raise ValueError("Multiple matches found when setting `actual_instance` in SimpleWorkflowGetResultOverviewGet200Response with oneOf schemas: GetAttachCategoryWorkflowResultOverviewResult, GetSimpleWorkflowResultOverviewResult. Details: " + ", ".join(error_messages))
72
+ raise ValueError("Multiple matches found when setting `actual_instance` in SimpleWorkflowGetResultOverviewGet200Response with oneOf schemas: GetClassifyWorkflowResultOverviewResult, GetSimpleWorkflowResultOverviewResult. Details: " + ", ".join(error_messages))
73
73
  elif match == 0:
74
74
  # no match
75
- raise ValueError("No match found when setting `actual_instance` in SimpleWorkflowGetResultOverviewGet200Response with oneOf schemas: GetAttachCategoryWorkflowResultOverviewResult, GetSimpleWorkflowResultOverviewResult. Details: " + ", ".join(error_messages))
75
+ raise ValueError("No match found when setting `actual_instance` in SimpleWorkflowGetResultOverviewGet200Response with oneOf schemas: GetClassifyWorkflowResultOverviewResult, GetSimpleWorkflowResultOverviewResult. Details: " + ", ".join(error_messages))
76
76
  else:
77
77
  return v
78
78
 
@@ -87,9 +87,9 @@ class SimpleWorkflowGetResultOverviewGet200Response(BaseModel):
87
87
  error_messages = []
88
88
  match = 0
89
89
 
90
- # deserialize data into GetAttachCategoryWorkflowResultOverviewResult
90
+ # deserialize data into GetClassifyWorkflowResultOverviewResult
91
91
  try:
92
- instance.actual_instance = GetAttachCategoryWorkflowResultOverviewResult.from_json(json_str)
92
+ instance.actual_instance = GetClassifyWorkflowResultOverviewResult.from_json(json_str)
93
93
  match += 1
94
94
  except (ValidationError, ValueError) as e:
95
95
  error_messages.append(str(e))
@@ -102,10 +102,10 @@ class SimpleWorkflowGetResultOverviewGet200Response(BaseModel):
102
102
 
103
103
  if match > 1:
104
104
  # more than 1 match
105
- raise ValueError("Multiple matches found when deserializing the JSON string into SimpleWorkflowGetResultOverviewGet200Response with oneOf schemas: GetAttachCategoryWorkflowResultOverviewResult, GetSimpleWorkflowResultOverviewResult. Details: " + ", ".join(error_messages))
105
+ raise ValueError("Multiple matches found when deserializing the JSON string into SimpleWorkflowGetResultOverviewGet200Response with oneOf schemas: GetClassifyWorkflowResultOverviewResult, GetSimpleWorkflowResultOverviewResult. Details: " + ", ".join(error_messages))
106
106
  elif match == 0:
107
107
  # no match
108
- raise ValueError("No match found when deserializing the JSON string into SimpleWorkflowGetResultOverviewGet200Response with oneOf schemas: GetAttachCategoryWorkflowResultOverviewResult, GetSimpleWorkflowResultOverviewResult. Details: " + ", ".join(error_messages))
108
+ raise ValueError("No match found when deserializing the JSON string into SimpleWorkflowGetResultOverviewGet200Response with oneOf schemas: GetClassifyWorkflowResultOverviewResult, GetSimpleWorkflowResultOverviewResult. Details: " + ", ".join(error_messages))
109
109
  else:
110
110
  return instance
111
111
 
@@ -119,7 +119,7 @@ class SimpleWorkflowGetResultOverviewGet200Response(BaseModel):
119
119
  else:
120
120
  return json.dumps(self.actual_instance)
121
121
 
122
- def to_dict(self) -> Optional[Union[Dict[str, Any], GetAttachCategoryWorkflowResultOverviewResult, GetSimpleWorkflowResultOverviewResult]]:
122
+ def to_dict(self) -> Optional[Union[Dict[str, Any], GetClassifyWorkflowResultOverviewResult, GetSimpleWorkflowResultOverviewResult]]:
123
123
  """Returns the dict representation of the actual instance"""
124
124
  if self.actual_instance is None:
125
125
  return None
@@ -20,7 +20,7 @@ import json
20
20
  from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
21
21
  from typing import Any, ClassVar, Dict, List, Optional
22
22
  from rapidata.api_client.models.compare_workflow_model1_referee import CompareWorkflowModel1Referee
23
- from rapidata.api_client.models.simple_workflow_model1_blueprint import SimpleWorkflowModel1Blueprint
23
+ from rapidata.api_client.models.validation_import_post_request_blueprint import ValidationImportPostRequestBlueprint
24
24
  from typing import Optional, Set
25
25
  from typing_extensions import Self
26
26
 
@@ -32,7 +32,7 @@ class SimpleWorkflowModel1(BaseModel):
32
32
  id: StrictStr
33
33
  dataset_id: Optional[StrictStr] = Field(alias="datasetId")
34
34
  state: StrictStr
35
- blueprint: SimpleWorkflowModel1Blueprint
35
+ blueprint: ValidationImportPostRequestBlueprint
36
36
  referee: CompareWorkflowModel1Referee
37
37
  name: StrictStr
38
38
  owner_mail: Optional[StrictStr] = Field(alias="ownerMail")
@@ -116,7 +116,7 @@ class SimpleWorkflowModel1(BaseModel):
116
116
  "id": obj.get("id"),
117
117
  "datasetId": obj.get("datasetId"),
118
118
  "state": obj.get("state"),
119
- "blueprint": SimpleWorkflowModel1Blueprint.from_dict(obj["blueprint"]) if obj.get("blueprint") is not None else None,
119
+ "blueprint": ValidationImportPostRequestBlueprint.from_dict(obj["blueprint"]) if obj.get("blueprint") is not None else None,
120
120
  "referee": CompareWorkflowModel1Referee.from_dict(obj["referee"]) if obj.get("referee") is not None else None,
121
121
  "name": obj.get("name"),
122
122
  "ownerMail": obj.get("ownerMail")
@@ -0,0 +1,99 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Rapidata.Dataset
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: v1
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class UpdateCampaignModel(BaseModel):
26
+ """
27
+ The model containing the new configuration for a campaign.
28
+ """ # noqa: E501
29
+ priority: Optional[StrictInt] = Field(description="A value above 0 indicating how much the campaign should be prioritized. The higher the value the more weight it will be given during campaign selection.")
30
+ feature_flags: Optional[Dict[str, StrictStr]] = Field(description="The feature flags to assign this campaign.", alias="featureFlags")
31
+ __properties: ClassVar[List[str]] = ["priority", "featureFlags"]
32
+
33
+ model_config = ConfigDict(
34
+ populate_by_name=True,
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+
40
+ def to_str(self) -> str:
41
+ """Returns the string representation of the model using alias"""
42
+ return pprint.pformat(self.model_dump(by_alias=True))
43
+
44
+ def to_json(self) -> str:
45
+ """Returns the JSON representation of the model using alias"""
46
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47
+ return json.dumps(self.to_dict())
48
+
49
+ @classmethod
50
+ def from_json(cls, json_str: str) -> Optional[Self]:
51
+ """Create an instance of UpdateCampaignModel from a JSON string"""
52
+ return cls.from_dict(json.loads(json_str))
53
+
54
+ def to_dict(self) -> Dict[str, Any]:
55
+ """Return the dictionary representation of the model using alias.
56
+
57
+ This has the following differences from calling pydantic's
58
+ `self.model_dump(by_alias=True)`:
59
+
60
+ * `None` is only added to the output dict for nullable fields that
61
+ were set at model initialization. Other fields with value `None`
62
+ are ignored.
63
+ """
64
+ excluded_fields: Set[str] = set([
65
+ ])
66
+
67
+ _dict = self.model_dump(
68
+ by_alias=True,
69
+ exclude=excluded_fields,
70
+ exclude_none=True,
71
+ )
72
+ # set to None if priority (nullable) is None
73
+ # and model_fields_set contains the field
74
+ if self.priority is None and "priority" in self.model_fields_set:
75
+ _dict['priority'] = None
76
+
77
+ # set to None if feature_flags (nullable) is None
78
+ # and model_fields_set contains the field
79
+ if self.feature_flags is None and "feature_flags" in self.model_fields_set:
80
+ _dict['featureFlags'] = None
81
+
82
+ return _dict
83
+
84
+ @classmethod
85
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
86
+ """Create an instance of UpdateCampaignModel from a dict"""
87
+ if obj is None:
88
+ return None
89
+
90
+ if not isinstance(obj, dict):
91
+ return cls.model_validate(obj)
92
+
93
+ _obj = cls.model_validate({
94
+ "priority": obj.get("priority"),
95
+ "featureFlags": obj.get("featureFlags")
96
+ })
97
+ return _obj
98
+
99
+
@@ -34,7 +34,7 @@ VALIDATIONIMPORTPOSTREQUESTBLUEPRINT_ONE_OF_SCHEMAS = ["AttachCategoryRapidBluep
34
34
 
35
35
  class ValidationImportPostRequestBlueprint(BaseModel):
36
36
  """
37
- The blueprint for the rapid to be created.
37
+ ValidationImportPostRequestBlueprint
38
38
  """
39
39
  # data type: TranscriptionRapidBlueprint
40
40
  oneof_schema_1_validator: Optional[TranscriptionRapidBlueprint] = None
@@ -117,9 +117,12 @@ Class | Method | HTTP request | Description
117
117
  *OrderApi* | [**order_unlock_post**](rapidata/api_client/docs/OrderApi.md#order_unlock_post) | **POST** /Order/Unlock | Unlocks a newly cloned order.
118
118
  *OrderApi* | [**order_update_access_put**](rapidata/api_client/docs/OrderApi.md#order_update_access_put) | **PUT** /Order/UpdateAccess | Updates whether an order is public or not.
119
119
  *OrderApi* | [**order_update_order_name_put**](rapidata/api_client/docs/OrderApi.md#order_update_order_name_put) | **PUT** /Order/UpdateOrderName | Updates the name of an order.
120
- *PipelineApi* | [**pipeline_add_campaign_patch**](rapidata/api_client/docs/PipelineApi.md#pipeline_add_campaign_patch) | **PATCH** /Pipeline/AddCampaign | Adds a campaign to a pipeline.
120
+ *PipelineApi* | [**pipeline_id_campaign_artifact_id_put**](rapidata/api_client/docs/PipelineApi.md#pipeline_id_campaign_artifact_id_put) | **PUT** /pipeline/{id}/campaign/{artifact-id} | Updates a specific campaign for a pipeline.
121
+ *PipelineApi* | [**pipeline_id_campaign_post**](rapidata/api_client/docs/PipelineApi.md#pipeline_id_campaign_post) | **POST** /pipeline/{id}/campaign | Adds a campaign to a pipeline.
122
+ *PipelineApi* | [**pipeline_id_campaign_put**](rapidata/api_client/docs/PipelineApi.md#pipeline_id_campaign_put) | **PUT** /pipeline/{id}/campaign | Updates the default campaign for a pipeline.
121
123
  *PipelineApi* | [**pipeline_id_get**](rapidata/api_client/docs/PipelineApi.md#pipeline_id_get) | **GET** /Pipeline/{id} | Gets a pipeline by its id.
122
- *PipelineApi* | [**pipeline_update_workflow_config_post**](rapidata/api_client/docs/PipelineApi.md#pipeline_update_workflow_config_post) | **POST** /Pipeline/UpdateWorkflowConfig | Updates the workflow configuration for a pipeline.
124
+ *PipelineApi* | [**pipeline_id_workflow_artifact_id_put**](rapidata/api_client/docs/PipelineApi.md#pipeline_id_workflow_artifact_id_put) | **PUT** /pipeline/{id}/workflow/{artifact-id} | Updates the workflow configuration for a pipeline.
125
+ *PipelineApi* | [**pipeline_id_workflow_put**](rapidata/api_client/docs/PipelineApi.md#pipeline_id_workflow_put) | **PUT** /pipeline/{id}/workflow | Updates the workflow configuration for a pipeline.
123
126
  *RapidApi* | [**rapid_add_user_guess_post**](rapidata/api_client/docs/RapidApi.md#rapid_add_user_guess_post) | **POST** /Rapid/AddUserGuess | Submits a user guess for a Rapid.
124
127
  *RapidApi* | [**rapid_create_demographic_rapid_post**](rapidata/api_client/docs/RapidApi.md#rapid_create_demographic_rapid_post) | **POST** /Rapid/CreateDemographicRapid | Creates a new Demographic Rapid.
125
128
  *RapidApi* | [**rapid_query_validation_rapids_get**](rapidata/api_client/docs/RapidApi.md#rapid_query_validation_rapids_get) | **GET** /Rapid/QueryValidationRapids | Queries the validation rapids for a specific validation set.
@@ -186,10 +189,14 @@ Class | Method | HTTP request | Description
186
189
  - [CompareTruth](rapidata/api_client/docs/CompareTruth.md)
187
190
  - [CompareWorkflowConfig](rapidata/api_client/docs/CompareWorkflowConfig.md)
188
191
  - [CompareWorkflowConfigModel](rapidata/api_client/docs/CompareWorkflowConfigModel.md)
192
+ - [CompareWorkflowConfigModelPairMakerConfig](rapidata/api_client/docs/CompareWorkflowConfigModelPairMakerConfig.md)
193
+ - [CompareWorkflowConfigPairMakerConfig](rapidata/api_client/docs/CompareWorkflowConfigPairMakerConfig.md)
189
194
  - [CompareWorkflowGetResultOverviewGet200Response](rapidata/api_client/docs/CompareWorkflowGetResultOverviewGet200Response.md)
190
195
  - [CompareWorkflowModel](rapidata/api_client/docs/CompareWorkflowModel.md)
191
196
  - [CompareWorkflowModel1](rapidata/api_client/docs/CompareWorkflowModel1.md)
197
+ - [CompareWorkflowModel1PairMakerInformation](rapidata/api_client/docs/CompareWorkflowModel1PairMakerInformation.md)
192
198
  - [CompareWorkflowModel1Referee](rapidata/api_client/docs/CompareWorkflowModel1Referee.md)
199
+ - [CompareWorkflowModelPairMakerConfig](rapidata/api_client/docs/CompareWorkflowModelPairMakerConfig.md)
193
200
  - [CompletedRapidModel](rapidata/api_client/docs/CompletedRapidModel.md)
194
201
  - [CompletedRapidModelAsset](rapidata/api_client/docs/CompletedRapidModelAsset.md)
195
202
  - [ConditionalValidationSelection](rapidata/api_client/docs/ConditionalValidationSelection.md)
@@ -230,7 +237,6 @@ Class | Method | HTTP request | Description
230
237
  - [DemographicSelection](rapidata/api_client/docs/DemographicSelection.md)
231
238
  - [EarlyStoppingRefereeModel](rapidata/api_client/docs/EarlyStoppingRefereeModel.md)
232
239
  - [EmptyValidationTruth](rapidata/api_client/docs/EmptyValidationTruth.md)
233
- - [ErrorType](rapidata/api_client/docs/ErrorType.md)
234
240
  - [EvaluationWorkflowConfig](rapidata/api_client/docs/EvaluationWorkflowConfig.md)
235
241
  - [EvaluationWorkflowModel](rapidata/api_client/docs/EvaluationWorkflowModel.md)
236
242
  - [FeatureFlag](rapidata/api_client/docs/FeatureFlag.md)
@@ -251,8 +257,8 @@ Class | Method | HTTP request | Description
251
257
  - [FreeTextResult](rapidata/api_client/docs/FreeTextResult.md)
252
258
  - [Gender](rapidata/api_client/docs/Gender.md)
253
259
  - [GenderUserFilterModel](rapidata/api_client/docs/GenderUserFilterModel.md)
254
- - [GetAttachCategoryWorkflowResultOverviewResult](rapidata/api_client/docs/GetAttachCategoryWorkflowResultOverviewResult.md)
255
260
  - [GetAvailableValidationSetsResult](rapidata/api_client/docs/GetAvailableValidationSetsResult.md)
261
+ - [GetClassifyWorkflowResultOverviewResult](rapidata/api_client/docs/GetClassifyWorkflowResultOverviewResult.md)
256
262
  - [GetCompareWorkflowResultOverviewResult](rapidata/api_client/docs/GetCompareWorkflowResultOverviewResult.md)
257
263
  - [GetCompareWorkflowResultOverviewSmallResult](rapidata/api_client/docs/GetCompareWorkflowResultOverviewSmallResult.md)
258
264
  - [GetDatapointsByDatasetIdResult](rapidata/api_client/docs/GetDatapointsByDatasetIdResult.md)
@@ -269,6 +275,7 @@ Class | Method | HTTP request | Description
269
275
  - [GetWorkflowProgressResult](rapidata/api_client/docs/GetWorkflowProgressResult.md)
270
276
  - [GetWorkflowResultOverviewResult](rapidata/api_client/docs/GetWorkflowResultOverviewResult.md)
271
277
  - [IWorkflowModelPagedResult](rapidata/api_client/docs/IWorkflowModelPagedResult.md)
278
+ - [IdentityReadBridgeTokenGet202Response](rapidata/api_client/docs/IdentityReadBridgeTokenGet202Response.md)
272
279
  - [ImageDimensionMetadata](rapidata/api_client/docs/ImageDimensionMetadata.md)
273
280
  - [ImageDimensionMetadataModel](rapidata/api_client/docs/ImageDimensionMetadataModel.md)
274
281
  - [ImportFromFileResult](rapidata/api_client/docs/ImportFromFileResult.md)
@@ -306,21 +313,29 @@ Class | Method | HTTP request | Description
306
313
  - [NamedEntityTruth](rapidata/api_client/docs/NamedEntityTruth.md)
307
314
  - [NeverEndingRefereeConfig](rapidata/api_client/docs/NeverEndingRefereeConfig.md)
308
315
  - [NewsletterModel](rapidata/api_client/docs/NewsletterModel.md)
316
+ - [NotAvailableYetResult](rapidata/api_client/docs/NotAvailableYetResult.md)
309
317
  - [NotStartedRapidModel](rapidata/api_client/docs/NotStartedRapidModel.md)
310
318
  - [NullAsset](rapidata/api_client/docs/NullAsset.md)
311
319
  - [NullAssetModel](rapidata/api_client/docs/NullAssetModel.md)
312
320
  - [NullAssetModel1](rapidata/api_client/docs/NullAssetModel1.md)
313
321
  - [NullAssetModel2](rapidata/api_client/docs/NullAssetModel2.md)
322
+ - [OnlinePairMakerConfig](rapidata/api_client/docs/OnlinePairMakerConfig.md)
323
+ - [OnlinePairMakerConfigModel](rapidata/api_client/docs/OnlinePairMakerConfigModel.md)
324
+ - [OnlinePairMakerInformation](rapidata/api_client/docs/OnlinePairMakerInformation.md)
314
325
  - [OrderModel](rapidata/api_client/docs/OrderModel.md)
315
326
  - [OrderModelPagedResult](rapidata/api_client/docs/OrderModelPagedResult.md)
316
327
  - [OrderState](rapidata/api_client/docs/OrderState.md)
317
328
  - [OriginalFilenameMetadata](rapidata/api_client/docs/OriginalFilenameMetadata.md)
318
329
  - [OriginalFilenameMetadataModel](rapidata/api_client/docs/OriginalFilenameMetadataModel.md)
319
330
  - [PageInfo](rapidata/api_client/docs/PageInfo.md)
331
+ - [PipelineIdWorkflowPutRequest](rapidata/api_client/docs/PipelineIdWorkflowPutRequest.md)
320
332
  - [PolygonPayload](rapidata/api_client/docs/PolygonPayload.md)
321
333
  - [PolygonRapidBlueprint](rapidata/api_client/docs/PolygonRapidBlueprint.md)
322
334
  - [PolygonResult](rapidata/api_client/docs/PolygonResult.md)
323
335
  - [PolygonTruth](rapidata/api_client/docs/PolygonTruth.md)
336
+ - [PreArrangedPairMakerConfig](rapidata/api_client/docs/PreArrangedPairMakerConfig.md)
337
+ - [PreArrangedPairMakerConfigModel](rapidata/api_client/docs/PreArrangedPairMakerConfigModel.md)
338
+ - [PreArrangedPairMakerInformation](rapidata/api_client/docs/PreArrangedPairMakerInformation.md)
324
339
  - [PrivateTextMetadataInput](rapidata/api_client/docs/PrivateTextMetadataInput.md)
325
340
  - [ProbabilisticAttachCategoryRefereeConfig](rapidata/api_client/docs/ProbabilisticAttachCategoryRefereeConfig.md)
326
341
  - [ProblemDetails](rapidata/api_client/docs/ProblemDetails.md)
@@ -354,7 +369,6 @@ Class | Method | HTTP request | Description
354
369
  - [SimpleWorkflowGetResultOverviewGet200Response](rapidata/api_client/docs/SimpleWorkflowGetResultOverviewGet200Response.md)
355
370
  - [SimpleWorkflowModel](rapidata/api_client/docs/SimpleWorkflowModel.md)
356
371
  - [SimpleWorkflowModel1](rapidata/api_client/docs/SimpleWorkflowModel1.md)
357
- - [SimpleWorkflowModel1Blueprint](rapidata/api_client/docs/SimpleWorkflowModel1Blueprint.md)
358
372
  - [SimpleWorkflowModelBlueprint](rapidata/api_client/docs/SimpleWorkflowModelBlueprint.md)
359
373
  - [SkipResult](rapidata/api_client/docs/SkipResult.md)
360
374
  - [SortCriterion](rapidata/api_client/docs/SortCriterion.md)
@@ -380,9 +394,8 @@ Class | Method | HTTP request | Description
380
394
  - [TranslatedString](rapidata/api_client/docs/TranslatedString.md)
381
395
  - [UnlockOrderResult](rapidata/api_client/docs/UnlockOrderResult.md)
382
396
  - [UpdateAccessModel](rapidata/api_client/docs/UpdateAccessModel.md)
397
+ - [UpdateCampaignModel](rapidata/api_client/docs/UpdateCampaignModel.md)
383
398
  - [UpdateOrderModel](rapidata/api_client/docs/UpdateOrderModel.md)
384
- - [UpdateWorkflowConfigRequest](rapidata/api_client/docs/UpdateWorkflowConfigRequest.md)
385
- - [UpdateWorkflowConfigRequestConfig](rapidata/api_client/docs/UpdateWorkflowConfigRequestConfig.md)
386
399
  - [UploadCocoResult](rapidata/api_client/docs/UploadCocoResult.md)
387
400
  - [UploadDatapointsResult](rapidata/api_client/docs/UploadDatapointsResult.md)
388
401
  - [UploadFilesFromS3BucketModel](rapidata/api_client/docs/UploadFilesFromS3BucketModel.md)
@@ -1,10 +1,4 @@
1
1
  from .rapidata_client import RapidataClient
2
- from .workflow import (
3
- ClassifyWorkflow,
4
- SelectWordsWorkflow,
5
- CompareWorkflow,
6
- FreeTextWorkflow,
7
- )
8
2
  from .selection import (
9
3
  DemographicSelection,
10
4
  LabelingSelection,
@@ -12,16 +6,29 @@ from .selection import (
12
6
  ConditionalValidationSelection,
13
7
  CappedSelection,
14
8
  )
15
- from .referee import NaiveReferee, EarlyStoppingReferee
16
9
  from .metadata import (
17
10
  PrivateTextMetadata,
18
11
  PublicTextMetadata,
19
12
  PromptMetadata,
20
13
  SelectWordsMetadata,
21
14
  )
22
- from .settings import Settings, FeatureFlags # remove FeatureFlags next major version
15
+ from .settings import (
16
+ RapidataSettings,
17
+ TranslationBehaviourOptions,
18
+ AlertOnFastResponse,
19
+ TranslationBehaviour,
20
+ FreeTextMinimumCharacters,
21
+ NoShuffle,
22
+ PlayVideoUntilTheEnd,
23
+ CustomSetting,
24
+ )
23
25
  from .country_codes import CountryCodes
24
- from .assets import MediaAsset, TextAsset, MultiAsset
26
+ from .assets import (
27
+ MediaAsset,
28
+ TextAsset,
29
+ MultiAsset,
30
+ RapidataDataTypes
31
+ )
25
32
  from .filter import (
26
33
  CountryFilter,
27
34
  LanguageFilter,
@@ -32,3 +39,5 @@ from .filter import (
32
39
  GenderFilter,
33
40
  Gender,
34
41
  )
42
+
43
+ from .validation import Box
@@ -2,7 +2,8 @@
2
2
 
3
3
  This package provides classes for different types of assets, including MediaAsset, TextAsset, and MultiAsset.
4
4
  """
5
- from .base_asset import BaseAsset
6
- from .media_asset import MediaAsset
7
- from .text_asset import TextAsset
8
- from .multi_asset import MultiAsset
5
+ from ._base_asset import BaseAsset
6
+ from ._media_asset import MediaAsset
7
+ from ._text_asset import TextAsset
8
+ from ._multi_asset import MultiAsset
9
+ from .data_type_enum import RapidataDataTypes
@@ -5,9 +5,10 @@ Defines the MediaAsset class for handling media file paths within assets.
5
5
 
6
6
  import os
7
7
  from io import BytesIO
8
- from rapidata.rapidata_client.assets.base_asset import BaseAsset
8
+ from rapidata.rapidata_client.assets._base_asset import BaseAsset
9
9
  import requests
10
10
  import re
11
+ from PIL import Image
11
12
 
12
13
  class MediaAsset(BaseAsset):
13
14
  """MediaAsset Class
@@ -41,32 +42,52 @@ class MediaAsset(BaseAsset):
41
42
  """
42
43
  if not isinstance(path, str):
43
44
  raise ValueError("Media must be a string, either a local file path or a URL")
44
-
45
+
45
46
  if re.match(r'^https?://', path):
46
- self.path = self._get_media_bytes(path)
47
+ self.path = self.__get_media_bytes(path)
47
48
  self.name = path.split('/')[-1]
48
- if not self.name.endswith(('.jpg', '.jpeg', '.png', '.gif', '.mp3', '.mp4', '.webp')):
49
- raise ValueError("Supported file types for custom names: jpg, jpeg, png, gif, mp3, mp4")
49
+ self.name = self.__check_name_ending(self.name)
50
50
  return
51
51
 
52
52
  if not os.path.exists(path):
53
53
  raise FileNotFoundError(f"File not found: {path}")
54
54
 
55
-
56
55
  self.path: str | bytes = path
57
56
  self.name = path
58
-
57
+
58
+ def get_image_dimension(self) -> tuple[int, int] | None:
59
+ """
60
+ Get the dimensions (width, height) of an image file.
61
+ Returns None for non-image files or if dimensions can't be determined.
62
+ """
63
+ if not any(self.name.lower().endswith(ext) for ext in ('.jpg', '.jpeg', '.png', '.gif', '.webp')):
64
+ return None
65
+
66
+ try:
67
+ if isinstance(self.path, bytes):
68
+ img = Image.open(BytesIO(self.path))
69
+ else:
70
+ img = Image.open(self.path)
71
+ return img.size
72
+ except Exception:
73
+ return None
74
+
59
75
  def set_custom_name(self, name: str) -> 'MediaAsset':
60
76
  """Set a custom name for the media asset (only works with URLs)."""
61
77
  if isinstance(self.path, bytes):
62
- if not name.endswith(('.jpg', '.jpeg', '.png', '.gif', '.mp3', '.mp4', '.webp')):
63
- raise ValueError("Supported file types for custom names: jpg, jpeg, png, gif, mp3, mp4")
64
- self.name = name
78
+ self.name = self.__check_name_ending(name)
65
79
  else:
66
80
  raise ValueError("Custom name can only be set for URLs.")
67
81
  return self
82
+
83
+ def __check_name_ending(self, name: str) -> str:
84
+ """Check if the media path is valid."""
85
+ if not name.endswith(('.jpg', '.jpeg', '.png', '.gif', '.mp3', '.mp4', '.webp')):
86
+ print("Warning: Supported file types: jpg, jpeg, png, gif, mp3, mp4. Image might not be displayed correctly.")
87
+ name = name + '.jpg'
88
+ return name
68
89
 
69
- def _get_media_bytes(self, url: str) -> bytes:
90
+ def __get_media_bytes(self, url: str) -> bytes:
70
91
  """
71
92
  Downloads media files from URL and validates type and duration.
72
93
 
@@ -3,7 +3,7 @@
3
3
  Defines the MultiAsset class for handling multiple BaseAsset instances.
4
4
  """
5
5
 
6
- from rapidata.rapidata_client.assets.base_asset import BaseAsset
6
+ from rapidata.rapidata_client.assets._base_asset import BaseAsset
7
7
  from rapidata.rapidata_client.assets import MediaAsset, TextAsset
8
8
  from typing import Iterator, Sequence
9
9
 
@@ -3,7 +3,7 @@
3
3
  Defines the TextAsset class for handling textual data within assets.
4
4
  """
5
5
 
6
- from rapidata.rapidata_client.assets.base_asset import BaseAsset
6
+ from rapidata.rapidata_client.assets._base_asset import BaseAsset
7
7
 
8
8
 
9
9
  class TextAsset(BaseAsset):
@@ -0,0 +1,7 @@
1
+ class RapidataDataTypes:
2
+ MEDIA = "media" # any form of image, video or audio
3
+ TEXT = "text"
4
+
5
+ @classmethod
6
+ def _possible_values(cls):
7
+ return [cls.MEDIA, cls.TEXT]
@@ -1,4 +1,4 @@
1
- from .base_filter import Filter
1
+ from ._base_filter import RapidataFilter
2
2
  from .age_filter import AgeFilter, AgeGroup
3
3
  from .campaign_filter import CampaignFilter
4
4
  from .country_filter import CountryFilter
@@ -0,0 +1,10 @@
1
+ from abc import abstractmethod
2
+ from typing import Any
3
+
4
+
5
+ class RapidataFilter:
6
+ """The base class for all Rapidata Filters."""
7
+
8
+ @abstractmethod
9
+ def _to_model(self) -> Any:
10
+ pass