rapidata 2.14.0__py3-none-any.whl → 2.14.1__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 (39) hide show
  1. rapidata/api_client/__init__.py +12 -0
  2. rapidata/api_client/api/rapid_api.py +262 -0
  3. rapidata/api_client/api/workflow_api.py +3 -3
  4. rapidata/api_client/models/__init__.py +12 -0
  5. rapidata/api_client/models/classification_metadata.py +2 -4
  6. rapidata/api_client/models/compare_workflow_config.py +17 -2
  7. rapidata/api_client/models/compare_workflow_config_metadata_value.py +238 -0
  8. rapidata/api_client/models/compare_workflow_config_model.py +17 -2
  9. rapidata/api_client/models/compare_workflow_model.py +17 -2
  10. rapidata/api_client/models/count_metadata.py +1 -3
  11. rapidata/api_client/models/early_stopping_referee_model.py +1 -1
  12. rapidata/api_client/models/get_rapid_responses_result.py +112 -0
  13. rapidata/api_client/models/get_simple_workflow_results_result.py +7 -1
  14. rapidata/api_client/models/image_dimension_metadata.py +1 -3
  15. rapidata/api_client/models/location_metadata.py +2 -4
  16. rapidata/api_client/models/metadata_visibilities.py +1 -0
  17. rapidata/api_client/models/original_filename_metadata.py +2 -4
  18. rapidata/api_client/models/prompt_metadata.py +1 -3
  19. rapidata/api_client/models/scrub_result.py +4 -4
  20. rapidata/api_client/models/source_url_metadata.py +98 -0
  21. rapidata/api_client/models/text_metadata.py +3 -5
  22. rapidata/api_client/models/transcription_metadata.py +1 -3
  23. rapidata/api_client_README.md +14 -1
  24. rapidata/rapidata_client/filter/rapidata_filters.py +10 -2
  25. rapidata/rapidata_client/order/_rapidata_order_builder.py +5 -5
  26. rapidata/rapidata_client/order/rapidata_order.py +2 -2
  27. rapidata/rapidata_client/order/rapidata_order_manager.py +10 -19
  28. rapidata/rapidata_client/order/rapidata_results.py +2 -1
  29. rapidata/rapidata_client/rapidata_client.py +4 -0
  30. rapidata/rapidata_client/selection/rapidata_selections.py +10 -9
  31. rapidata/rapidata_client/settings/no_shuffle.py +2 -2
  32. rapidata/rapidata_client/settings/rapidata_settings.py +8 -0
  33. rapidata/rapidata_client/workflow/_ranking_workflow.py +15 -4
  34. rapidata/service/credential_manager.py +7 -0
  35. rapidata/service/openapi_service.py +6 -6
  36. {rapidata-2.14.0.dist-info → rapidata-2.14.1.dist-info}/METADATA +1 -1
  37. {rapidata-2.14.0.dist-info → rapidata-2.14.1.dist-info}/RECORD +39 -36
  38. {rapidata-2.14.0.dist-info → rapidata-2.14.1.dist-info}/LICENSE +0 -0
  39. {rapidata-2.14.0.dist-info → rapidata-2.14.1.dist-info}/WHEEL +0 -0
@@ -0,0 +1,98 @@
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, StrictStr, field_validator
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class SourceUrlMetadata(BaseModel):
26
+ """
27
+ SourceUrlMetadata
28
+ """ # noqa: E501
29
+ t: StrictStr = Field(description="Discriminator value for SourceUrlMetadata", alias="_t")
30
+ url: StrictStr
31
+ visibilities: Optional[StrictStr] = None
32
+ __properties: ClassVar[List[str]] = ["_t", "url", "visibilities"]
33
+
34
+ @field_validator('t')
35
+ def t_validate_enum(cls, value):
36
+ """Validates the enum"""
37
+ if value not in set(['SourceUrlMetadata']):
38
+ raise ValueError("must be one of enum values ('SourceUrlMetadata')")
39
+ return value
40
+
41
+ model_config = ConfigDict(
42
+ populate_by_name=True,
43
+ validate_assignment=True,
44
+ protected_namespaces=(),
45
+ )
46
+
47
+
48
+ def to_str(self) -> str:
49
+ """Returns the string representation of the model using alias"""
50
+ return pprint.pformat(self.model_dump(by_alias=True))
51
+
52
+ def to_json(self) -> str:
53
+ """Returns the JSON representation of the model using alias"""
54
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
55
+ return json.dumps(self.to_dict())
56
+
57
+ @classmethod
58
+ def from_json(cls, json_str: str) -> Optional[Self]:
59
+ """Create an instance of SourceUrlMetadata from a JSON string"""
60
+ return cls.from_dict(json.loads(json_str))
61
+
62
+ def to_dict(self) -> Dict[str, Any]:
63
+ """Return the dictionary representation of the model using alias.
64
+
65
+ This has the following differences from calling pydantic's
66
+ `self.model_dump(by_alias=True)`:
67
+
68
+ * `None` is only added to the output dict for nullable fields that
69
+ were set at model initialization. Other fields with value `None`
70
+ are ignored.
71
+ """
72
+ excluded_fields: Set[str] = set([
73
+ ])
74
+
75
+ _dict = self.model_dump(
76
+ by_alias=True,
77
+ exclude=excluded_fields,
78
+ exclude_none=True,
79
+ )
80
+ return _dict
81
+
82
+ @classmethod
83
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
84
+ """Create an instance of SourceUrlMetadata from a dict"""
85
+ if obj is None:
86
+ return None
87
+
88
+ if not isinstance(obj, dict):
89
+ return cls.model_validate(obj)
90
+
91
+ _obj = cls.model_validate({
92
+ "_t": obj.get("_t") if obj.get("_t") is not None else 'SourceUrlMetadata',
93
+ "url": obj.get("url"),
94
+ "visibilities": obj.get("visibilities")
95
+ })
96
+ return _obj
97
+
98
+
@@ -18,7 +18,7 @@ import re # noqa: F401
18
18
  import json
19
19
 
20
20
  from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
21
- from typing import Any, ClassVar, Dict, List
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
22
  from typing import Optional, Set
23
23
  from typing_extensions import Self
24
24
 
@@ -28,9 +28,8 @@ class TextMetadata(BaseModel):
28
28
  """ # noqa: E501
29
29
  t: StrictStr = Field(description="Discriminator value for TextMetadata", alias="_t")
30
30
  text: StrictStr
31
- identifier: StrictStr
32
- visibilities: StrictStr
33
- __properties: ClassVar[List[str]] = ["_t", "text", "identifier", "visibilities"]
31
+ visibilities: Optional[StrictStr] = None
32
+ __properties: ClassVar[List[str]] = ["_t", "text", "visibilities"]
34
33
 
35
34
  @field_validator('t')
36
35
  def t_validate_enum(cls, value):
@@ -92,7 +91,6 @@ class TextMetadata(BaseModel):
92
91
  _obj = cls.model_validate({
93
92
  "_t": obj.get("_t") if obj.get("_t") is not None else 'TextMetadata',
94
93
  "text": obj.get("text"),
95
- "identifier": obj.get("identifier"),
96
94
  "visibilities": obj.get("visibilities")
97
95
  })
98
96
  return _obj
@@ -28,9 +28,8 @@ class TranscriptionMetadata(BaseModel):
28
28
  """ # noqa: E501
29
29
  t: StrictStr = Field(description="Discriminator value for TranscriptionMetadata", alias="_t")
30
30
  transcription: StrictStr
31
- identifier: StrictStr
32
31
  visibilities: StrictStr
33
- __properties: ClassVar[List[str]] = ["_t", "transcription", "identifier", "visibilities"]
32
+ __properties: ClassVar[List[str]] = ["_t", "transcription", "visibilities"]
34
33
 
35
34
  @field_validator('t')
36
35
  def t_validate_enum(cls, value):
@@ -92,7 +91,6 @@ class TranscriptionMetadata(BaseModel):
92
91
  _obj = cls.model_validate({
93
92
  "_t": obj.get("_t") if obj.get("_t") is not None else 'TranscriptionMetadata',
94
93
  "transcription": obj.get("transcription"),
95
- "identifier": obj.get("identifier"),
96
94
  "visibilities": obj.get("visibilities")
97
95
  })
98
96
  return _obj
@@ -131,6 +131,7 @@ Class | Method | HTTP request | Description
131
131
  *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
132
  *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
133
  *RapidApi* | [**rapid_rapid_id_delete**](rapidata/api_client/docs/RapidApi.md#rapid_rapid_id_delete) | **DELETE** /rapid/{rapidId} | Deletes a rapid.
134
+ *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
135
  *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
136
  *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
137
  *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.
@@ -151,7 +152,7 @@ Class | Method | HTTP request | Description
151
152
  *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
153
  *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
154
  *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.
155
+ *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
156
  *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
157
 
157
158
 
@@ -184,6 +185,7 @@ Class | Method | HTTP request | Description
184
185
  - [CampaignStatus](rapidata/api_client/docs/CampaignStatus.md)
185
186
  - [CampaignUserFilterModel](rapidata/api_client/docs/CampaignUserFilterModel.md)
186
187
  - [CappedSelection](rapidata/api_client/docs/CappedSelection.md)
188
+ - [ClassificationMetadata](rapidata/api_client/docs/ClassificationMetadata.md)
187
189
  - [ClassificationMetadataFilterConfig](rapidata/api_client/docs/ClassificationMetadataFilterConfig.md)
188
190
  - [ClassificationMetadataModel](rapidata/api_client/docs/ClassificationMetadataModel.md)
189
191
  - [ClassifyPayload](rapidata/api_client/docs/ClassifyPayload.md)
@@ -197,6 +199,7 @@ Class | Method | HTTP request | Description
197
199
  - [CompareResult](rapidata/api_client/docs/CompareResult.md)
198
200
  - [CompareTruth](rapidata/api_client/docs/CompareTruth.md)
199
201
  - [CompareWorkflowConfig](rapidata/api_client/docs/CompareWorkflowConfig.md)
202
+ - [CompareWorkflowConfigMetadataValue](rapidata/api_client/docs/CompareWorkflowConfigMetadataValue.md)
200
203
  - [CompareWorkflowConfigModel](rapidata/api_client/docs/CompareWorkflowConfigModel.md)
201
204
  - [CompareWorkflowConfigModelPairMakerConfig](rapidata/api_client/docs/CompareWorkflowConfigModelPairMakerConfig.md)
202
205
  - [CompareWorkflowConfigPairMakerConfig](rapidata/api_client/docs/CompareWorkflowConfigPairMakerConfig.md)
@@ -208,6 +211,7 @@ Class | Method | HTTP request | Description
208
211
  - [ConditionalValidationSelection](rapidata/api_client/docs/ConditionalValidationSelection.md)
209
212
  - [Coordinate](rapidata/api_client/docs/Coordinate.md)
210
213
  - [CountClassificationMetadataFilterConfig](rapidata/api_client/docs/CountClassificationMetadataFilterConfig.md)
214
+ - [CountMetadata](rapidata/api_client/docs/CountMetadata.md)
211
215
  - [CountMetadataModel](rapidata/api_client/docs/CountMetadataModel.md)
212
216
  - [CountryUserFilterModel](rapidata/api_client/docs/CountryUserFilterModel.md)
213
217
  - [CreateBridgeTokenResult](rapidata/api_client/docs/CreateBridgeTokenResult.md)
@@ -276,6 +280,7 @@ Class | Method | HTTP request | Description
276
280
  - [GetPipelineByIdResult](rapidata/api_client/docs/GetPipelineByIdResult.md)
277
281
  - [GetPipelineByIdResultArtifactsValue](rapidata/api_client/docs/GetPipelineByIdResultArtifactsValue.md)
278
282
  - [GetPublicOrdersResult](rapidata/api_client/docs/GetPublicOrdersResult.md)
283
+ - [GetRapidResponsesResult](rapidata/api_client/docs/GetRapidResponsesResult.md)
279
284
  - [GetResponsesResult](rapidata/api_client/docs/GetResponsesResult.md)
280
285
  - [GetSimpleWorkflowResultsModel](rapidata/api_client/docs/GetSimpleWorkflowResultsModel.md)
281
286
  - [GetSimpleWorkflowResultsResult](rapidata/api_client/docs/GetSimpleWorkflowResultsResult.md)
@@ -286,6 +291,7 @@ Class | Method | HTTP request | Description
286
291
  - [GetWorkflowProgressResult](rapidata/api_client/docs/GetWorkflowProgressResult.md)
287
292
  - [IWorkflowModelPagedResult](rapidata/api_client/docs/IWorkflowModelPagedResult.md)
288
293
  - [IdentityReadBridgeTokenGet202Response](rapidata/api_client/docs/IdentityReadBridgeTokenGet202Response.md)
294
+ - [ImageDimensionMetadata](rapidata/api_client/docs/ImageDimensionMetadata.md)
289
295
  - [ImageDimensionMetadataModel](rapidata/api_client/docs/ImageDimensionMetadataModel.md)
290
296
  - [ImportFromFileResult](rapidata/api_client/docs/ImportFromFileResult.md)
291
297
  - [ImportValidationSetFromFileResult](rapidata/api_client/docs/ImportValidationSetFromFileResult.md)
@@ -303,9 +309,11 @@ Class | Method | HTTP request | Description
303
309
  - [LocatePayload](rapidata/api_client/docs/LocatePayload.md)
304
310
  - [LocateRapidBlueprint](rapidata/api_client/docs/LocateRapidBlueprint.md)
305
311
  - [LocateResult](rapidata/api_client/docs/LocateResult.md)
312
+ - [LocationMetadata](rapidata/api_client/docs/LocationMetadata.md)
306
313
  - [LocationMetadataExistsFilterConfig](rapidata/api_client/docs/LocationMetadataExistsFilterConfig.md)
307
314
  - [LocationMetadataModel](rapidata/api_client/docs/LocationMetadataModel.md)
308
315
  - [LogicOperator](rapidata/api_client/docs/LogicOperator.md)
316
+ - [MetadataVisibilities](rapidata/api_client/docs/MetadataVisibilities.md)
309
317
  - [MultiAssetModel](rapidata/api_client/docs/MultiAssetModel.md)
310
318
  - [NaiveRefereeConfig](rapidata/api_client/docs/NaiveRefereeConfig.md)
311
319
  - [NaiveRefereeModel](rapidata/api_client/docs/NaiveRefereeModel.md)
@@ -325,6 +333,7 @@ Class | Method | HTTP request | Description
325
333
  - [OrderModel](rapidata/api_client/docs/OrderModel.md)
326
334
  - [OrderModelPagedResult](rapidata/api_client/docs/OrderModelPagedResult.md)
327
335
  - [OrderState](rapidata/api_client/docs/OrderState.md)
336
+ - [OriginalFilenameMetadata](rapidata/api_client/docs/OriginalFilenameMetadata.md)
328
337
  - [OriginalFilenameMetadataModel](rapidata/api_client/docs/OriginalFilenameMetadataModel.md)
329
338
  - [PageInfo](rapidata/api_client/docs/PageInfo.md)
330
339
  - [PipelineIdWorkflowPutRequest](rapidata/api_client/docs/PipelineIdWorkflowPutRequest.md)
@@ -337,6 +346,7 @@ Class | Method | HTTP request | Description
337
346
  - [PrivateTextMetadataInput](rapidata/api_client/docs/PrivateTextMetadataInput.md)
338
347
  - [ProbabilisticAttachCategoryRefereeConfig](rapidata/api_client/docs/ProbabilisticAttachCategoryRefereeConfig.md)
339
348
  - [ProblemDetails](rapidata/api_client/docs/ProblemDetails.md)
349
+ - [PromptMetadata](rapidata/api_client/docs/PromptMetadata.md)
340
350
  - [PromptMetadataInput](rapidata/api_client/docs/PromptMetadataInput.md)
341
351
  - [PromptMetadataModel](rapidata/api_client/docs/PromptMetadataModel.md)
342
352
  - [PublicOrderModel](rapidata/api_client/docs/PublicOrderModel.md)
@@ -376,12 +386,15 @@ Class | Method | HTTP request | Description
376
386
  - [SkipResult](rapidata/api_client/docs/SkipResult.md)
377
387
  - [SortCriterion](rapidata/api_client/docs/SortCriterion.md)
378
388
  - [SortDirection](rapidata/api_client/docs/SortDirection.md)
389
+ - [SourceUrlMetadata](rapidata/api_client/docs/SourceUrlMetadata.md)
379
390
  - [SourceUrlMetadataModel](rapidata/api_client/docs/SourceUrlMetadataModel.md)
380
391
  - [StaticSelection](rapidata/api_client/docs/StaticSelection.md)
381
392
  - [SubmitCocoModel](rapidata/api_client/docs/SubmitCocoModel.md)
382
393
  - [SubmitCocoResult](rapidata/api_client/docs/SubmitCocoResult.md)
383
394
  - [TextAssetModel](rapidata/api_client/docs/TextAssetModel.md)
395
+ - [TextMetadata](rapidata/api_client/docs/TextMetadata.md)
384
396
  - [TextMetadataModel](rapidata/api_client/docs/TextMetadataModel.md)
397
+ - [TranscriptionMetadata](rapidata/api_client/docs/TranscriptionMetadata.md)
385
398
  - [TranscriptionMetadataInput](rapidata/api_client/docs/TranscriptionMetadataInput.md)
386
399
  - [TranscriptionMetadataModel](rapidata/api_client/docs/TranscriptionMetadataModel.md)
387
400
  - [TranscriptionPayload](rapidata/api_client/docs/TranscriptionPayload.md)
@@ -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
@@ -235,11 +235,11 @@ class RapidataOrderBuilder:
235
235
  if not isinstance(asset, list):
236
236
  raise TypeError("Media paths must be provided as a list of paths.")
237
237
 
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
- # )
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
+ )
243
243
 
244
244
  if metadata:
245
245
  for data in metadata:
@@ -165,8 +165,8 @@ class RapidataOrder:
165
165
  Raises:
166
166
  Exception: If the order is not in processing state.
167
167
  """
168
- if self.get_status() != OrderState.PROCESSING:
169
- raise Exception("Order is not processing. Preview unavailable.")
168
+ if (status := self.get_status()) != OrderState.PROCESSING:
169
+ raise Exception(f"Preview only available if order is processing. current status: {status}")
170
170
 
171
171
  campaign_id = self.__get_campaign_id()
172
172
  auth_url = f"https://rapids.{self.__openapi_service.enviroment}/preview/campaign?id={campaign_id}"
@@ -247,17 +247,15 @@ 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
252
  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,
253
+ context: Optional[str] = None,
257
254
  validation_set_id: Optional[str] = None,
258
255
  filters: Sequence[RapidataFilter] = [],
259
256
  settings: Sequence[RapidataSetting] = [],
260
- selections: Optional[Sequence[RapidataSelection]] = None) -> RapidataOrder:
257
+ selections: Optional[Sequence[RapidataSelection]] = None
258
+ ) -> RapidataOrder:
261
259
  """
262
260
  Create a ranking order.
263
261
 
@@ -266,15 +264,11 @@ class RapidataOrderManager:
266
264
  instruction (str): The question asked from People when They see two datapoints.
267
265
  datapoints (list[str]): A list of datapoints that will participate in the ranking.
268
266
  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
267
  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.
268
+ random_comparisons_ratio (float, optional): The fraction of random comparisons in the ranking process.
269
+ The rest will focus on pairing similarly ranked datapoints. Defaults to 0.5 and can be left untouched.
270
+ context (str, optional): The context for all the comparison. Defaults to None.\n
271
+ If provided will be shown in addition to the instruction for all the matchups.
278
272
  validation_set_id (str, optional): The ID of the validation set. Defaults to None.\n
279
273
  If provided, one validation task will be shown infront of the datapoints that will be labeled.
280
274
  filters (Sequence[RapidataFilter], optional): The list of filters for the order. Defaults to []. Decides who the tasks should be shown to.
@@ -287,15 +281,12 @@ class RapidataOrderManager:
287
281
  name=name,
288
282
  workflow=RankingWorkflow(
289
283
  criteria=instruction,
290
- elo_start=elo_start,
291
- elo_k_factor=elo_k_factor,
292
- elo_scaling_factor=elo_scaling_factor,
293
284
  total_comparison_budget=total_comparison_budget,
294
- random_comparisons_ratio=random_comparisons_ratio
285
+ random_comparisons_ratio=random_comparisons_ratio,
286
+ context=context
295
287
  ),
296
288
  assets=assets,
297
289
  responses_per_datapoint=responses_per_comparison,
298
- contexts=contexts,
299
290
  validation_set_id=validation_set_id,
300
291
  filters=filters,
301
292
  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.14.1
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