rapidata 2.14.0__py3-none-any.whl → 2.15.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 (51) hide show
  1. rapidata/api_client/__init__.py +13 -0
  2. rapidata/api_client/api/campaign_api.py +252 -0
  3. rapidata/api_client/api/order_api.py +252 -0
  4. rapidata/api_client/api/rapid_api.py +262 -0
  5. rapidata/api_client/api/validation_api.py +283 -0
  6. rapidata/api_client/api/workflow_api.py +3 -3
  7. rapidata/api_client/models/__init__.py +13 -0
  8. rapidata/api_client/models/add_campaign_model.py +9 -2
  9. rapidata/api_client/models/campaign_query_result.py +2 -2
  10. rapidata/api_client/models/campaign_status.py +1 -0
  11. rapidata/api_client/models/classification_metadata.py +2 -4
  12. rapidata/api_client/models/compare_workflow_config.py +17 -2
  13. rapidata/api_client/models/compare_workflow_config_metadata_value.py +238 -0
  14. rapidata/api_client/models/compare_workflow_config_model.py +17 -2
  15. rapidata/api_client/models/compare_workflow_model.py +17 -2
  16. rapidata/api_client/models/count_metadata.py +1 -3
  17. rapidata/api_client/models/create_order_model.py +15 -1
  18. rapidata/api_client/models/early_stopping_referee_model.py +1 -1
  19. rapidata/api_client/models/evaluation_workflow_model.py +1 -1
  20. rapidata/api_client/models/get_rapid_responses_result.py +112 -0
  21. rapidata/api_client/models/get_simple_workflow_results_result.py +7 -1
  22. rapidata/api_client/models/image_dimension_metadata.py +1 -3
  23. rapidata/api_client/models/location_metadata.py +2 -4
  24. rapidata/api_client/models/metadata_visibilities.py +1 -0
  25. rapidata/api_client/models/order_model.py +2 -2
  26. rapidata/api_client/models/order_state.py +1 -0
  27. rapidata/api_client/models/original_filename_metadata.py +2 -4
  28. rapidata/api_client/models/prompt_metadata.py +1 -3
  29. rapidata/api_client/models/scrub_result.py +4 -4
  30. rapidata/api_client/models/source_url_metadata.py +98 -0
  31. rapidata/api_client/models/text_metadata.py +3 -5
  32. rapidata/api_client/models/transcription_metadata.py +1 -3
  33. rapidata/api_client/models/update_dimensions_model.py +87 -0
  34. rapidata/api_client_README.md +22 -4
  35. rapidata/rapidata_client/demographic/demographic_manager.py +35 -0
  36. rapidata/rapidata_client/filter/rapidata_filters.py +10 -2
  37. rapidata/rapidata_client/order/_rapidata_order_builder.py +7 -5
  38. rapidata/rapidata_client/order/rapidata_order.py +3 -5
  39. rapidata/rapidata_client/order/rapidata_order_manager.py +20 -20
  40. rapidata/rapidata_client/order/rapidata_results.py +2 -1
  41. rapidata/rapidata_client/rapidata_client.py +4 -0
  42. rapidata/rapidata_client/selection/rapidata_selections.py +10 -9
  43. rapidata/rapidata_client/settings/no_shuffle.py +2 -2
  44. rapidata/rapidata_client/settings/rapidata_settings.py +8 -0
  45. rapidata/rapidata_client/workflow/_ranking_workflow.py +15 -4
  46. rapidata/service/credential_manager.py +7 -0
  47. rapidata/service/openapi_service.py +6 -6
  48. {rapidata-2.14.0.dist-info → rapidata-2.15.0.dist-info}/METADATA +1 -1
  49. {rapidata-2.14.0.dist-info → rapidata-2.15.0.dist-info}/RECORD +51 -47
  50. {rapidata-2.14.0.dist-info → rapidata-2.15.0.dist-info}/LICENSE +0 -0
  51. {rapidata-2.14.0.dist-info → rapidata-2.15.0.dist-info}/WHEEL +0 -0
@@ -56,12 +56,13 @@ configuration.api_key['bearer'] = os.environ["API_KEY"]
56
56
  with rapidata.api_client.ApiClient(configuration) as api_client:
57
57
  # Create an instance of the API class
58
58
  api_instance = rapidata.api_client.CampaignApi(api_client)
59
+ campaign_id = 'campaign_id_example' # str | The campaign id that should be released
59
60
 
60
61
  try:
61
- # The monitor endpoint is used to monitor the health of the service
62
- api_instance.campaign_monitor_get()
62
+ # Releases a campaign from the preview state. This will make the campaign available for the users to be labeled.
63
+ api_instance.campaign_campaign_id_release_post(campaign_id)
63
64
  except ApiException as e:
64
- print("Exception when calling CampaignApi->campaign_monitor_get: %s\n" % e)
65
+ print("Exception when calling CampaignApi->campaign_campaign_id_release_post: %s\n" % e)
65
66
 
66
67
  ```
67
68
 
@@ -71,6 +72,7 @@ All URIs are relative to *http://localhost*
71
72
 
72
73
  Class | Method | HTTP request | Description
73
74
  ------------ | ------------- | ------------- | -------------
75
+ *CampaignApi* | [**campaign_campaign_id_release_post**](rapidata/api_client/docs/CampaignApi.md#campaign_campaign_id_release_post) | **POST** /campaign/{campaignId}/release | Releases a campaign from the preview state. This will make the campaign available for the users to be labeled.
74
76
  *CampaignApi* | [**campaign_monitor_get**](rapidata/api_client/docs/CampaignApi.md#campaign_monitor_get) | **GET** /Campaign/Monitor | The monitor endpoint is used to monitor the health of the service
75
77
  *CampaignApi* | [**campaign_pause_post**](rapidata/api_client/docs/CampaignApi.md#campaign_pause_post) | **POST** /Campaign/Pause | Pauses a campaign.
76
78
  *CampaignApi* | [**campaign_query_get**](rapidata/api_client/docs/CampaignApi.md#campaign_query_get) | **GET** /Campaign/Query | Queries orders based on a filter, page, and sort criteria.
@@ -109,6 +111,7 @@ Class | Method | HTTP request | Description
109
111
  *OrderApi* | [**order_get_by_id_get**](rapidata/api_client/docs/OrderApi.md#order_get_by_id_get) | **GET** /Order/GetById | Retrieves an order by its id.
110
112
  *OrderApi* | [**order_get_order_results_get**](rapidata/api_client/docs/OrderApi.md#order_get_order_results_get) | **GET** /Order/GetOrderResults | Aggregates the results of an order.
111
113
  *OrderApi* | [**order_get_public_get**](rapidata/api_client/docs/OrderApi.md#order_get_public_get) | **GET** /Order/GetPublic | Retrieves orders that are public and can be cloned by any user.
114
+ *OrderApi* | [**order_order_id_preview_post**](rapidata/api_client/docs/OrderApi.md#order_order_id_preview_post) | **POST** /order/{orderId}/preview | Puts the order into preview mode, where it one can inspect what our labelers receive.
112
115
  *OrderApi* | [**order_pause_post**](rapidata/api_client/docs/OrderApi.md#order_pause_post) | **POST** /Order/Pause | Pauses an order that is processing. Meaning all campaigns in the order will be paused.
113
116
  *OrderApi* | [**order_query_get**](rapidata/api_client/docs/OrderApi.md#order_query_get) | **GET** /Order/Query | Queries orders based on a filter, page, and sort criteria.
114
117
  *OrderApi* | [**order_result_get**](rapidata/api_client/docs/OrderApi.md#order_result_get) | **GET** /Order/Result | Aggregates the results of an order.
@@ -131,6 +134,7 @@ Class | Method | HTTP request | Description
131
134
  *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.
132
135
  *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.
133
136
  *RapidApi* | [**rapid_rapid_id_delete**](rapidata/api_client/docs/RapidApi.md#rapid_rapid_id_delete) | **DELETE** /rapid/{rapidId} | Deletes a rapid.
137
+ *RapidApi* | [**rapid_rapid_id_responses_get**](rapidata/api_client/docs/RapidApi.md#rapid_rapid_id_responses_get) | **GET** /rapid/{rapidId}/responses | Gets all responses for a given rapid.
134
138
  *RapidApi* | [**rapid_report_id_get**](rapidata/api_client/docs/RapidApi.md#rapid_report_id_get) | **GET** /rapid/report/{id} | Inspects a report's dump. can be used to restore zustand state or anything alike.
135
139
  *RapidApi* | [**rapid_report_post**](rapidata/api_client/docs/RapidApi.md#rapid_report_post) | **POST** /Rapid/Report | Used to report an issue with a rapid.
136
140
  *RapidApi* | [**rapid_skip_user_guess_post**](rapidata/api_client/docs/RapidApi.md#rapid_skip_user_guess_post) | **POST** /Rapid/SkipUserGuess | Skips a Rapid for the user.
@@ -147,11 +151,12 @@ Class | Method | HTTP request | Description
147
151
  *ValidationApi* | [**validation_import_compare_post**](rapidata/api_client/docs/ValidationApi.md#validation_import_compare_post) | **POST** /Validation/ImportCompare | Imports a compare validation set from a zip file.
148
152
  *ValidationApi* | [**validation_import_post**](rapidata/api_client/docs/ValidationApi.md#validation_import_post) | **POST** /Validation/Import | Imports a validation set from a zip file.
149
153
  *ValidationApi* | [**validation_query_validation_sets_get**](rapidata/api_client/docs/ValidationApi.md#validation_query_validation_sets_get) | **GET** /Validation/QueryValidationSets | Queries validation sets based on the provided filter, paging and sorting criteria.
154
+ *ValidationApi* | [**validation_validation_set_id_dimensions_patch**](rapidata/api_client/docs/ValidationApi.md#validation_validation_set_id_dimensions_patch) | **PATCH** /validation/{validationSetId}/dimensions | Updates the dimensions of all rapids within a validation set.
150
155
  *WorkflowApi* | [**workflow_delete_delete**](rapidata/api_client/docs/WorkflowApi.md#workflow_delete_delete) | **DELETE** /Workflow/Delete | Deletes a workflow.
151
156
  *WorkflowApi* | [**workflow_get_by_id_get**](rapidata/api_client/docs/WorkflowApi.md#workflow_get_by_id_get) | **GET** /Workflow/GetById | Get a workflow by its ID.
152
157
  *WorkflowApi* | [**workflow_get_progress_get**](rapidata/api_client/docs/WorkflowApi.md#workflow_get_progress_get) | **GET** /Workflow/GetProgress | Get the progress of a workflow.
153
158
  *WorkflowApi* | [**workflow_id_compare_ab_summary_get**](rapidata/api_client/docs/WorkflowApi.md#workflow_id_compare_ab_summary_get) | **GET** /workflow/{id}/compare-ab-summary | Calculates a summary of the results for a simple compare workflow. The summary includes the number of times an asset at each index was the winner.
154
- *WorkflowApi* | [**workflow_id_responses_get**](rapidata/api_client/docs/WorkflowApi.md#workflow_id_responses_get) | **GET** /workflow/{id}/responses | Gets the !:limit most recent or oldest responses for a workflow. The responses are not guaranteed to be of any specific rapid. Instead, this endpoint returns all responses to any rapid in the workflow.
159
+ *WorkflowApi* | [**workflow_id_responses_get**](rapidata/api_client/docs/WorkflowApi.md#workflow_id_responses_get) | **GET** /workflow/{id}/responses | Gets the limit most recent or oldest responses for a workflow. The responses are not guaranteed to be of any specific rapid. Instead, this endpoint returns all responses to any rapid in the workflow.
155
160
  *WorkflowApi* | [**workflow_query_get**](rapidata/api_client/docs/WorkflowApi.md#workflow_query_get) | **GET** /Workflow/Query | Queries workflows based on the provided filter, page, and sort criteria.
156
161
 
157
162
 
@@ -184,6 +189,7 @@ Class | Method | HTTP request | Description
184
189
  - [CampaignStatus](rapidata/api_client/docs/CampaignStatus.md)
185
190
  - [CampaignUserFilterModel](rapidata/api_client/docs/CampaignUserFilterModel.md)
186
191
  - [CappedSelection](rapidata/api_client/docs/CappedSelection.md)
192
+ - [ClassificationMetadata](rapidata/api_client/docs/ClassificationMetadata.md)
187
193
  - [ClassificationMetadataFilterConfig](rapidata/api_client/docs/ClassificationMetadataFilterConfig.md)
188
194
  - [ClassificationMetadataModel](rapidata/api_client/docs/ClassificationMetadataModel.md)
189
195
  - [ClassifyPayload](rapidata/api_client/docs/ClassifyPayload.md)
@@ -197,6 +203,7 @@ Class | Method | HTTP request | Description
197
203
  - [CompareResult](rapidata/api_client/docs/CompareResult.md)
198
204
  - [CompareTruth](rapidata/api_client/docs/CompareTruth.md)
199
205
  - [CompareWorkflowConfig](rapidata/api_client/docs/CompareWorkflowConfig.md)
206
+ - [CompareWorkflowConfigMetadataValue](rapidata/api_client/docs/CompareWorkflowConfigMetadataValue.md)
200
207
  - [CompareWorkflowConfigModel](rapidata/api_client/docs/CompareWorkflowConfigModel.md)
201
208
  - [CompareWorkflowConfigModelPairMakerConfig](rapidata/api_client/docs/CompareWorkflowConfigModelPairMakerConfig.md)
202
209
  - [CompareWorkflowConfigPairMakerConfig](rapidata/api_client/docs/CompareWorkflowConfigPairMakerConfig.md)
@@ -208,6 +215,7 @@ Class | Method | HTTP request | Description
208
215
  - [ConditionalValidationSelection](rapidata/api_client/docs/ConditionalValidationSelection.md)
209
216
  - [Coordinate](rapidata/api_client/docs/Coordinate.md)
210
217
  - [CountClassificationMetadataFilterConfig](rapidata/api_client/docs/CountClassificationMetadataFilterConfig.md)
218
+ - [CountMetadata](rapidata/api_client/docs/CountMetadata.md)
211
219
  - [CountMetadataModel](rapidata/api_client/docs/CountMetadataModel.md)
212
220
  - [CountryUserFilterModel](rapidata/api_client/docs/CountryUserFilterModel.md)
213
221
  - [CreateBridgeTokenResult](rapidata/api_client/docs/CreateBridgeTokenResult.md)
@@ -276,6 +284,7 @@ Class | Method | HTTP request | Description
276
284
  - [GetPipelineByIdResult](rapidata/api_client/docs/GetPipelineByIdResult.md)
277
285
  - [GetPipelineByIdResultArtifactsValue](rapidata/api_client/docs/GetPipelineByIdResultArtifactsValue.md)
278
286
  - [GetPublicOrdersResult](rapidata/api_client/docs/GetPublicOrdersResult.md)
287
+ - [GetRapidResponsesResult](rapidata/api_client/docs/GetRapidResponsesResult.md)
279
288
  - [GetResponsesResult](rapidata/api_client/docs/GetResponsesResult.md)
280
289
  - [GetSimpleWorkflowResultsModel](rapidata/api_client/docs/GetSimpleWorkflowResultsModel.md)
281
290
  - [GetSimpleWorkflowResultsResult](rapidata/api_client/docs/GetSimpleWorkflowResultsResult.md)
@@ -286,6 +295,7 @@ Class | Method | HTTP request | Description
286
295
  - [GetWorkflowProgressResult](rapidata/api_client/docs/GetWorkflowProgressResult.md)
287
296
  - [IWorkflowModelPagedResult](rapidata/api_client/docs/IWorkflowModelPagedResult.md)
288
297
  - [IdentityReadBridgeTokenGet202Response](rapidata/api_client/docs/IdentityReadBridgeTokenGet202Response.md)
298
+ - [ImageDimensionMetadata](rapidata/api_client/docs/ImageDimensionMetadata.md)
289
299
  - [ImageDimensionMetadataModel](rapidata/api_client/docs/ImageDimensionMetadataModel.md)
290
300
  - [ImportFromFileResult](rapidata/api_client/docs/ImportFromFileResult.md)
291
301
  - [ImportValidationSetFromFileResult](rapidata/api_client/docs/ImportValidationSetFromFileResult.md)
@@ -303,9 +313,11 @@ Class | Method | HTTP request | Description
303
313
  - [LocatePayload](rapidata/api_client/docs/LocatePayload.md)
304
314
  - [LocateRapidBlueprint](rapidata/api_client/docs/LocateRapidBlueprint.md)
305
315
  - [LocateResult](rapidata/api_client/docs/LocateResult.md)
316
+ - [LocationMetadata](rapidata/api_client/docs/LocationMetadata.md)
306
317
  - [LocationMetadataExistsFilterConfig](rapidata/api_client/docs/LocationMetadataExistsFilterConfig.md)
307
318
  - [LocationMetadataModel](rapidata/api_client/docs/LocationMetadataModel.md)
308
319
  - [LogicOperator](rapidata/api_client/docs/LogicOperator.md)
320
+ - [MetadataVisibilities](rapidata/api_client/docs/MetadataVisibilities.md)
309
321
  - [MultiAssetModel](rapidata/api_client/docs/MultiAssetModel.md)
310
322
  - [NaiveRefereeConfig](rapidata/api_client/docs/NaiveRefereeConfig.md)
311
323
  - [NaiveRefereeModel](rapidata/api_client/docs/NaiveRefereeModel.md)
@@ -325,6 +337,7 @@ Class | Method | HTTP request | Description
325
337
  - [OrderModel](rapidata/api_client/docs/OrderModel.md)
326
338
  - [OrderModelPagedResult](rapidata/api_client/docs/OrderModelPagedResult.md)
327
339
  - [OrderState](rapidata/api_client/docs/OrderState.md)
340
+ - [OriginalFilenameMetadata](rapidata/api_client/docs/OriginalFilenameMetadata.md)
328
341
  - [OriginalFilenameMetadataModel](rapidata/api_client/docs/OriginalFilenameMetadataModel.md)
329
342
  - [PageInfo](rapidata/api_client/docs/PageInfo.md)
330
343
  - [PipelineIdWorkflowPutRequest](rapidata/api_client/docs/PipelineIdWorkflowPutRequest.md)
@@ -337,6 +350,7 @@ Class | Method | HTTP request | Description
337
350
  - [PrivateTextMetadataInput](rapidata/api_client/docs/PrivateTextMetadataInput.md)
338
351
  - [ProbabilisticAttachCategoryRefereeConfig](rapidata/api_client/docs/ProbabilisticAttachCategoryRefereeConfig.md)
339
352
  - [ProblemDetails](rapidata/api_client/docs/ProblemDetails.md)
353
+ - [PromptMetadata](rapidata/api_client/docs/PromptMetadata.md)
340
354
  - [PromptMetadataInput](rapidata/api_client/docs/PromptMetadataInput.md)
341
355
  - [PromptMetadataModel](rapidata/api_client/docs/PromptMetadataModel.md)
342
356
  - [PublicOrderModel](rapidata/api_client/docs/PublicOrderModel.md)
@@ -376,12 +390,15 @@ Class | Method | HTTP request | Description
376
390
  - [SkipResult](rapidata/api_client/docs/SkipResult.md)
377
391
  - [SortCriterion](rapidata/api_client/docs/SortCriterion.md)
378
392
  - [SortDirection](rapidata/api_client/docs/SortDirection.md)
393
+ - [SourceUrlMetadata](rapidata/api_client/docs/SourceUrlMetadata.md)
379
394
  - [SourceUrlMetadataModel](rapidata/api_client/docs/SourceUrlMetadataModel.md)
380
395
  - [StaticSelection](rapidata/api_client/docs/StaticSelection.md)
381
396
  - [SubmitCocoModel](rapidata/api_client/docs/SubmitCocoModel.md)
382
397
  - [SubmitCocoResult](rapidata/api_client/docs/SubmitCocoResult.md)
383
398
  - [TextAssetModel](rapidata/api_client/docs/TextAssetModel.md)
399
+ - [TextMetadata](rapidata/api_client/docs/TextMetadata.md)
384
400
  - [TextMetadataModel](rapidata/api_client/docs/TextMetadataModel.md)
401
+ - [TranscriptionMetadata](rapidata/api_client/docs/TranscriptionMetadata.md)
385
402
  - [TranscriptionMetadataInput](rapidata/api_client/docs/TranscriptionMetadataInput.md)
386
403
  - [TranscriptionMetadataModel](rapidata/api_client/docs/TranscriptionMetadataModel.md)
387
404
  - [TranscriptionPayload](rapidata/api_client/docs/TranscriptionPayload.md)
@@ -394,6 +411,7 @@ Class | Method | HTTP request | Description
394
411
  - [UnlockOrderResult](rapidata/api_client/docs/UnlockOrderResult.md)
395
412
  - [UpdateAccessModel](rapidata/api_client/docs/UpdateAccessModel.md)
396
413
  - [UpdateCampaignModel](rapidata/api_client/docs/UpdateCampaignModel.md)
414
+ - [UpdateDimensionsModel](rapidata/api_client/docs/UpdateDimensionsModel.md)
397
415
  - [UpdateOrderModel](rapidata/api_client/docs/UpdateOrderModel.md)
398
416
  - [UpdateValidationRapidModel](rapidata/api_client/docs/UpdateValidationRapidModel.md)
399
417
  - [UpdateValidationRapidModelTruth](rapidata/api_client/docs/UpdateValidationRapidModelTruth.md)
@@ -2,6 +2,8 @@ from rapidata.service.openapi_service import OpenAPIService
2
2
  from rapidata.rapidata_client.assets import MediaAsset
3
3
  from rapidata.api_client.models.create_demographic_rapid_model import CreateDemographicRapidModel
4
4
  from rapidata.api_client.models.classify_payload import ClassifyPayload
5
+ import requests
6
+ from requests.adapters import HTTPAdapter, Retry
5
7
 
6
8
 
7
9
  class DemographicManager:
@@ -23,5 +25,38 @@ class DemographicManager:
23
25
  title=instruction
24
26
  )
25
27
  )
28
+ session = self._get_session()
29
+ media.session = session
30
+
26
31
  self._openapi_service.rapid_api.rapid_create_demographic_rapid_post(model=model, file=[media.to_file()])
32
+
33
+ def _get_session(self, max_retries: int = 5, max_workers: int = 10) -> requests.Session:
34
+ """Get a requests session with retry logic.
35
+
36
+
37
+ Args:
38
+ max_retries (int): The maximum number of retries.
39
+ max_workers (int): The maximum number of workers.
40
+
41
+ Returns:
42
+ requests.Session: A requests session with retry logic.
43
+ """
44
+ session = requests.Session()
45
+ retries = Retry(
46
+ total=max_retries,
47
+ backoff_factor=1,
48
+ status_forcelist=[500, 502, 503, 504],
49
+ allowed_methods=["GET"],
50
+ respect_retry_after_header=True
51
+ )
52
+
53
+ adapter = HTTPAdapter(
54
+ pool_connections=max_workers * 2,
55
+ pool_maxsize=max_workers * 4,
56
+ max_retries=retries
57
+ )
58
+ session.mount('http://', adapter)
59
+ session.mount('https://', adapter)
60
+
61
+ return session
27
62
 
@@ -14,17 +14,25 @@ class RapidataFilters:
14
14
 
15
15
  Note that adding multiple filters to the same order will result in a logical AND operation between the filters.
16
16
 
17
- Warning: this might significantly slow down the number of responses you receive.
17
+ Warning:
18
+ This might significantly slow down the number of responses you receive.
18
19
 
19
20
  Attributes:
20
21
  user_score (UserScoreFilter): The UserScoreFilter instance.
21
22
  age (AgeFilter): The AgeFilter instance.
22
23
  campaign (CampaignFilter): The CampaignFilter instance.
23
24
  country (CountryFilter): The CountryFilter instance.
24
- campaign (CampaignFilter): The CampaignFilter instance
25
25
  gender (GenderFilter): The GenderFilter instance.
26
26
  language (LanguageFilter): The LanguageFilter instance.
27
27
  custom_filter (CustomFilter): The CustomFilter instance.
28
+
29
+ Example:
30
+ ```python
31
+ from rapidata import CountryFilter, LanguageFilter
32
+ filters=[CountryFilter(["US", "DE"]), LanguageFilter(["en"])]
33
+ ```
34
+
35
+ This ensures the order is only shown to users in the US and Germany whose phones are set to English.
28
36
  """
29
37
  user_score = UserScoreFilter
30
38
  age = AgeFilter
@@ -182,6 +182,8 @@ class RapidataOrderBuilder:
182
182
  raise ValueError(
183
183
  "Media paths must all be of the same type: MediaAsset, TextAsset, or MultiAsset."
184
184
  )
185
+
186
+ self.__openapi_service.order_api.order_order_id_preview_post(self.order_id)
185
187
 
186
188
  return order
187
189
 
@@ -235,11 +237,11 @@ class RapidataOrderBuilder:
235
237
  if not isinstance(asset, list):
236
238
  raise TypeError("Media paths must be provided as a list of paths.")
237
239
 
238
- # for a in asset:
239
- # if not isinstance(a, (MediaAsset, TextAsset, MultiAsset)):
240
- # raise TypeError(
241
- # "Media paths must be of type MediaAsset, TextAsset, or MultiAsset."
242
- # )
240
+ for a in asset:
241
+ if not isinstance(a, (MediaAsset, TextAsset, MultiAsset)):
242
+ raise TypeError(
243
+ "Media paths must be of type MediaAsset, TextAsset, or MultiAsset."
244
+ )
243
245
 
244
246
  if metadata:
245
247
  for data in metadata:
@@ -70,6 +70,7 @@ class RapidataOrder:
70
70
 
71
71
  States:
72
72
  Created: The order has been created but not started yet.\n
73
+ Preview: The order has been set up and ready but not collecting responses yet.\n
73
74
  Submitted: The order has been submitted and is being reviewed.\n
74
75
  ManualReview: The order is in manual review - something went wrong with the automatic approval.\n
75
76
  Processing: The order is actively being processed.\n
@@ -164,12 +165,9 @@ class RapidataOrder:
164
165
 
165
166
  Raises:
166
167
  Exception: If the order is not in processing state.
167
- """
168
- if self.get_status() != OrderState.PROCESSING:
169
- raise Exception("Order is not processing. Preview unavailable.")
170
-
168
+ """
171
169
  campaign_id = self.__get_campaign_id()
172
- auth_url = f"https://rapids.{self.__openapi_service.enviroment}/preview/campaign?id={campaign_id}"
170
+ auth_url = f"https://app.{self.__openapi_service.enviroment}/order/detail/{self.order_id}/preview?campaignId={campaign_id}"
173
171
  could_open_browser = webbrowser.open(auth_url)
174
172
  if not could_open_browser:
175
173
  encoded_url = urllib.parse.quote(auth_url, safe="%/:=&?~#+!$,;'@()*[]")
@@ -247,17 +247,16 @@ class RapidataOrderManager:
247
247
  name: str,
248
248
  instruction: str,
249
249
  datapoints: list[str],
250
- responses_per_comparison: int,
251
250
  total_comparison_budget: int,
251
+ responses_per_comparison: int = 5,
252
+ data_type: str = RapidataDataTypes.MEDIA,
252
253
  random_comparisons_ratio: float = 0.5,
253
- elo_start: int = 1200,
254
- elo_k_factor: int = 40,
255
- elo_scaling_factor: int = 400,
256
- contexts: Optional[list[str]] = None,
254
+ context: Optional[str] = None,
257
255
  validation_set_id: Optional[str] = None,
258
256
  filters: Sequence[RapidataFilter] = [],
259
257
  settings: Sequence[RapidataSetting] = [],
260
- selections: Optional[Sequence[RapidataSelection]] = None) -> RapidataOrder:
258
+ selections: Optional[Sequence[RapidataSelection]] = None
259
+ ) -> RapidataOrder:
261
260
  """
262
261
  Create a ranking order.
263
262
 
@@ -266,15 +265,13 @@ class RapidataOrderManager:
266
265
  instruction (str): The question asked from People when They see two datapoints.
267
266
  datapoints (list[str]): A list of datapoints that will participate in the ranking.
268
267
  total_comparison_budget (int): The total number of (pairwise-)comparisons that can be made.
269
- random_comparisons_ratio (float, optional): The fraction of random comparisons in the ranking process.
270
- The rest will focus on pairing similarly ranked datapoints.
271
- elo_start (int, optional): The initial ELO rating assigned to each datapoint.
272
- elo_k_factor (int, optional): The K-factor used for ELO updates.
273
- elo_scaling_factor (int, optional): The scaling factor used in the ELO calculation.
274
268
  responses_per_comparison (int, optional): The number of responses collected per comparison.
275
- contexts (list[str], optional): The list of contexts for the comparison. Defaults to None.\n
276
- If provided has to be the same length as datapoints and will be shown in addition to the instruction.
277
- (Therefore will be different for each datapoint) Will be match up with the datapoints using the list index.
269
+ data_type (str, optional): The data type of the datapoints. Defaults to RapidataDataTypes.MEDIA. \n
270
+ Other option: RapidataDataTypes.TEXT ("text").
271
+ random_comparisons_ratio (float, optional): The fraction of random comparisons in the ranking process.
272
+ The rest will focus on pairing similarly ranked datapoints. Defaults to 0.5 and can be left untouched.
273
+ context (str, optional): The context for all the comparison. Defaults to None.\n
274
+ If provided will be shown in addition to the instruction for all the matchups.
278
275
  validation_set_id (str, optional): The ID of the validation set. Defaults to None.\n
279
276
  If provided, one validation task will be shown infront of the datapoints that will be labeled.
280
277
  filters (Sequence[RapidataFilter], optional): The list of filters for the order. Defaults to []. Decides who the tasks should be shown to.
@@ -282,20 +279,23 @@ class RapidataOrderManager:
282
279
  selections (Sequence[RapidataSelection], optional): The list of selections for the order. Defaults to None. Decides in what order the tasks should be shown.
283
280
  """
284
281
 
285
- assets = [MediaAsset(path=path) for path in datapoints]
282
+ if data_type == RapidataDataTypes.MEDIA:
283
+ assets = [MediaAsset(path=path) for path in datapoints]
284
+ elif data_type == RapidataDataTypes.TEXT:
285
+ assets = [TextAsset(text=text) for text in datapoints]
286
+ else:
287
+ raise ValueError(f"Unsupported data type: {data_type}, must be one of {RapidataDataTypes._possible_values()}")
288
+
286
289
  return self._create_general_order(
287
290
  name=name,
288
291
  workflow=RankingWorkflow(
289
292
  criteria=instruction,
290
- elo_start=elo_start,
291
- elo_k_factor=elo_k_factor,
292
- elo_scaling_factor=elo_scaling_factor,
293
293
  total_comparison_budget=total_comparison_budget,
294
- random_comparisons_ratio=random_comparisons_ratio
294
+ random_comparisons_ratio=random_comparisons_ratio,
295
+ context=context
295
296
  ),
296
297
  assets=assets,
297
298
  responses_per_datapoint=responses_per_comparison,
298
- contexts=contexts,
299
299
  validation_set_id=validation_set_id,
300
300
  filters=filters,
301
301
  selections=selections,
@@ -10,7 +10,8 @@ class RapidataResults(dict):
10
10
  """
11
11
  def to_pandas(self, split_details: bool = False) -> pd.DataFrame:
12
12
  """
13
- This method is currently under development.
13
+ Warning:
14
+ This method is currently under development. The structure of the results may change in the future.
14
15
 
15
16
  Converts the results to a pandas DataFrame.
16
17
 
@@ -42,3 +42,7 @@ class RapidataClient:
42
42
  self.validation = ValidationSetManager(openapi_service=self._openapi_service)
43
43
 
44
44
  self._demographic = DemographicManager(openapi_service=self._openapi_service)
45
+
46
+ def reset_credentials(self):
47
+ """Reset the credentials saved in the configuration file for the current enviroment."""
48
+ self._openapi_service.reset_credentials()
@@ -11,21 +11,22 @@ class RapidataSelections:
11
11
  Selections are used to define what type of tasks and in what order they are shown to the user.
12
12
  All Tasks are called a "Session". A session can contain multiple tasks of different types.
13
13
 
14
- Example:
15
- ```python
16
- selections=[ValidationSelection("your-validation-set-id", 1),
17
- LabelingSelection(2)]
18
- ```
19
-
20
- The above example will create a session with a validation task followed by two labeling tasks.
21
-
22
14
  Attributes:
23
15
  labeling (LabelingSelection): The LabelingSelection instance.
24
16
  validation (ValidationSelection): The ValidationSelection instance.
25
17
  conditional_validation (ConditionalValidationSelection): The ConditionalValidationSelection instance.
26
18
  demographic (DemographicSelection): The DemographicSelection instance.
27
- capped (CappedSelection): The CappedSelection instance."""
19
+ capped (CappedSelection): The CappedSelection instance.
28
20
 
21
+ Example:
22
+ ```python
23
+ from rapidata import LabelingSelection, ValidationSelection
24
+ selections=[ValidationSelection("your-validation-set-id", 1),
25
+ LabelingSelection(2)]
26
+ ```
27
+
28
+ This will require annotators to complete one validation task followed by two labeling tasks.
29
+ """
29
30
  labeling = LabelingSelection
30
31
  validation = ValidationSelection
31
32
  conditional_validation = ConditionalValidationSelection
@@ -2,9 +2,9 @@ from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
2
2
 
3
3
  class NoShuffle(RapidataSetting):
4
4
  """
5
- Only for classify tasks. If true, the order of the categories will be the same.
5
+ Only for classification and compare tasks. If true, the order of the categories / images will not be shuffled and presented in the same order as specified.
6
6
 
7
- If this is not added to the order, it shuffling will be active.
7
+ If this is not added to the order, the shuffling will be active.
8
8
 
9
9
  Args:
10
10
  value (bool, optional): Whether to disable shuffling. Defaults to True for function call.
@@ -20,6 +20,14 @@ class RapidataSettings:
20
20
  no_shuffle (NoShuffle): The NoShuffle instance.
21
21
  play_video_until_the_end (PlayVideoUntilTheEnd): The PlayVideoUntilTheEnd instance.
22
22
  custom_setting (CustomSetting): The CustomSetting instance.
23
+
24
+ Example:
25
+ ```python
26
+ from rapidata import FreeTextMinimumCharacters
27
+ settings=[FreeTextMinimumCharacters(10)]
28
+ ```
29
+
30
+ This can be used in a free text order to set the minimum number of characters required to submit the task.
23
31
  """
24
32
 
25
33
  alert_on_fast_response = AlertOnFastResponse
@@ -1,6 +1,11 @@
1
1
  from rapidata.api_client import CompareWorkflowModelPairMakerConfig, OnlinePairMakerConfigModel, EloConfigModel
2
2
  from rapidata.api_client.models.compare_workflow_model import CompareWorkflowModel
3
3
  from rapidata.rapidata_client.workflow._base_workflow import Workflow
4
+ from rapidata.rapidata_client.metadata import PromptMetadata
5
+ from rapidata.api_client.models.create_datapoint_from_urls_model import (
6
+ CreateDatapointFromUrlsModelMetadataInner,
7
+ )
8
+
4
9
 
5
10
  class RankingWorkflow(Workflow):
6
11
 
@@ -9,12 +14,17 @@ class RankingWorkflow(Workflow):
9
14
  criteria: str,
10
15
  total_comparison_budget: int,
11
16
  random_comparisons_ratio,
12
- elo_start: int,
13
- elo_k_factor: int,
14
- elo_scaling_factor: int,
17
+ elo_start: int = 1200,
18
+ elo_k_factor: int = 40,
19
+ elo_scaling_factor: int = 400,
20
+ context: str | None = None,
15
21
  ):
16
22
  super().__init__(type="CompareWorkflowConfig")
17
23
 
24
+ self.context = [CreateDatapointFromUrlsModelMetadataInner(
25
+ PromptMetadata(context).to_model())
26
+ ] if context else None
27
+
18
28
  self.criteria = criteria
19
29
  self.pair_maker_config = CompareWorkflowModelPairMakerConfig(
20
30
  OnlinePairMakerConfigModel(
@@ -36,5 +46,6 @@ class RankingWorkflow(Workflow):
36
46
  _t="CompareWorkflow",
37
47
  criteria=self.criteria,
38
48
  eloConfig=self.elo_config,
39
- pairMakerConfig=self.pair_maker_config
49
+ pairMakerConfig=self.pair_maker_config,
50
+ metadata=self.context,
40
51
  )
@@ -133,6 +133,13 @@ class CredentialManager:
133
133
  return credential
134
134
 
135
135
  return self._create_new_credentials()
136
+
137
+ def reset_credentials(self) -> None:
138
+ """Reset the stored credentials for current enviroment."""
139
+ credentials = self._read_credentials()
140
+ if self.endpoint in credentials:
141
+ del credentials[self.endpoint]
142
+ self._write_credentials(credentials)
136
143
 
137
144
  def _get_bridge_tokens(self) -> Optional[BridgeToken]:
138
145
  """Get bridge tokens from the identity endpoint."""
@@ -8,6 +8,7 @@ from rapidata.api_client.api.workflow_api import WorkflowApi
8
8
  from rapidata.api_client.api_client import ApiClient
9
9
  from rapidata.api_client.configuration import Configuration
10
10
  from rapidata.service.token_manager import TokenManager, TokenInfo
11
+ from rapidata.service.credential_manager import CredentialManager
11
12
 
12
13
  from importlib.metadata import version, PackageNotFoundError
13
14
 
@@ -23,11 +24,11 @@ class OpenAPIService:
23
24
  ):
24
25
  self.enviroment = enviroment
25
26
  endpoint = f"https://api.{enviroment}"
26
- token_url = f"https://auth.{enviroment}"
27
+ self._token_url = f"https://auth.{enviroment}"
27
28
  token_manager = TokenManager(
28
29
  client_id=client_id,
29
30
  client_secret=client_secret,
30
- endpoint=token_url,
31
+ endpoint=self._token_url,
31
32
  oauth_scope=oauth_scope,
32
33
  cert_path=cert_path,
33
34
  )
@@ -42,14 +43,13 @@ class OpenAPIService:
42
43
  f"Bearer {token_manager.fetch_token().access_token}"
43
44
  )
44
45
 
45
- self._client_id = client_id
46
- self._client_secret = client_secret
47
- self._oauth_scope = oauth_scope
48
- self._token_url = f"{token_url}/connect/token"
49
46
  self._cert_path = cert_path
50
47
 
51
48
  token_manager.start_token_refresh(token_callback=self._set_token)
52
49
 
50
+ def reset_credentials(self):
51
+ CredentialManager(endpoint=self._token_url, cert_path=self._cert_path).reset_credentials()
52
+
53
53
  @property
54
54
  def order_api(self) -> OrderApi:
55
55
  return OrderApi(self.api_client)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: rapidata
3
- Version: 2.14.0
3
+ Version: 2.15.0
4
4
  Summary: Rapidata package containing the Rapidata Python Client to interact with the Rapidata Web API in an easy way.
5
5
  License: Apache-2.0
6
6
  Author: Rapidata AG