rapidata 1.2.4__py3-none-any.whl → 1.3.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.

@@ -1,4 +1,10 @@
1
1
  from rapidata.api_client.models.feature_flag_model import FeatureFlagModel
2
+ from enum import StrEnum
3
+
4
+ class TranslationBehaviour(StrEnum):
5
+ BOTH = "both"
6
+ ONLY_ORIGINAL = "only original"
7
+ ONLY_TRANSLATED = "only translated"
2
8
 
3
9
 
4
10
  class FeatureFlags:
@@ -49,16 +55,22 @@ class FeatureFlags:
49
55
  self._flags["alert_on_fast_response"] = str(milliseconds)
50
56
  return self
51
57
 
52
- def disable_translation(self, value: bool = True):
53
- """Disable automatic translation of all texts in the UI.
58
+
59
+ def translation_behaviour(self, behaviour: TranslationBehaviour = TranslationBehaviour.BOTH):
60
+ """Defines what's the behaviour of the translation in the UI.
61
+
62
+ The behaviour can be set to:
63
+ - TranslationBehaviour.BOTH: Show both the original and the translated text.
64
+ - TranslationBehaviour.ONLY_ORIGINAL: Show only the original text.
65
+ - TranslationBehaviour.ONLY_TRANSLATED: Show only the translated text.
54
66
 
55
67
  Args:
56
- value (bool, optional): Whether to disable translation. Defaults to True.
68
+ behaviour (TranslationBehaviour): The translation behaviour. Defaults to TranslationBehaviour.BOTH.
57
69
 
58
70
  Returns:
59
71
  FeatureFlags: The current FeatureFlags instance for method chaining.
60
72
  """
61
- self._flags["disable_translation"] = str(value)
73
+ self._flags["translation_behaviour"] = behaviour
62
74
  return self
63
75
 
64
76
  def free_text_minimum_characters(self, value: int):
@@ -108,4 +120,4 @@ class FeatureFlags:
108
120
  FeatureFlags: The current FeatureFlags instance for method chaining.
109
121
  """
110
122
  self._flags[key] = value
111
- return self
123
+ return self
@@ -11,7 +11,6 @@ from rapidata.rapidata_client.dataset.rapidata_dataset import RapidataDataset
11
11
  from rapidata.rapidata_client.simple_builders.simple_classification_builders import ClassificationQuestionBuilder
12
12
  from rapidata.rapidata_client.simple_builders.simple_compare_builders import CompareCriteriaBuilder
13
13
 
14
-
15
14
  class RapidataClient:
16
15
  """The Rapidata client is the main entry point for interacting with the Rapidata API. It allows you to create orders and validation sets. For creating a new order, check out `new_order()`. For creating a new validation set, check out `new_validation_set()`."""
17
16
 
@@ -20,6 +19,9 @@ class RapidataClient:
20
19
  client_id: str,
21
20
  client_secret: str,
22
21
  endpoint: str = "https://api.app.rapidata.ai",
22
+ token_url: str = "https://api.app.rapidata.ai/connect/token",
23
+ oauth_scope: str = "openid",
24
+ cert_path: str | None = None,
23
25
  ):
24
26
  """Initialize the RapidataClient. Best practice is to store the client ID and client secret in environment variables. Ask your Rapidata representative for the client ID and client secret.
25
27
 
@@ -29,7 +31,12 @@ class RapidataClient:
29
31
  endpoint (str, optional): The API endpoint URL.
30
32
  """
31
33
  self.openapi_service = OpenAPIService(
32
- client_id=client_id, client_secret=client_secret, endpoint=endpoint
34
+ client_id=client_id,
35
+ client_secret=client_secret,
36
+ endpoint=endpoint,
37
+ token_url=token_url,
38
+ oauth_scope=oauth_scope,
39
+ cert_path=cert_path
33
40
  )
34
41
 
35
42
  def new_order(self, name: str) -> RapidataOrderBuilder:
@@ -64,7 +71,7 @@ class RapidataClient:
64
71
  RapidataValidationSet: The ValidationSet instance.
65
72
  """
66
73
  return RapidataValidationSet(validation_set_id, self.openapi_service)
67
-
74
+
68
75
  def get_order(self, order_id: str) -> RapidataOrder:
69
76
  """Get an order by ID.
70
77
 
@@ -1,13 +1,14 @@
1
+ import json
2
+ import requests
3
+ from rapidata.api_client.api.campaign_api import CampaignApi
1
4
  from rapidata.api_client.api.dataset_api import DatasetApi
2
- from rapidata.api_client.api.identity_api import IdentityApi
3
5
  from rapidata.api_client.api.order_api import OrderApi
6
+ from rapidata.api_client.api.pipeline_api import PipelineApi
4
7
  from rapidata.api_client.api.rapid_api import RapidApi
5
8
  from rapidata.api_client.api.validation_api import ValidationApi
9
+ from rapidata.api_client.api.workflow_api import WorkflowApi
6
10
  from rapidata.api_client.api_client import ApiClient
7
11
  from rapidata.api_client.configuration import Configuration
8
- from rapidata.api_client.api.campaign_api import CampaignApi
9
- from rapidata.api_client.api.pipeline_api import PipelineApi
10
- from rapidata.api_client.api.workflow_api import WorkflowApi
11
12
 
12
13
 
13
14
  class OpenAPIService:
@@ -16,19 +17,17 @@ class OpenAPIService:
16
17
  self,
17
18
  client_id: str,
18
19
  client_secret: str,
19
- endpoint: str = "https://api.rapidata.ai",
20
+ endpoint: str,
21
+ token_url: str,
22
+ oauth_scope: str,
23
+ cert_path: str | None = None,
20
24
  ):
21
- client_configuration = Configuration(host=endpoint)
25
+ client_configuration = Configuration(host=endpoint, ssl_ca_cert=cert_path)
22
26
  self.api_client = ApiClient(configuration=client_configuration)
23
27
 
24
- identity_api = IdentityApi(self.api_client)
28
+ token = self.__fetch_token(client_id, client_secret, oauth_scope, token_url, cert_path)
25
29
 
26
- result = identity_api.identity_get_client_auth_token_post(
27
- client_id=client_id,
28
- _headers={"Authorization": f"Basic {client_secret}"},
29
- )
30
-
31
- client_configuration.api_key["bearer"] = f"Bearer {result.auth_token}"
30
+ client_configuration.api_key["bearer"] = f"Bearer {token}"
32
31
  self._api_client = ApiClient()
33
32
  self._order_api = OrderApi(self.api_client)
34
33
  self._dataset_api = DatasetApi(self.api_client)
@@ -48,15 +47,36 @@ class OpenAPIService:
48
47
  @property
49
48
  def rapid_api(self) -> RapidApi:
50
49
  return RapidApi(self.api_client)
51
-
50
+
52
51
  @property
53
52
  def campaign_api(self) -> CampaignApi:
54
53
  return CampaignApi(self.api_client)
55
-
54
+
56
55
  @property
57
56
  def pipeline_api(self) -> PipelineApi:
58
57
  return PipelineApi(self.api_client)
59
-
58
+
60
59
  @property
61
60
  def workflow_api(self) -> WorkflowApi:
62
61
  return WorkflowApi(self.api_client)
62
+
63
+ @staticmethod
64
+ def __fetch_token(client_id: str, client_secret: str, scope: str, token_url: str, cert_path: str | None = None) -> str:
65
+ try:
66
+ return requests.post(
67
+ token_url,
68
+ data={
69
+ 'grant_type': 'client_credentials',
70
+ 'client_id': client_id,
71
+ 'client_secret': client_secret,
72
+ 'scope': scope,
73
+ },
74
+ verify=cert_path
75
+ ).json()['access_token']
76
+ except requests.RequestException as e:
77
+ raise Exception(f"Failed to fetch token: {e}")
78
+ except json.JSONDecodeError as e:
79
+ raise Exception(f"Failed to parse token response: {e}")
80
+ except KeyError as e:
81
+ raise Exception(f"Failed to extract token from response: {e}")
82
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rapidata
3
- Version: 1.2.4
3
+ Version: 1.3.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
@@ -323,7 +323,7 @@ rapidata/rapidata_client/dataset/rapidata_validation_set.py,sha256=rSRZQ67-8XjLa
323
323
  rapidata/rapidata_client/dataset/validation_rapid_parts.py,sha256=uzpOZFqQu8bG6vmjcWWUNJPZsRe28OmnyalRE6ry8tk,2317
324
324
  rapidata/rapidata_client/dataset/validation_set_builder.py,sha256=xPZBzNRPausIbYNRVinIhsVGnKSIIuxP5tjKkV4hOyo,7990
325
325
  rapidata/rapidata_client/feature_flags/__init__.py,sha256=IYkcK_bZCl5RfyQFiWjjUdz4y0jipiW9qfeopq4EjQQ,40
326
- rapidata/rapidata_client/feature_flags/feature_flags.py,sha256=hcS9YRzpsPWpZfw-3QwSuf2TaVg-MOHBxY788oNqIW4,3957
326
+ rapidata/rapidata_client/feature_flags/feature_flags.py,sha256=r8imkH_e2NPGjqHMUjLF0qbYHajuu0gMv1z5Ep4Gm3c,4478
327
327
  rapidata/rapidata_client/filter/__init__.py,sha256=F3JsMCbAZWH7SNdgaj98ydTqgCCKXKBhLyt9gQ4x6tQ,301
328
328
  rapidata/rapidata_client/filter/age_filter.py,sha256=hncr1zNM_HrO0fCta8h0LgTCB8Ufv_vI5_cGhMb-xr8,478
329
329
  rapidata/rapidata_client/filter/base_filter.py,sha256=nXraj72cumyQjjYoo4MMpnlE0aWjAIOmGakKf0MNqps,135
@@ -341,7 +341,7 @@ rapidata/rapidata_client/metadata/transcription_metadata.py,sha256=THtDEVCON4Ulc
341
341
  rapidata/rapidata_client/order/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
342
342
  rapidata/rapidata_client/order/rapidata_order.py,sha256=Q2orpb1NV7XiEAOJD0md93uLpYI1RFfr7mqDJDLk4m4,4643
343
343
  rapidata/rapidata_client/order/rapidata_order_builder.py,sha256=YBTQ7iXsMF2ALjDRE_NRApKJJYvsJ1fGniJGrDJEN_g,15868
344
- rapidata/rapidata_client/rapidata_client.py,sha256=s3TlhYlvMuxcyEDIFDqpwRsP0SIi9b158uIHLUyV1gY,4699
344
+ rapidata/rapidata_client/rapidata_client.py,sha256=d8r9C3PCXdqnV7k3xY5A4fUh_96pCro9VWzLTae--l4,4966
345
345
  rapidata/rapidata_client/referee/__init__.py,sha256=Ow9MQsONhF4sX2wFK9jbvSBrpcJgtq3OglIQMkBUdIY,167
346
346
  rapidata/rapidata_client/referee/base_referee.py,sha256=bMy7cw0a-pGNbFu6u_1_Jplu0A483Ubj4oDQzh8vu8k,493
347
347
  rapidata/rapidata_client/referee/classify_early_stopping_referee.py,sha256=B5wsqKM3_Oc1TU_MFGiIyiXjwK1LcmaVjhzLdaL8Cgw,1797
@@ -366,10 +366,10 @@ rapidata/rapidata_client/workflow/free_text_workflow.py,sha256=VaypoG3yKgsbtVyqx
366
366
  rapidata/rapidata_client/workflow/transcription_workflow.py,sha256=_KDtGCdRhauJm3jQHpwhY-Hq79CLg5I8q2RgOz5lo1g,1404
367
367
  rapidata/service/__init__.py,sha256=s9bS1AJZaWIhLtJX_ZA40_CK39rAAkwdAmymTMbeWl4,68
368
368
  rapidata/service/local_file_service.py,sha256=pgorvlWcx52Uh3cEG6VrdMK_t__7dacQ_5AnfY14BW8,877
369
- rapidata/service/openapi_service.py,sha256=KwFJmgnyfrzmSjs6wGh5J6ESMLvtKazGcYoewWeL8PU,2038
369
+ rapidata/service/openapi_service.py,sha256=pGcOCttKZW0PVCSM7Kfehe5loh7CxmmDDbu4UJbamnI,2770
370
370
  rapidata/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
371
371
  rapidata/utils/image_utils.py,sha256=TldO3eJWG8IhfJjm5MfNGO0mEDm1mQTsRoA0HLU1Uxs,404
372
- rapidata-1.2.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
373
- rapidata-1.2.4.dist-info/METADATA,sha256=mxCsVK9pFmWon7FhPSLcm8PzSE7_B48T0OJo3FGxLqc,1012
374
- rapidata-1.2.4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
375
- rapidata-1.2.4.dist-info/RECORD,,
372
+ rapidata-1.3.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
373
+ rapidata-1.3.1.dist-info/METADATA,sha256=1v9m12XMve-YQFq87fyiQ34qGB8L1XtF1OhKKhq9t3k,1012
374
+ rapidata-1.3.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
375
+ rapidata-1.3.1.dist-info/RECORD,,