rapidata 0.1.3__py3-none-any.whl → 0.1.6__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.
Files changed (225) hide show
  1. openapi/openapi-client/openapi_client/__init__.py +215 -0
  2. openapi/openapi-client/openapi_client/api/__init__.py +11 -0
  3. openapi/openapi-client/openapi_client/api/coco_api.py +619 -0
  4. openapi/openapi-client/openapi_client/api/datapoint_api.py +817 -0
  5. openapi/openapi-client/openapi_client/api/dataset_api.py +2290 -0
  6. openapi/openapi-client/openapi_client/api/identity_api.py +3181 -0
  7. openapi/openapi-client/openapi_client/api/newsletter_api.py +571 -0
  8. openapi/openapi-client/openapi_client/api/order_api.py +5390 -0
  9. openapi/openapi-client/openapi_client/api/validation_api.py +1670 -0
  10. openapi/openapi-client/openapi_client/api_client.py +797 -0
  11. openapi/openapi-client/openapi_client/api_response.py +21 -0
  12. openapi/openapi-client/openapi_client/configuration.py +479 -0
  13. openapi/openapi-client/openapi_client/exceptions.py +199 -0
  14. openapi/openapi-client/openapi_client/models/__init__.py +192 -0
  15. openapi/openapi-client/openapi_client/models/add_validation_rapid_model.py +116 -0
  16. openapi/openapi-client/openapi_client/models/add_validation_rapid_model_payload.py +238 -0
  17. openapi/openapi-client/openapi_client/models/add_validation_rapid_model_truth.py +238 -0
  18. openapi/openapi-client/openapi_client/models/admin_order_model.py +103 -0
  19. openapi/openapi-client/openapi_client/models/admin_order_model_paged_result.py +105 -0
  20. openapi/openapi-client/openapi_client/models/age_group.py +40 -0
  21. openapi/openapi-client/openapi_client/models/age_user_filter_model.py +97 -0
  22. openapi/openapi-client/openapi_client/models/aggregator_type.py +46 -0
  23. openapi/openapi-client/openapi_client/models/attach_category_rapid_blueprint.py +98 -0
  24. openapi/openapi-client/openapi_client/models/attach_category_truth.py +96 -0
  25. openapi/openapi-client/openapi_client/models/base_error.py +90 -0
  26. openapi/openapi-client/openapi_client/models/bounding_box_payload.py +96 -0
  27. openapi/openapi-client/openapi_client/models/bounding_box_rapid_blueprint.py +96 -0
  28. openapi/openapi-client/openapi_client/models/bounding_box_truth.py +102 -0
  29. openapi/openapi-client/openapi_client/models/box_shape.py +122 -0
  30. openapi/openapi-client/openapi_client/models/classification_metadata.py +110 -0
  31. openapi/openapi-client/openapi_client/models/classification_metadata_filter_config.py +96 -0
  32. openapi/openapi-client/openapi_client/models/classify_payload.py +98 -0
  33. openapi/openapi-client/openapi_client/models/clone_dataset_model.py +98 -0
  34. openapi/openapi-client/openapi_client/models/clone_order_model.py +89 -0
  35. openapi/openapi-client/openapi_client/models/clone_order_result.py +89 -0
  36. openapi/openapi-client/openapi_client/models/compare_payload.py +96 -0
  37. openapi/openapi-client/openapi_client/models/compare_rapid_blueprint.py +96 -0
  38. openapi/openapi-client/openapi_client/models/compare_truth.py +96 -0
  39. openapi/openapi-client/openapi_client/models/compare_workflow_config.py +143 -0
  40. openapi/openapi-client/openapi_client/models/compare_workflow_config_rapid_selection_configs_inner.py +210 -0
  41. openapi/openapi-client/openapi_client/models/compare_workflow_config_referee.py +154 -0
  42. openapi/openapi-client/openapi_client/models/compare_workflow_model.py +106 -0
  43. openapi/openapi-client/openapi_client/models/conditional_validation_rapid_selection_config.py +113 -0
  44. openapi/openapi-client/openapi_client/models/correlated_rapid_selection_config.py +98 -0
  45. openapi/openapi-client/openapi_client/models/count_classification_metadata_filter_config.py +94 -0
  46. openapi/openapi-client/openapi_client/models/count_metadata.py +110 -0
  47. openapi/openapi-client/openapi_client/models/country_user_filter_model.py +96 -0
  48. openapi/openapi-client/openapi_client/models/create_client_model.py +89 -0
  49. openapi/openapi-client/openapi_client/models/create_complex_order_model.py +95 -0
  50. openapi/openapi-client/openapi_client/models/create_complex_order_model_pipeline.py +126 -0
  51. openapi/openapi-client/openapi_client/models/create_complex_order_result.py +96 -0
  52. openapi/openapi-client/openapi_client/models/create_dataset_artifact_model.py +102 -0
  53. openapi/openapi-client/openapi_client/models/create_dataset_artifact_model_dataset.py +126 -0
  54. openapi/openapi-client/openapi_client/models/create_default_order_model.py +109 -0
  55. openapi/openapi-client/openapi_client/models/create_default_order_model_workflow_config.py +140 -0
  56. openapi/openapi-client/openapi_client/models/create_empty_validation_set_result.py +87 -0
  57. openapi/openapi-client/openapi_client/models/create_legacy_order_result.py +89 -0
  58. openapi/openapi-client/openapi_client/models/create_order_model.py +163 -0
  59. openapi/openapi-client/openapi_client/models/create_order_model_referee.py +126 -0
  60. openapi/openapi-client/openapi_client/models/create_order_model_selections_inner.py +154 -0
  61. openapi/openapi-client/openapi_client/models/create_order_model_user_filters_inner.py +154 -0
  62. openapi/openapi-client/openapi_client/models/create_order_model_workflow.py +140 -0
  63. openapi/openapi-client/openapi_client/models/create_order_result.py +96 -0
  64. openapi/openapi-client/openapi_client/models/create_simple_pipeline_model.py +116 -0
  65. openapi/openapi-client/openapi_client/models/create_simple_pipeline_model_artifacts_inner.py +126 -0
  66. openapi/openapi-client/openapi_client/models/create_simple_pipeline_model_pipeline_steps_inner.py +182 -0
  67. openapi/openapi-client/openapi_client/models/create_unsupported_order_model.py +91 -0
  68. openapi/openapi-client/openapi_client/models/customer_order_model.py +101 -0
  69. openapi/openapi-client/openapi_client/models/customer_order_model_paged_result.py +105 -0
  70. openapi/openapi-client/openapi_client/models/datapoint.py +121 -0
  71. openapi/openapi-client/openapi_client/models/datapoint_asset.py +170 -0
  72. openapi/openapi-client/openapi_client/models/datapoint_get_by_id_get200_response.py +126 -0
  73. openapi/openapi-client/openapi_client/models/datapoint_metadata_model.py +97 -0
  74. openapi/openapi-client/openapi_client/models/datapoint_metadata_model_metadata_inner.py +168 -0
  75. openapi/openapi-client/openapi_client/models/datapoint_model.py +95 -0
  76. openapi/openapi-client/openapi_client/models/datapoint_model_asset.py +170 -0
  77. openapi/openapi-client/openapi_client/models/dataset_evaluation_step_model.py +102 -0
  78. openapi/openapi-client/openapi_client/models/demographic_rapid_selection_config.py +96 -0
  79. openapi/openapi-client/openapi_client/models/demographic_selection.py +96 -0
  80. openapi/openapi-client/openapi_client/models/empty_validation_truth.py +94 -0
  81. openapi/openapi-client/openapi_client/models/error_type.py +40 -0
  82. openapi/openapi-client/openapi_client/models/feature_flag.py +89 -0
  83. openapi/openapi-client/openapi_client/models/feature_flag_model.py +89 -0
  84. openapi/openapi-client/openapi_client/models/feedback_model.py +94 -0
  85. openapi/openapi-client/openapi_client/models/file_asset.py +108 -0
  86. openapi/openapi-client/openapi_client/models/file_asset_metadata_inner.py +224 -0
  87. openapi/openapi-client/openapi_client/models/file_asset_model.py +108 -0
  88. openapi/openapi-client/openapi_client/models/filter.py +134 -0
  89. openapi/openapi-client/openapi_client/models/filter_operator.py +44 -0
  90. openapi/openapi-client/openapi_client/models/free_text_payload.py +96 -0
  91. openapi/openapi-client/openapi_client/models/free_text_rapid_blueprint.py +96 -0
  92. openapi/openapi-client/openapi_client/models/gender.py +38 -0
  93. openapi/openapi-client/openapi_client/models/gender_user_filter_model.py +97 -0
  94. openapi/openapi-client/openapi_client/models/get_available_validation_sets_result.py +95 -0
  95. openapi/openapi-client/openapi_client/models/get_datapoints_by_dataset_id_result.py +95 -0
  96. openapi/openapi-client/openapi_client/models/get_dataset_by_id_result.py +87 -0
  97. openapi/openapi-client/openapi_client/models/get_order_by_id_result.py +98 -0
  98. openapi/openapi-client/openapi_client/models/get_order_results_result.py +91 -0
  99. openapi/openapi-client/openapi_client/models/get_public_orders_result.py +95 -0
  100. openapi/openapi-client/openapi_client/models/get_workflow_config_result.py +91 -0
  101. openapi/openapi-client/openapi_client/models/get_workflow_config_result_workflow_config.py +140 -0
  102. openapi/openapi-client/openapi_client/models/image_dimension_metadata.py +112 -0
  103. openapi/openapi-client/openapi_client/models/import_from_file_result.py +87 -0
  104. openapi/openapi-client/openapi_client/models/import_validation_set_from_file_result.py +87 -0
  105. openapi/openapi-client/openapi_client/models/issue_auth_token_result.py +87 -0
  106. openapi/openapi-client/openapi_client/models/issue_client_auth_token_result.py +87 -0
  107. openapi/openapi-client/openapi_client/models/labeling_selection.py +96 -0
  108. openapi/openapi-client/openapi_client/models/line_payload.py +96 -0
  109. openapi/openapi-client/openapi_client/models/line_rapid_blueprint.py +96 -0
  110. openapi/openapi-client/openapi_client/models/line_truth.py +94 -0
  111. openapi/openapi-client/openapi_client/models/locate_box_truth.py +104 -0
  112. openapi/openapi-client/openapi_client/models/locate_payload.py +96 -0
  113. openapi/openapi-client/openapi_client/models/locate_rapid_blueprint.py +96 -0
  114. openapi/openapi-client/openapi_client/models/location_metadata.py +112 -0
  115. openapi/openapi-client/openapi_client/models/location_metadata_exists_filter_config.py +94 -0
  116. openapi/openapi-client/openapi_client/models/logic_operator.py +37 -0
  117. openapi/openapi-client/openapi_client/models/login_model.py +89 -0
  118. openapi/openapi-client/openapi_client/models/metadata_visibilities.py +40 -0
  119. openapi/openapi-client/openapi_client/models/multi_asset.py +116 -0
  120. openapi/openapi-client/openapi_client/models/multi_asset_model.py +118 -0
  121. openapi/openapi-client/openapi_client/models/naive_referee_config.py +96 -0
  122. openapi/openapi-client/openapi_client/models/naive_referee_model.py +96 -0
  123. openapi/openapi-client/openapi_client/models/named_classification.py +100 -0
  124. openapi/openapi-client/openapi_client/models/named_entity_payload.py +98 -0
  125. openapi/openapi-client/openapi_client/models/named_entity_rapid_blueprint.py +98 -0
  126. openapi/openapi-client/openapi_client/models/named_entity_truth.py +104 -0
  127. openapi/openapi-client/openapi_client/models/never_ending_referee_config.py +94 -0
  128. openapi/openapi-client/openapi_client/models/newsletter_model.py +89 -0
  129. openapi/openapi-client/openapi_client/models/no_validation_workflow_rapid_selection_config.py +101 -0
  130. openapi/openapi-client/openapi_client/models/null_asset.py +104 -0
  131. openapi/openapi-client/openapi_client/models/null_asset_model.py +106 -0
  132. openapi/openapi-client/openapi_client/models/only_validation_workflow_rapid_selection_config.py +96 -0
  133. openapi/openapi-client/openapi_client/models/order_model.py +91 -0
  134. openapi/openapi-client/openapi_client/models/order_query_get200_response.py +137 -0
  135. openapi/openapi-client/openapi_client/models/original_filename_metadata.py +110 -0
  136. openapi/openapi-client/openapi_client/models/page_info.py +94 -0
  137. openapi/openapi-client/openapi_client/models/polygon_payload.py +96 -0
  138. openapi/openapi-client/openapi_client/models/polygon_rapid_blueprint.py +96 -0
  139. openapi/openapi-client/openapi_client/models/polygon_truth.py +94 -0
  140. openapi/openapi-client/openapi_client/models/private_text_metadata_input.py +98 -0
  141. openapi/openapi-client/openapi_client/models/probabilistic_attach_category_referee_config.py +98 -0
  142. openapi/openapi-client/openapi_client/models/prompt_metadata.py +110 -0
  143. openapi/openapi-client/openapi_client/models/prompt_metadata_input.py +98 -0
  144. openapi/openapi-client/openapi_client/models/public_text_metadata_input.py +98 -0
  145. openapi/openapi-client/openapi_client/models/query_orders_model.py +112 -0
  146. openapi/openapi-client/openapi_client/models/query_validation_set_model.py +112 -0
  147. openapi/openapi-client/openapi_client/models/request_password_reset_command.py +98 -0
  148. openapi/openapi-client/openapi_client/models/root_filter.py +107 -0
  149. openapi/openapi-client/openapi_client/models/send_completion_mail_step_model.py +98 -0
  150. openapi/openapi-client/openapi_client/models/signup_customer_model.py +93 -0
  151. openapi/openapi-client/openapi_client/models/signup_shadow_customer_model.py +87 -0
  152. openapi/openapi-client/openapi_client/models/simple_workflow_config.py +137 -0
  153. openapi/openapi-client/openapi_client/models/simple_workflow_config_blueprint.py +238 -0
  154. openapi/openapi-client/openapi_client/models/simple_workflow_model.py +100 -0
  155. openapi/openapi-client/openapi_client/models/simple_workflow_model_blueprint.py +238 -0
  156. openapi/openapi-client/openapi_client/models/sort_criterion.py +96 -0
  157. openapi/openapi-client/openapi_client/models/sort_direction.py +37 -0
  158. openapi/openapi-client/openapi_client/models/static_rapid_selection_config.py +96 -0
  159. openapi/openapi-client/openapi_client/models/submit_coco_model.py +91 -0
  160. openapi/openapi-client/openapi_client/models/submit_coco_result.py +87 -0
  161. openapi/openapi-client/openapi_client/models/submit_password_reset_command.py +102 -0
  162. openapi/openapi-client/openapi_client/models/text_asset.py +106 -0
  163. openapi/openapi-client/openapi_client/models/text_asset_model.py +108 -0
  164. openapi/openapi-client/openapi_client/models/text_metadata.py +107 -0
  165. openapi/openapi-client/openapi_client/models/transcription_metadata.py +107 -0
  166. openapi/openapi-client/openapi_client/models/transcription_metadata_input.py +98 -0
  167. openapi/openapi-client/openapi_client/models/transcription_payload.py +106 -0
  168. openapi/openapi-client/openapi_client/models/transcription_rapid_blueprint.py +96 -0
  169. openapi/openapi-client/openapi_client/models/transcription_truth.py +106 -0
  170. openapi/openapi-client/openapi_client/models/transcription_word.py +89 -0
  171. openapi/openapi-client/openapi_client/models/unlock_order_result.py +87 -0
  172. openapi/openapi-client/openapi_client/models/update_access_model.py +87 -0
  173. openapi/openapi-client/openapi_client/models/update_order_model.py +87 -0
  174. openapi/openapi-client/openapi_client/models/update_workflow_config_model.py +100 -0
  175. openapi/openapi-client/openapi_client/models/update_workflow_config_model_workflow_config.py +140 -0
  176. openapi/openapi-client/openapi_client/models/upload_coco_result.py +91 -0
  177. openapi/openapi-client/openapi_client/models/upload_datapoints_result.py +97 -0
  178. openapi/openapi-client/openapi_client/models/upload_files_from_s3_bucket_model.py +116 -0
  179. openapi/openapi-client/openapi_client/models/upload_text_sources_to_dataset_model.py +89 -0
  180. openapi/openapi-client/openapi_client/models/validation_chance.py +91 -0
  181. openapi/openapi-client/openapi_client/models/validation_import_post_request_blueprint.py +238 -0
  182. openapi/openapi-client/openapi_client/models/validation_rapid_selection_config.py +98 -0
  183. openapi/openapi-client/openapi_client/models/validation_selection.py +98 -0
  184. openapi/openapi-client/openapi_client/models/validation_set.py +105 -0
  185. openapi/openapi-client/openapi_client/models/validation_set_overview_model.py +91 -0
  186. openapi/openapi-client/openapi_client/models/validation_set_paged_result.py +105 -0
  187. openapi/openapi-client/openapi_client/models/workflow_aggregation_step_model.py +112 -0
  188. openapi/openapi-client/openapi_client/models/workflow_labeling_step_model.py +96 -0
  189. openapi/openapi-client/openapi_client/models/workflow_split_model.py +110 -0
  190. openapi/openapi-client/openapi_client/models/workflow_split_model_filter_configs_inner.py +154 -0
  191. openapi/openapi-client/openapi_client/rest.py +257 -0
  192. rapidata/rapidata_client/{workflow/feature_flags → feature_flags}/feature_flags.py +5 -3
  193. rapidata/rapidata_client/metadata/__init__.py +0 -0
  194. rapidata/rapidata_client/metadata/base_metadata.py +12 -0
  195. rapidata/rapidata_client/metadata/transcription_metadata.py +19 -0
  196. rapidata/rapidata_client/order/dataset/rapidata_dataset.py +42 -16
  197. rapidata/rapidata_client/order/dataset/validation_set_builder.py +187 -0
  198. rapidata/rapidata_client/order/rapidata_order.py +49 -23
  199. rapidata/rapidata_client/order/rapidata_order_builder.py +126 -8
  200. rapidata/rapidata_client/rapidata_client.py +17 -5
  201. rapidata/rapidata_client/{workflow/referee → referee}/base_referee.py +8 -2
  202. rapidata/rapidata_client/{workflow/referee → referee}/classify_early_stopping_referee.py +1 -1
  203. rapidata/rapidata_client/{workflow/referee → referee}/naive_referee.py +5 -1
  204. rapidata/rapidata_client/workflow/__init__.py +0 -2
  205. rapidata/rapidata_client/workflow/base_workflow.py +9 -5
  206. rapidata/rapidata_client/workflow/classify_workflow.py +18 -3
  207. rapidata/rapidata_client/workflow/compare_workflow.py +13 -14
  208. rapidata/rapidata_client/workflow/free_text_workflow.py +14 -0
  209. rapidata/rapidata_client/workflow/transcription_workflow.py +22 -0
  210. rapidata/service/__init__.py +0 -1
  211. rapidata/service/openapi_service.py +43 -0
  212. {rapidata-0.1.3.dist-info → rapidata-0.1.6.dist-info}/METADATA +2 -2
  213. rapidata-0.1.6.dist-info/RECORD +227 -0
  214. rapidata/service/rapidata_api_services/base_service.py +0 -76
  215. rapidata/service/rapidata_api_services/dataset_service.py +0 -82
  216. rapidata/service/rapidata_api_services/order_service.py +0 -49
  217. rapidata/service/rapidata_api_services/rapidata_service.py +0 -18
  218. rapidata-0.1.3.dist-info/RECORD +0 -34
  219. /rapidata/service/rapidata_api_services/__init__.py → /openapi/openapi-client/openapi_client/py.typed +0 -0
  220. /rapidata/rapidata_client/{workflow/country_codes → country_codes}/__init__.py +0 -0
  221. /rapidata/rapidata_client/{workflow/country_codes → country_codes}/country_codes.py +0 -0
  222. /rapidata/rapidata_client/{workflow/feature_flags → feature_flags}/__init__.py +0 -0
  223. /rapidata/rapidata_client/{workflow/referee → referee}/__init__.py +0 -0
  224. {rapidata-0.1.3.dist-info → rapidata-0.1.6.dist-info}/LICENSE +0 -0
  225. {rapidata-0.1.3.dist-info → rapidata-0.1.6.dist-info}/WHEEL +0 -0
@@ -0,0 +1,187 @@
1
+ from dataclasses import dataclass
2
+ import os
3
+ from typing import Any, Union
4
+ from openapi_client.models.add_validation_rapid_model import AddValidationRapidModel
5
+ from openapi_client.models.add_validation_rapid_model_payload import (
6
+ AddValidationRapidModelPayload,
7
+ )
8
+ from openapi_client.models.add_validation_rapid_model_truth import (
9
+ AddValidationRapidModelTruth,
10
+ )
11
+ from openapi_client.models.attach_category_truth import AttachCategoryTruth
12
+ from openapi_client.models.bounding_box_payload import BoundingBoxPayload
13
+ from openapi_client.models.bounding_box_truth import BoundingBoxTruth
14
+ from openapi_client.models.classify_payload import ClassifyPayload
15
+ from openapi_client.models.compare_payload import ComparePayload
16
+ from openapi_client.models.compare_truth import CompareTruth
17
+ from openapi_client.models.empty_validation_truth import EmptyValidationTruth
18
+ from openapi_client.models.free_text_payload import FreeTextPayload
19
+ from openapi_client.models.line_payload import LinePayload
20
+ from openapi_client.models.line_truth import LineTruth
21
+ from openapi_client.models.locate_box_truth import LocateBoxTruth
22
+ from openapi_client.models.locate_payload import LocatePayload
23
+ from openapi_client.models.named_entity_payload import NamedEntityPayload
24
+ from openapi_client.models.named_entity_truth import NamedEntityTruth
25
+ from openapi_client.models.polygon_payload import PolygonPayload
26
+ from openapi_client.models.polygon_truth import PolygonTruth
27
+ from openapi_client.models.transcription_payload import TranscriptionPayload
28
+ from openapi_client.models.transcription_truth import TranscriptionTruth
29
+ from openapi_client.models.transcription_word import TranscriptionWord
30
+ from rapidata.service.openapi_service import OpenAPIService
31
+
32
+
33
+ @dataclass
34
+ class ValidatioRapidParts:
35
+ question: str
36
+ media_paths: str | list[str]
37
+ payload: Union[
38
+ BoundingBoxPayload,
39
+ ClassifyPayload,
40
+ ComparePayload,
41
+ FreeTextPayload,
42
+ LinePayload,
43
+ LocatePayload,
44
+ NamedEntityPayload,
45
+ PolygonPayload,
46
+ TranscriptionPayload,
47
+ ]
48
+ truths: Union[
49
+ AttachCategoryTruth,
50
+ BoundingBoxTruth,
51
+ CompareTruth,
52
+ EmptyValidationTruth,
53
+ LineTruth,
54
+ LocateBoxTruth,
55
+ NamedEntityTruth,
56
+ PolygonTruth,
57
+ TranscriptionTruth,
58
+ ]
59
+ metadata: Any
60
+ randomCorrectProbability: float
61
+
62
+
63
+ class ValidationSetBuilder:
64
+
65
+ def __init__(self, name: str, openapi_service: OpenAPIService):
66
+ self.name = name
67
+ self.openapi_service = openapi_service
68
+ self.validation_set_id: str | None = None
69
+ self._rapid_parts: list[ValidatioRapidParts] = []
70
+
71
+ def create(self):
72
+ result = (
73
+ self.openapi_service.validation_api.validation_create_validation_set_post(
74
+ name=self.name
75
+ )
76
+ )
77
+ self.validation_set_id = result.validation_set_id
78
+
79
+ if self.validation_set_id is None:
80
+ raise ValueError("Failed to create validation set")
81
+
82
+ for rapid_part in self._rapid_parts:
83
+ model = AddValidationRapidModel(
84
+ validationSetId=self.validation_set_id,
85
+ payload=AddValidationRapidModelPayload(rapid_part.payload),
86
+ truth=AddValidationRapidModelTruth(rapid_part.truths),
87
+ metadata=rapid_part.metadata or [],
88
+ randomCorrectProbability=rapid_part.randomCorrectProbability,
89
+ )
90
+
91
+ self.openapi_service.validation_api.validation_add_validation_rapid_post(
92
+ model=model, files=rapid_part.media_paths if isinstance(rapid_part.media_paths, list) else [rapid_part.media_paths] # type: ignore
93
+ )
94
+
95
+ return str(self.validation_set_id)
96
+
97
+ def add_classify_rapid(
98
+ self, media_path: str, question: str, categories: list[str], truths: list[str]
99
+ ):
100
+ payload = ClassifyPayload(
101
+ _t="ClassifyPaylod", possibleCategories=categories, title=question
102
+ )
103
+ model_truth = AttachCategoryTruth(
104
+ correctCategories=truths, _t="AttachCategoryTruth"
105
+ )
106
+
107
+ self._rapid_parts.append(
108
+ ValidatioRapidParts(
109
+ question=question,
110
+ media_paths=media_path,
111
+ payload=payload,
112
+ truths=model_truth,
113
+ metadata=None,
114
+ randomCorrectProbability=len(truths) / len(categories),
115
+ )
116
+ )
117
+
118
+ return self
119
+
120
+ def add_compare_rapid(self, media_paths: list[str], question: str, truth: str):
121
+ payload = ComparePayload(_t="ComparePayload", criteria=question)
122
+ model_truth = CompareTruth(_t="CompareTruth", winnerId=truth)
123
+
124
+ if len(media_paths) != 2:
125
+ raise ValueError("Compare rapid requires exactly two media paths")
126
+
127
+ # check that files exist
128
+ for media_path in media_paths:
129
+ if not os.path.exists(media_path):
130
+ raise FileNotFoundError(f"File not found: {media_path}")
131
+
132
+ self._rapid_parts.append(
133
+ ValidatioRapidParts(
134
+ question=question,
135
+ media_paths=media_paths,
136
+ payload=payload,
137
+ truths=model_truth,
138
+ metadata=None,
139
+ randomCorrectProbability=1 / len(media_paths),
140
+ )
141
+ )
142
+
143
+ return self
144
+
145
+ def add_transcription_rapid(
146
+ self,
147
+ media_path: str,
148
+ question: str,
149
+ transcription: list[str],
150
+ correct_words: list[str],
151
+ strict_grading: bool | None = None,
152
+ ):
153
+ transcription_words = [
154
+ TranscriptionWord(word=word, wordIndex=i)
155
+ for i, word in enumerate(transcription)
156
+ ]
157
+
158
+ correct_transcription_words = []
159
+ for word in correct_words:
160
+ if word not in transcription:
161
+ raise ValueError(f"Correct word '{word}' not found in transcription")
162
+ correct_transcription_words.append(
163
+ TranscriptionWord(word=word, wordIndex=transcription.index(word))
164
+ )
165
+
166
+ payload = TranscriptionPayload(
167
+ _t="TranscriptionPayload", title=question, transcription=transcription_words
168
+ )
169
+
170
+ model_truth = TranscriptionTruth(
171
+ _t="TranscriptionTruth",
172
+ correctWords=correct_transcription_words,
173
+ strictGrading=strict_grading,
174
+ )
175
+
176
+ self._rapid_parts.append(
177
+ ValidatioRapidParts(
178
+ question=question,
179
+ media_paths=media_path,
180
+ payload=payload,
181
+ truths=model_truth,
182
+ metadata=None,
183
+ randomCorrectProbability=1 / len(transcription),
184
+ )
185
+ )
186
+
187
+ return self
@@ -1,6 +1,11 @@
1
+ import time
2
+ from openapi_client.models.create_order_model_referee import CreateOrderModelReferee
3
+ from openapi_client.models.create_order_model_workflow import CreateOrderModelWorkflow
1
4
  from rapidata.rapidata_client.order.dataset.rapidata_dataset import RapidataDataset
2
5
  from rapidata.rapidata_client.workflow import Workflow
3
- from rapidata.service import RapidataService
6
+ from openapi_client.models.create_order_model import CreateOrderModel
7
+ from rapidata.rapidata_client.referee import Referee
8
+ from rapidata.service.openapi_service import OpenAPIService
4
9
 
5
10
 
6
11
  class RapidataOrder:
@@ -16,13 +21,14 @@ class RapidataOrder:
16
21
  """
17
22
 
18
23
  def __init__(
19
- self, name: str, workflow: Workflow, rapidata_service: RapidataService
24
+ self,
25
+ order_id: str,
26
+ dataset: RapidataDataset,
27
+ openapi_service: OpenAPIService,
20
28
  ):
21
- self.name = name
22
- self.workflow = workflow
23
- self.rapidata_service = rapidata_service
24
- self.order_id = None
25
- self._dataset = None
29
+ self.openapi_service = openapi_service
30
+ self.order_id = order_id
31
+ self._dataset = dataset
26
32
 
27
33
  def create(self):
28
34
  """
@@ -31,41 +37,61 @@ class RapidataOrder:
31
37
  :return: The created RapidataOrder instance.
32
38
  :rtype: RapidataOrder
33
39
  """
34
- self.order_id, dataset_id = self.rapidata_service.order.create_order(self.name, self.workflow.to_dict())
35
- self._dataset = RapidataDataset(dataset_id, self.rapidata_service)
36
- return self
37
40
 
38
41
  def submit(self):
39
42
  """
40
43
  Submits the order for processing.
41
-
42
- :raises ValueError: If the order has not been created.
43
44
  """
44
- if self.order_id is None:
45
- raise ValueError("You must create the order before submitting it.")
46
45
 
47
- self.rapidata_service.order.submit(self.order_id)
46
+ self.openapi_service.order_api.order_submit_post(self.order_id)
48
47
 
49
48
  def approve(self):
50
49
  """
51
50
  Approves the order for execution.
51
+ """
52
+ self.openapi_service.order_api.order_approve_post(self.order_id)
53
+
54
+ def get_status(self):
55
+ """
56
+ Gets the status of the order.
57
+
58
+ :return: The status of the order.
59
+ :rtype: str
60
+ """
61
+ return self.openapi_service.order_api.order_get_by_id_get(self.order_id)
52
62
 
53
- :raises ValueError: If the order has not been created.
63
+ def wait_for_done(self):
54
64
  """
55
- if self.order_id is None:
56
- raise ValueError("You must create the order before approving it.")
65
+ Blocking call that waits for the order to be done. Exponential backoff is used to check the status of the order.
66
+ """
67
+ wait_time = 2
68
+ back_off_factor = 1.5
69
+ minimum_poll_interval = 60 * 10 # 10 minutes
70
+
71
+ while True:
72
+ time.sleep(wait_time)
73
+ result = self.get_status()
74
+ if result.state == "Completed":
75
+ break
76
+ wait_time = max(
77
+ minimum_poll_interval, wait_time * back_off_factor
78
+ ) # poll at least every 10 minutes
79
+
80
+ def get_results(self):
81
+ """
82
+ Gets the results of the order.
57
83
 
58
- self.rapidata_service.order.approve(self.order_id)
84
+ :return: The results of the order.
85
+ :rtype: dict
86
+ """
87
+ # return self.openapi_service.order_api.order_get_order_results_get(self.order_id) # throws error
88
+ raise NotImplementedError("Currently not supported")
59
89
 
60
90
  @property
61
91
  def dataset(self):
62
92
  """
63
93
  The dataset associated with the order.
64
-
65
- :raises ValueError: If the order has not been submitted.
66
94
  :return: The RapidataDataset instance.
67
95
  :rtype: RapidataDataset
68
96
  """
69
- if self._dataset is None:
70
- raise ValueError("You must submit the order before accessing the dataset.")
71
97
  return self._dataset
@@ -1,6 +1,15 @@
1
+ from openapi_client.models.aggregator_type import AggregatorType
2
+ from openapi_client.models.create_order_model import CreateOrderModel
3
+ from openapi_client.models.create_order_model_referee import CreateOrderModelReferee
4
+ from openapi_client.models.create_order_model_workflow import CreateOrderModelWorkflow
5
+ from rapidata.rapidata_client.feature_flags import FeatureFlags
6
+ from rapidata.rapidata_client.metadata.base_metadata import Metadata
7
+ from rapidata.rapidata_client.order.dataset.rapidata_dataset import RapidataDataset
8
+ from rapidata.rapidata_client.referee.naive_referee import NaiveReferee
1
9
  from rapidata.rapidata_client.workflow import Workflow
2
10
  from rapidata.rapidata_client.order.rapidata_order import RapidataOrder
3
- from rapidata.service import RapidataService
11
+ from rapidata.rapidata_client.referee import Referee
12
+ from rapidata.service.openapi_service import OpenAPIService
4
13
 
5
14
 
6
15
  class RapidataOrderBuilder:
@@ -17,16 +26,22 @@ class RapidataOrderBuilder:
17
26
 
18
27
  def __init__(
19
28
  self,
20
- rapidata_service: RapidataService,
29
+ openapi_service: OpenAPIService,
21
30
  name: str,
22
31
  ):
23
32
  self._name = name
24
- self._rapidata_service = rapidata_service
33
+ self._openapi_service = openapi_service
25
34
  self._workflow: Workflow | None = None
35
+ self._referee: Referee | None = None
36
+ self._media_paths: list[str] = []
37
+ self._metadata: list[Metadata] | None = None
38
+ self._aggregator: AggregatorType | None = None
39
+ self._validation_set_id: str | None = None
40
+ self._feature_flags: FeatureFlags | None = None
26
41
 
27
- def create(self) -> RapidataOrder:
42
+ def create(self, submit=True) -> RapidataOrder:
28
43
  """
29
- Create a RapidataOrder instance based on the configured settings.
44
+ Actually makes the API calls to create the order based on how the order builder was configures. Returns a RapidataOrder instance based on the created order with order_id and dataset_id.
30
45
 
31
46
  :return: The created RapidataOrder instance.
32
47
  :rtype: RapidataOrder
@@ -35,9 +50,33 @@ class RapidataOrderBuilder:
35
50
  if self._workflow is None:
36
51
  raise ValueError("You must provide a blueprint to create an order.")
37
52
 
38
- return RapidataOrder(
39
- name=self._name, workflow=self._workflow, rapidata_service=self._rapidata_service
40
- ).create()
53
+ if self._referee is None:
54
+ print("No referee provided, using default NaiveReferee.")
55
+ self._referee = NaiveReferee()
56
+
57
+ order_model = CreateOrderModel(
58
+ orderName=self._name,
59
+ workflow=CreateOrderModelWorkflow(self._workflow.to_model()),
60
+ userFilters=[],
61
+ referee=CreateOrderModelReferee(self._referee.to_model()),
62
+ validationSetId=self._validation_set_id,
63
+ featureFlags=self._feature_flags.to_list() if self._feature_flags is not None else None,
64
+ )
65
+
66
+ result = self._openapi_service.order_api.order_create_post(
67
+ create_order_model=order_model
68
+ )
69
+
70
+ self.order_id = result.order_id
71
+ self._dataset = RapidataDataset(result.dataset_id, self._openapi_service)
72
+ order = RapidataOrder(order_id=self.order_id, dataset=self._dataset, openapi_service=self._openapi_service)
73
+
74
+ order.dataset.add_media_from_paths(self._media_paths, self._metadata)
75
+
76
+ if submit:
77
+ order.submit()
78
+
79
+ return order
41
80
 
42
81
  def workflow(self, workflow: Workflow):
43
82
  """
@@ -50,3 +89,82 @@ class RapidataOrderBuilder:
50
89
  """
51
90
  self._workflow = workflow
52
91
  return self
92
+
93
+ def referee(self, referee: Referee):
94
+ """
95
+ Set the referee for the order.
96
+
97
+ :param referee: The referee to be set.
98
+ :type referee: Referee
99
+ :return: The updated RapidataOrderBuilder instance.
100
+ :rtype: RapidataOrderBuilder
101
+ """
102
+ self._referee = referee
103
+ return self
104
+
105
+ def media(
106
+ self, media_paths: list[str], metadata: list[Metadata] | None = None):
107
+ """
108
+ Set the media assets for the order.
109
+
110
+ :param media_paths: The paths of the media assets to be set.
111
+ :type media_paths: list[str]
112
+ :return: The updated RapidataOrderBuilder instance.
113
+ :rtype: RapidataOrderBuilder
114
+ """
115
+ self._media_paths = media_paths
116
+ self._metadata = metadata
117
+ return self
118
+
119
+ def feature_flags(self, feature_flags: FeatureFlags):
120
+ """
121
+ Set the feature flags for the order.
122
+
123
+ :param feature_flags: The feature flags to be set.
124
+ :type feature_flags: FeatureFlags
125
+ :return: The updated RapidataOrderBuilder instance.
126
+ :rtype: RapidataOrderBuilder
127
+ """
128
+ self._feature_flags = feature_flags
129
+ return self
130
+
131
+ def target_country_codes(self, country_codes: list[str]):
132
+ """
133
+ Set the target country codes for the order.
134
+
135
+ :param country_codes: The country codes to be set.
136
+ :type country_codes: list[str]
137
+ :return: The updated RapidataOrderBuilder instance.
138
+ :rtype: RapidataOrderBuilder
139
+ """
140
+ if self._workflow is None:
141
+ raise ValueError(
142
+ "You must set the workflow before setting the target country codes."
143
+ )
144
+
145
+ self._workflow.target_country_codes(country_codes)
146
+ return self
147
+
148
+ def aggregator(self, aggregator: AggregatorType):
149
+ """
150
+ Set the aggregator for the order.
151
+
152
+ :param aggregator: The aggregator to be set.
153
+ :type aggregator: AggregatorType
154
+ :return: The updated RapidataOrderBuilder instance.
155
+ :rtype: RapidataOrderBuilder
156
+ """
157
+ self._aggregator = aggregator
158
+ return self
159
+
160
+ def validation_set(self, validation_set_id: str):
161
+ """
162
+ Set the validation set for the order.
163
+
164
+ :param validation_set_id: The validation set ID to be set.
165
+ :type validation_set_id: str
166
+ :return: The updated RapidataOrderBuilder instance.
167
+ :rtype: RapidataOrderBuilder
168
+ """
169
+ self._validation_set_id = validation_set_id
170
+ return self
@@ -1,6 +1,6 @@
1
+ from rapidata.rapidata_client.order.dataset.validation_set_builder import ValidationSetBuilder
1
2
  from rapidata.rapidata_client.order.rapidata_order_builder import RapidataOrderBuilder
2
- from rapidata.service import RapidataService
3
-
3
+ from rapidata.service.openapi_service import OpenAPIService
4
4
 
5
5
  class RapidataClient:
6
6
  """
@@ -11,7 +11,7 @@ class RapidataClient:
11
11
  self,
12
12
  client_id: str,
13
13
  client_secret: str,
14
- endpoint: str = "https://api.rapidata.ai",
14
+ endpoint: str = "https://api.app.rapidata.ai",
15
15
  ):
16
16
  """
17
17
  Initialize the RapidataClient.
@@ -20,10 +20,12 @@ class RapidataClient:
20
20
  :param client_secret: The client secret for authentication.
21
21
  :param endpoint: The API endpoint URL. Defaults to "https://api.rapidata.ai".
22
22
  """
23
- self._rapidata_service = RapidataService(
23
+ self.openapi_service = OpenAPIService(
24
24
  client_id=client_id, client_secret=client_secret, endpoint=endpoint
25
25
  )
26
26
 
27
+
28
+
27
29
  def new_order(self, name: str) -> RapidataOrderBuilder:
28
30
  """
29
31
  Create a new order using a RapidataOrderBuilder instance.
@@ -31,4 +33,14 @@ class RapidataClient:
31
33
  :param name: The name of the order.
32
34
  :return: A RapidataOrderBuilder instance.
33
35
  """
34
- return RapidataOrderBuilder(rapidata_service=self._rapidata_service, name=name)
36
+ return RapidataOrderBuilder(openapi_service=self.openapi_service, name=name)
37
+
38
+
39
+ def new_validation_set(self, name: str) -> ValidationSetBuilder:
40
+ """
41
+ Create a new validation set using a ValidationDatasetBuilder instance.
42
+
43
+ :param name: The name of the validation set.
44
+ :return: A ValidationDatasetBuilder instance.
45
+ """
46
+ return ValidationSetBuilder(name=name, openapi_service=self.openapi_service)
@@ -1,6 +1,5 @@
1
1
  from abc import ABC, abstractmethod
2
- from typing import Mapping
3
-
2
+ from typing import Any, Mapping
4
3
 
5
4
  class Referee(ABC):
6
5
  """
@@ -11,4 +10,11 @@ class Referee(ABC):
11
10
  """
12
11
  Convert the referee to a referee configuration dict.
13
12
  """
13
+ pass
14
+
15
+ @abstractmethod
16
+ def to_model(self) -> Any:
17
+ """
18
+ Convert the referee to a referee configuration model.
19
+ """
14
20
  pass
@@ -1,4 +1,4 @@
1
- from rapidata.rapidata_client.workflow.referee.base_referee import Referee
1
+ from rapidata.rapidata_client.referee.base_referee import Referee
2
2
 
3
3
 
4
4
  class ClassifyEarlyStoppingReferee(Referee):
@@ -1,4 +1,5 @@
1
- from rapidata.rapidata_client.workflow.referee.base_referee import Referee
1
+ from openapi_client.models.naive_referee_model import NaiveRefereeModel
2
+ from rapidata.rapidata_client.referee.base_referee import Referee
2
3
 
3
4
 
4
5
  class NaiveReferee(Referee):
@@ -16,3 +17,6 @@ class NaiveReferee(Referee):
16
17
  "_t": "NaiveRefereeConfig",
17
18
  "guessesRequired": self.required_guesses,
18
19
  }
20
+
21
+ def to_model(self):
22
+ return NaiveRefereeModel(_t="NaiveReferee", totalVotes=self.required_guesses)
@@ -2,5 +2,3 @@ from .base_workflow import Workflow as Workflow
2
2
  from .classify_workflow import ClassifyWorkflow as ClassifyWorkflow
3
3
  from .compare_workflow import CompareWorkflow as CompareWorkflow
4
4
  from .free_text_workflow import FreeTextWorkflow as FreeTextWorkflow
5
- from .feature_flags import FeatureFlags as FeatureFlags
6
- from .country_codes import CountryCodes as CountryCodes
@@ -1,16 +1,16 @@
1
- from abc import ABC
1
+ from abc import ABC, abstractmethod
2
2
  from typing import Any
3
3
 
4
- from rapidata.rapidata_client.workflow.feature_flags import FeatureFlags
5
- from rapidata.rapidata_client.workflow.referee.base_referee import Referee
6
- from rapidata.rapidata_client.workflow.referee.naive_referee import NaiveReferee
4
+ from openapi_client.models.simple_workflow_model import SimpleWorkflowModel
5
+ from rapidata.rapidata_client.feature_flags import FeatureFlags
6
+ from rapidata.rapidata_client.referee.base_referee import Referee
7
+ from rapidata.rapidata_client.referee.naive_referee import NaiveReferee
7
8
 
8
9
 
9
10
  class Workflow(ABC):
10
11
 
11
12
  def __init__(self, type: str):
12
13
  self._type = type
13
- self._referee = NaiveReferee()
14
14
  self._target_country_codes: list[str] = []
15
15
  self._feature_flags: FeatureFlags = FeatureFlags()
16
16
 
@@ -21,6 +21,10 @@ class Workflow(ABC):
21
21
  "targetCountryCodes": self._target_country_codes,
22
22
  "featureFlags": self._feature_flags.to_list(),
23
23
  }
24
+
25
+ @abstractmethod
26
+ def to_model(self) -> SimpleWorkflowModel:
27
+ pass
24
28
 
25
29
  def referee(self, referee: Referee):
26
30
  self._referee = referee
@@ -1,12 +1,15 @@
1
1
  from typing import Any
2
+ from openapi_client.models.attach_category_rapid_blueprint import AttachCategoryRapidBlueprint
3
+ from openapi_client.models.simple_workflow_model import SimpleWorkflowModel
4
+ from openapi_client.models.simple_workflow_model_blueprint import SimpleWorkflowModelBlueprint
2
5
  from rapidata.rapidata_client.workflow import Workflow
3
6
 
4
7
 
5
8
  class ClassifyWorkflow(Workflow):
6
- def __init__(self, question: str, categories: list[str]):
9
+ def __init__(self, question: str, options: list[str]):
7
10
  super().__init__(type="SimpleWorkflowConfig")
8
11
  self._question = question
9
- self._categories = categories
12
+ self._options = options
10
13
 
11
14
  def to_dict(self) -> dict[str, Any]:
12
15
  return {
@@ -14,6 +17,18 @@ class ClassifyWorkflow(Workflow):
14
17
  "blueprint": {
15
18
  "_t": "ClassifyBlueprint",
16
19
  "title": self._question,
17
- "possibleCategories": self._categories,
20
+ "possibleCategories": self._options,
18
21
  }
19
22
  }
23
+
24
+ def to_model(self) -> SimpleWorkflowModel:
25
+ blueprint = AttachCategoryRapidBlueprint(
26
+ _t="ClassifyBlueprint",
27
+ title=self._question,
28
+ possibleCategories=self._options,
29
+ )
30
+
31
+ return SimpleWorkflowModel(
32
+ _t="SimpleWorkflow",
33
+ blueprint=SimpleWorkflowModelBlueprint(blueprint),
34
+ )
@@ -1,14 +1,14 @@
1
1
  from typing import Any
2
+ from openapi_client.models.simple_workflow_model_blueprint import SimpleWorkflowModelBlueprint
2
3
  from rapidata.rapidata_client.workflow import Workflow
4
+ from openapi_client.models.compare_rapid_blueprint import CompareRapidBlueprint
5
+ from openapi_client.models.simple_workflow_model import SimpleWorkflowModel
3
6
 
4
7
 
5
8
  class CompareWorkflow(Workflow):
6
9
  def __init__(self, criteria: str):
7
10
  super().__init__(type="CompareWorkflowConfig")
8
11
  self._criteria = criteria
9
- self._k_factor = 40
10
- self._match_size = 2
11
- self._matches_until_completed = 10
12
12
 
13
13
  def to_dict(self) -> dict[str, Any]:
14
14
  return {
@@ -16,15 +16,14 @@ class CompareWorkflow(Workflow):
16
16
  "criteria": self._criteria,
17
17
  }
18
18
 
19
- def k_factor(self, k_factor: int):
20
- self._k_factor = k_factor
21
- return self
22
-
23
- def match_size(self, match_size: int):
24
- self._match_size = match_size
25
- return self
26
-
27
- def matches_until_completed(self, matches_until_completed: int):
28
- self._matches_until_completed = matches_until_completed
29
- return self
19
+ def to_model(self) -> SimpleWorkflowModel:
20
+ blueprint = CompareRapidBlueprint(
21
+ _t="CompareBlueprint",
22
+ criteria=self._criteria,
23
+ )
24
+
25
+ return SimpleWorkflowModel(
26
+ _t="SimpleWorkflow",
27
+ blueprint=SimpleWorkflowModelBlueprint(blueprint),
28
+ )
30
29