rapidata 2.21.1__py3-none-any.whl → 2.21.2__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.
- rapidata/rapidata_client/api/__init__.py +0 -0
- rapidata/rapidata_client/api/rapidata_exception.py +105 -0
- rapidata/rapidata_client/validation/rapids/rapids_manager.py +3 -0
- rapidata/service/openapi_service.py +2 -2
- {rapidata-2.21.1.dist-info → rapidata-2.21.2.dist-info}/METADATA +1 -1
- {rapidata-2.21.1.dist-info → rapidata-2.21.2.dist-info}/RECORD +8 -6
- {rapidata-2.21.1.dist-info → rapidata-2.21.2.dist-info}/LICENSE +0 -0
- {rapidata-2.21.1.dist-info → rapidata-2.21.2.dist-info}/WHEEL +0 -0
|
File without changes
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
from typing import Optional, Any
|
|
2
|
+
from rapidata.api_client.api_client import ApiClient, rest, ApiResponse, ApiResponseT
|
|
3
|
+
from rapidata.api_client.exceptions import ApiException
|
|
4
|
+
import json
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class RapidataError(Exception):
|
|
8
|
+
"""Custom error class for Rapidata API errors."""
|
|
9
|
+
|
|
10
|
+
def __init__(
|
|
11
|
+
self,
|
|
12
|
+
status_code: Optional[int] = None,
|
|
13
|
+
message: str | None = None,
|
|
14
|
+
original_exception: Exception | None = None,
|
|
15
|
+
details: Any = None
|
|
16
|
+
):
|
|
17
|
+
self.status_code = status_code
|
|
18
|
+
self.message = message
|
|
19
|
+
self.original_exception = original_exception
|
|
20
|
+
self.details = details
|
|
21
|
+
|
|
22
|
+
# Create a nice error message
|
|
23
|
+
error_msg = "Rapidata API Error"
|
|
24
|
+
if status_code:
|
|
25
|
+
error_msg += f" ({status_code})"
|
|
26
|
+
if message:
|
|
27
|
+
error_msg += f": {message}"
|
|
28
|
+
|
|
29
|
+
super().__init__(error_msg)
|
|
30
|
+
|
|
31
|
+
def __str__(self):
|
|
32
|
+
"""Return a string representation of the error."""
|
|
33
|
+
# Extract information from message if available
|
|
34
|
+
title = None
|
|
35
|
+
errors = None
|
|
36
|
+
trace_id = None
|
|
37
|
+
|
|
38
|
+
# Try to extract from details if available and is a dict
|
|
39
|
+
if self.details and isinstance(self.details, dict):
|
|
40
|
+
title = self.details.get('title')
|
|
41
|
+
errors = self.details.get('errors')
|
|
42
|
+
trace_id = self.details.get('traceId')
|
|
43
|
+
|
|
44
|
+
# Build the error string
|
|
45
|
+
error_parts = []
|
|
46
|
+
|
|
47
|
+
# Main error line
|
|
48
|
+
if title:
|
|
49
|
+
error_parts.append(f"{title}")
|
|
50
|
+
else:
|
|
51
|
+
error_parts.append(f"{self.message or 'Unknown error'}")
|
|
52
|
+
|
|
53
|
+
# Reasons
|
|
54
|
+
if errors:
|
|
55
|
+
if isinstance(errors, dict):
|
|
56
|
+
error_parts.append(f"Reasons: {json.dumps({'errors': errors})}")
|
|
57
|
+
else:
|
|
58
|
+
error_parts.append(f"Reasons: {errors}")
|
|
59
|
+
|
|
60
|
+
# Trace ID
|
|
61
|
+
if trace_id:
|
|
62
|
+
error_parts.append(f"Trace Id: {trace_id}")
|
|
63
|
+
else:
|
|
64
|
+
error_parts.append("Trace Id: N/A")
|
|
65
|
+
|
|
66
|
+
return "\n".join(error_parts)
|
|
67
|
+
|
|
68
|
+
class RapidataApiClient(ApiClient):
|
|
69
|
+
"""Custom API client that wraps errors in RapidataError."""
|
|
70
|
+
|
|
71
|
+
def response_deserialize(
|
|
72
|
+
self,
|
|
73
|
+
response_data: rest.RESTResponse,
|
|
74
|
+
response_types_map: Optional[dict[str, ApiResponseT]] = None
|
|
75
|
+
) -> ApiResponse[ApiResponseT]:
|
|
76
|
+
"""Override the response_deserialize method to catch and convert exceptions."""
|
|
77
|
+
try:
|
|
78
|
+
return super().response_deserialize(response_data, response_types_map)
|
|
79
|
+
except ApiException as e:
|
|
80
|
+
status_code = getattr(e, 'status', None)
|
|
81
|
+
message = str(e)
|
|
82
|
+
details = None
|
|
83
|
+
|
|
84
|
+
# Extract more detailed error message from response body if available
|
|
85
|
+
if hasattr(e, 'body') and e.body:
|
|
86
|
+
try:
|
|
87
|
+
body_json = json.loads(e.body)
|
|
88
|
+
if isinstance(body_json, dict):
|
|
89
|
+
if 'message' in body_json:
|
|
90
|
+
message = body_json['message']
|
|
91
|
+
elif 'error' in body_json:
|
|
92
|
+
message = body_json['error']
|
|
93
|
+
|
|
94
|
+
# Store the full error details for debugging
|
|
95
|
+
details = body_json
|
|
96
|
+
except (json.JSONDecodeError, AttributeError):
|
|
97
|
+
# If we can't parse the body as JSON, use the original message
|
|
98
|
+
pass
|
|
99
|
+
|
|
100
|
+
raise RapidataError(
|
|
101
|
+
status_code=status_code,
|
|
102
|
+
message=message,
|
|
103
|
+
original_exception=e,
|
|
104
|
+
details=details
|
|
105
|
+
) from None
|
|
@@ -43,6 +43,9 @@ class RapidsManager:
|
|
|
43
43
|
else:
|
|
44
44
|
raise ValueError(f"Unsupported data type: {data_type}")
|
|
45
45
|
|
|
46
|
+
if not isinstance(truths, list):
|
|
47
|
+
raise ValueError("Truths must be a list of strings")
|
|
48
|
+
|
|
46
49
|
if not all(truth in answer_options for truth in truths):
|
|
47
50
|
raise ValueError("Truths must be part of the answer options")
|
|
48
51
|
|
|
@@ -8,9 +8,9 @@ from rapidata.api_client.api.pipeline_api import PipelineApi
|
|
|
8
8
|
from rapidata.api_client.api.rapid_api import RapidApi
|
|
9
9
|
from rapidata.api_client.api.validation_api import ValidationApi
|
|
10
10
|
from rapidata.api_client.api.workflow_api import WorkflowApi
|
|
11
|
-
from rapidata.api_client.api_client import ApiClient
|
|
12
11
|
from rapidata.api_client.configuration import Configuration
|
|
13
12
|
from rapidata.service.credential_manager import CredentialManager
|
|
13
|
+
from rapidata.rapidata_client.api.rapidata_exception import RapidataApiClient
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class OpenAPIService:
|
|
@@ -36,7 +36,7 @@ class OpenAPIService:
|
|
|
36
36
|
)
|
|
37
37
|
|
|
38
38
|
client_configuration = Configuration(host=endpoint, ssl_ca_cert=cert_path)
|
|
39
|
-
self.api_client =
|
|
39
|
+
self.api_client = RapidataApiClient(
|
|
40
40
|
configuration=client_configuration,
|
|
41
41
|
header_name="X-Client",
|
|
42
42
|
header_value=f"RapidataPythonSDK/{self._get_rapidata_package_version()}",
|
|
@@ -415,6 +415,8 @@ rapidata/api_client/models/workflow_state.py,sha256=5LAK1se76RCoozeVB6oxMPb8p_5b
|
|
|
415
415
|
rapidata/api_client/rest.py,sha256=WTkaOPZhB24TG2mV7Ih5Km76lo2ySQXFjR98nyFIGIM,9013
|
|
416
416
|
rapidata/api_client_README.md,sha256=XxKjqTKsOlLbAyeUNmJWnQU2Kc7LYOsJLUZ0Q_SEIIo,55005
|
|
417
417
|
rapidata/rapidata_client/__init__.py,sha256=XP9btoeEBcUfLP_4Hi-tqmIsy__L7Q0l4LY1GRQZSKk,974
|
|
418
|
+
rapidata/rapidata_client/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
419
|
+
rapidata/rapidata_client/api/rapidata_exception.py,sha256=pJDMX5Pk1SSkxyt6PE0MCP2PQ13374qsi9SBWJYXbJI,3726
|
|
418
420
|
rapidata/rapidata_client/assets/__init__.py,sha256=hKgrOSn8gJcBSULaf4auYhH1S1N5AfcwIhBSq1BOKwQ,323
|
|
419
421
|
rapidata/rapidata_client/assets/_base_asset.py,sha256=B2YWH1NgaeYUYHDW3OPpHM_bqawHbH4EjnRCE2BYwiM,298
|
|
420
422
|
rapidata/rapidata_client/assets/_media_asset.py,sha256=9IKNKWarBJ-aAxfTjh80ScNsHlWGJnd55fsDbrf8x4s,10336
|
|
@@ -485,7 +487,7 @@ rapidata/rapidata_client/validation/rapidata_validation_set.py,sha256=GaatGGuJCH
|
|
|
485
487
|
rapidata/rapidata_client/validation/rapids/__init__.py,sha256=WU5PPwtTJlte6U90MDakzx4I8Y0laj7siw9teeXj5R0,21
|
|
486
488
|
rapidata/rapidata_client/validation/rapids/box.py,sha256=t3_Kn6doKXdnJdtbwefXnYKPiTKHneJl9E2inkDSqL8,589
|
|
487
489
|
rapidata/rapidata_client/validation/rapids/rapids.py,sha256=uCKnoSn1RykNHgTFbrvCFlfzU8lF42cff-2I-Pd48w0,4620
|
|
488
|
-
rapidata/rapidata_client/validation/rapids/rapids_manager.py,sha256=
|
|
490
|
+
rapidata/rapidata_client/validation/rapids/rapids_manager.py,sha256=s5VAq8H5CKACWfmIQuz9kHC8t2nd-xEHGGUj9pIfXKI,14386
|
|
489
491
|
rapidata/rapidata_client/validation/validation_set_manager.py,sha256=GCFDyruCz6EIN67cc2fwRjzirUoGfs3KLTIg7n6wXbI,26722
|
|
490
492
|
rapidata/rapidata_client/workflow/__init__.py,sha256=7nXcY91xkxjHudBc9H0fP35eBBtgwHGWTQKbb-M4h7Y,477
|
|
491
493
|
rapidata/rapidata_client/workflow/_base_workflow.py,sha256=XyIZFKS_RxAuwIHS848S3AyLEHqd07oTD_5jm2oUbsw,762
|
|
@@ -501,8 +503,8 @@ rapidata/rapidata_client/workflow/_timestamp_workflow.py,sha256=tPi2zu1-SlE_ppbG
|
|
|
501
503
|
rapidata/service/__init__.py,sha256=s9bS1AJZaWIhLtJX_ZA40_CK39rAAkwdAmymTMbeWl4,68
|
|
502
504
|
rapidata/service/credential_manager.py,sha256=3x-Fb6tyqmgtpjI1MSOtXWW_SkzTK8Lo7I0SSL2YD7E,8602
|
|
503
505
|
rapidata/service/local_file_service.py,sha256=pgorvlWcx52Uh3cEG6VrdMK_t__7dacQ_5AnfY14BW8,877
|
|
504
|
-
rapidata/service/openapi_service.py,sha256=
|
|
505
|
-
rapidata-2.21.
|
|
506
|
-
rapidata-2.21.
|
|
507
|
-
rapidata-2.21.
|
|
508
|
-
rapidata-2.21.
|
|
506
|
+
rapidata/service/openapi_service.py,sha256=nh7gAmNRdZ5qu3sG7khi-pZmXhfg5u8KHdmEDQd_z9U,4075
|
|
507
|
+
rapidata-2.21.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
508
|
+
rapidata-2.21.2.dist-info/METADATA,sha256=npRKolQ9iiiUYn9FbocwGWJCWYzjMTS9DJJOTLNR1Oc,1227
|
|
509
|
+
rapidata-2.21.2.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
510
|
+
rapidata-2.21.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|