rapidata 1.2.3__py3-none-any.whl → 1.3.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.
- rapidata/rapidata_client/dataset/rapidata_dataset.py +4 -3
- rapidata/rapidata_client/rapidata_client.py +10 -3
- rapidata/service/openapi_service.py +36 -16
- {rapidata-1.2.3.dist-info → rapidata-1.3.0.dist-info}/METADATA +1 -1
- {rapidata-1.2.3.dist-info → rapidata-1.3.0.dist-info}/RECORD +7 -7
- {rapidata-1.2.3.dist-info → rapidata-1.3.0.dist-info}/LICENSE +0 -0
- {rapidata-1.2.3.dist-info → rapidata-1.3.0.dist-info}/WHEEL +0 -0
|
@@ -41,7 +41,7 @@ class RapidataDataset:
|
|
|
41
41
|
texts = [asset.text for asset in text_asset.assets if isinstance(asset, TextAsset)]
|
|
42
42
|
else:
|
|
43
43
|
raise ValueError(f"Unsupported asset type: {type(text_asset)}")
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
model = UploadTextSourcesToDatasetModel(
|
|
46
46
|
datasetId=self.dataset_id,
|
|
47
47
|
textSources=texts
|
|
@@ -53,6 +53,7 @@ class RapidataDataset:
|
|
|
53
53
|
with ThreadPoolExecutor(max_workers=max_workers) as executor:
|
|
54
54
|
futures = [
|
|
55
55
|
executor.submit(upload_text_datapoint, text_asset)
|
|
56
|
+
for text_asset in text_assets
|
|
56
57
|
]
|
|
57
58
|
|
|
58
59
|
with tqdm(total=total_uploads, desc="Uploading text datapoints") as pbar:
|
|
@@ -70,7 +71,7 @@ class RapidataDataset:
|
|
|
70
71
|
raise ValueError(
|
|
71
72
|
"metadata must be None or have the same length as media_paths"
|
|
72
73
|
)
|
|
73
|
-
|
|
74
|
+
|
|
74
75
|
for media_path in media_paths:
|
|
75
76
|
if isinstance(media_path, MultiAsset):
|
|
76
77
|
assert all(
|
|
@@ -84,7 +85,7 @@ class RapidataDataset:
|
|
|
84
85
|
paths = [asset.path for asset in media_asset.assets if isinstance(asset, MediaAsset)]
|
|
85
86
|
else:
|
|
86
87
|
raise ValueError(f"Unsupported asset type: {type(media_asset)}")
|
|
87
|
-
|
|
88
|
+
|
|
88
89
|
assert all(
|
|
89
90
|
os.path.exists(media_path) for media_path in paths
|
|
90
91
|
), "All media paths must exist on the local filesystem."
|
|
@@ -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,
|
|
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
|
|
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
|
-
|
|
28
|
+
token = self.__fetch_token(client_id, client_secret, oauth_scope, token_url, cert_path)
|
|
25
29
|
|
|
26
|
-
|
|
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
|
+
|
|
@@ -318,7 +318,7 @@ rapidata/rapidata_client/config.py,sha256=tQLgN6k_ATOX1GzZh38At2rgBDLStV6rJ6z0vs
|
|
|
318
318
|
rapidata/rapidata_client/country_codes/__init__.py,sha256=FB9Dcks44J6C6YBSYmTmNZ71tE130x6NO_3aLJ8fKzQ,40
|
|
319
319
|
rapidata/rapidata_client/country_codes/country_codes.py,sha256=Q0HMX7uHJQDeLCFPP5bq4iYi6pgcDWEcl2ONGhjgoeU,286
|
|
320
320
|
rapidata/rapidata_client/dataset/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
321
|
-
rapidata/rapidata_client/dataset/rapidata_dataset.py,sha256=
|
|
321
|
+
rapidata/rapidata_client/dataset/rapidata_dataset.py,sha256=12mvcpHa-ZpDOFhSuqnSb6pFhR1q7rF98fgiDBuONdw,4935
|
|
322
322
|
rapidata/rapidata_client/dataset/rapidata_validation_set.py,sha256=rSRZQ67-8XjLa1_pWutieBrQfmvPA0fOMK7QKQpxsX0,10970
|
|
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
|
|
@@ -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=
|
|
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=
|
|
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.
|
|
373
|
-
rapidata-1.
|
|
374
|
-
rapidata-1.
|
|
375
|
-
rapidata-1.
|
|
372
|
+
rapidata-1.3.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
373
|
+
rapidata-1.3.0.dist-info/METADATA,sha256=wFSO1-QAg27tUA9W1zmrbWpoUWcs_HJIKLw1FfHgGrk,1012
|
|
374
|
+
rapidata-1.3.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
375
|
+
rapidata-1.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|