dc-python-sdk 1.5.51__tar.gz → 1.6.1__tar.gz
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.
- {dc_python_sdk-1.5.51/src/dc_python_sdk.egg-info → dc_python_sdk-1.6.1}/PKG-INFO +53 -3
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/README.md +48 -1
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/pyproject.toml +8 -3
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/setup.cfg +2 -2
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1/src/dc_python_sdk.egg-info}/PKG-INFO +53 -3
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_python_sdk.egg-info/SOURCES.txt +3 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_python_sdk.egg-info/requires.txt +5 -1
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/errors.py +57 -1
- dc_python_sdk-1.6.1/src/dc_sdk/file_utils.py +1454 -0
- dc_python_sdk-1.6.1/src/dc_sdk/handler.py +122 -0
- dc_python_sdk-1.6.1/src/dc_sdk/json_safe.py +55 -0
- dc_python_sdk-1.6.1/src/dc_sdk/row_filters.py +246 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/ai.py +4 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/ai_http.py +4 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/mapping.py +32 -12
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/models/errors.py +49 -1
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/pipeline.py +66 -33
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/server.py +1 -1
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/services/api.py +16 -1
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/services/aws.py +8 -11
- dc_python_sdk-1.5.51/src/dc_sdk/handler.py +0 -241
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/LICENSE +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_python_sdk.egg-info/dependency_links.txt +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_python_sdk.egg-info/entry_points.txt +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_python_sdk.egg-info/top_level.txt +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/__init__.py +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/app.py +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/cli.py +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/data_stream.py +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/__init__.py +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/connection_status.py +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/destination_object_template.py +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/models/__init__.py +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/models/enums.py +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/models/log_templates.py +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/models/pipeline_details.py +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/services/__init__.py +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/services/environment.py +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/services/loader.py +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/services/logger.py +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/src/services/session.py +0 -0
- {dc_python_sdk-1.5.51 → dc_python_sdk-1.6.1}/src/dc_sdk/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dc-python-sdk
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6.1
|
|
4
4
|
Summary: Data Connector Python SDK
|
|
5
5
|
Home-page: https://github.com/data-connector/dc-python-sdk
|
|
6
6
|
Author: DataConnector
|
|
@@ -14,7 +14,7 @@ Description-Content-Type: text/markdown
|
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Requires-Dist: fastapi
|
|
16
16
|
Requires-Dist: uvicorn
|
|
17
|
-
Requires-Dist: awslambdaric
|
|
17
|
+
Requires-Dist: awslambdaric==4.0.4
|
|
18
18
|
Requires-Dist: requests
|
|
19
19
|
Requires-Dist: boto3>=1.40.0
|
|
20
20
|
Requires-Dist: openai
|
|
@@ -26,6 +26,9 @@ Requires-Dist: numpy>=1.21.6; extra == "test"
|
|
|
26
26
|
Requires-Dist: pandas>=1.3.5; extra == "test"
|
|
27
27
|
Provides-Extra: ai
|
|
28
28
|
Requires-Dist: openai; extra == "ai"
|
|
29
|
+
Provides-Extra: file
|
|
30
|
+
Requires-Dist: numpy>=1.21.6; extra == "file"
|
|
31
|
+
Requires-Dist: pandas>=1.3.5; extra == "file"
|
|
29
32
|
Dynamic: license-file
|
|
30
33
|
|
|
31
34
|
# Data Connector Python SDK
|
|
@@ -91,6 +94,41 @@ def get_available_objects():
|
|
|
91
94
|
return objects
|
|
92
95
|
```
|
|
93
96
|
|
|
97
|
+
### Selective discovery in the Lambda handler
|
|
98
|
+
|
|
99
|
+
Authenticate with action `3`, then request only the metadata needed by the current
|
|
100
|
+
screen with action `5`:
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{"action": 5, "sections": ["accounts"], "credentials": {}}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Connectors opt in by defining `get_metadata(self, sections=None)`. Fabric supports
|
|
107
|
+
`accounts`, `schemas`, and `folders`; callers can request more than one section.
|
|
108
|
+
Requested sections retain their usual keys in the metadata dictionary, and static
|
|
109
|
+
capability fields may also be returned. Unrequested dynamic keys are omitted,
|
|
110
|
+
not returned as empty lists. Callers should merge partial metadata into existing
|
|
111
|
+
metadata for the same account, and clear cached metadata when switching accounts.
|
|
112
|
+
|
|
113
|
+
Action `6` accepts the same optional parameter for `get_objects(self, sections=None)`;
|
|
114
|
+
Fabric supports `tables` and `files`. Use `include_metadata: false` to avoid an
|
|
115
|
+
additional full metadata request when fetching only objects. Object results remain
|
|
116
|
+
a list in the existing response envelope.
|
|
117
|
+
|
|
118
|
+
Omitting `sections` (or using null) retains full discovery. An empty list requests
|
|
119
|
+
no dynamic sections on an opted-in connector. The SDK validates a list of non-empty
|
|
120
|
+
strings and passes it only to methods with an explicit `sections` keyword; legacy
|
|
121
|
+
connectors still perform full discovery with no arguments. Each opted-in connector
|
|
122
|
+
validates its supported section names. Internal connector TypeErrors are propagated,
|
|
123
|
+
never retried as a legacy call. The SDK does not filter a legacy response or claim
|
|
124
|
+
that a legacy connector avoided fetching unrequested data.
|
|
125
|
+
|
|
126
|
+
The SDK returns `error_phase: "metadata"` for discovery errors and keeps successful
|
|
127
|
+
authentication status. `AuthenticationError` still invalidates authentication.
|
|
128
|
+
API and UI consumers must use this distinction to show a discovery retry instead
|
|
129
|
+
of requiring reconnection. This contract applies to the Lambda handler; the local
|
|
130
|
+
HTTP server below uses a separate method-based request format.
|
|
131
|
+
|
|
94
132
|
### Running the local HTTP server
|
|
95
133
|
|
|
96
134
|
Install the SDK and start the HTTP server that wraps your connector:
|
|
@@ -139,7 +177,7 @@ Our system uses the `dc_sdk` library to gracefully throw errors. This ensures:
|
|
|
139
177
|
|
|
140
178
|
## Error Categories
|
|
141
179
|
|
|
142
|
-
The SDK provides
|
|
180
|
+
The SDK provides 25 different error classes organized into logical categories. Each error is designed to handle specific failure scenarios:
|
|
143
181
|
|
|
144
182
|
### Authentication Errors
|
|
145
183
|
- `AuthenticationError` - Invalid credentials, expired tokens
|
|
@@ -152,6 +190,8 @@ The SDK provides 21 different error classes organized into logical categories. E
|
|
|
152
190
|
- `GetFieldsError` - Cannot retrieve field information
|
|
153
191
|
- `BadFieldIDError` - Invalid field ID for object
|
|
154
192
|
- `BadObjectIDError` - Object ID doesn't exist
|
|
193
|
+
- `FieldNotFoundError` - Requested fields are missing from a file or object
|
|
194
|
+
- `ObjectNotFoundError` - File or object could not be found at the source
|
|
155
195
|
|
|
156
196
|
### Data Filtering & Mapping Errors
|
|
157
197
|
- `FilterDataTypeError` - Invalid data type for filtering
|
|
@@ -160,6 +200,7 @@ The SDK provides 21 different error classes organized into logical categories. E
|
|
|
160
200
|
|
|
161
201
|
### Data Retrieval Errors
|
|
162
202
|
- `DataError` - Generic data retrieval failure
|
|
203
|
+
- `InvalidFileFormatError` - File could not be parsed or has no usable format
|
|
163
204
|
- `APIRequestError` - API returned error status
|
|
164
205
|
- `APITimeoutError` - Request timeout
|
|
165
206
|
- `APIPermissionError` - Insufficient API permissions
|
|
@@ -172,6 +213,15 @@ The SDK provides 21 different error classes organized into logical categories. E
|
|
|
172
213
|
|
|
173
214
|
### Implementation Errors
|
|
174
215
|
- `NotImplementedError` - Required method not implemented
|
|
216
|
+
- `FileUtilsDependencyError` - Connector imported `dc_sdk.file_utils` without installing pandas/numpy
|
|
217
|
+
|
|
218
|
+
File connectors can share parsing helpers with:
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
from dc_sdk.file_utils import FileConnectorUtilis
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
That import is optional. Connectors that use it must also install pandas and numpy (for example `pip install pandas numpy`). Other connectors should keep importing `from dc_sdk import errors` only, so they never load pandas.
|
|
175
225
|
|
|
176
226
|
For detailed examples and usage patterns, see the [Examples](#examples) section below.
|
|
177
227
|
|
|
@@ -61,6 +61,41 @@ def get_available_objects():
|
|
|
61
61
|
return objects
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
### Selective discovery in the Lambda handler
|
|
65
|
+
|
|
66
|
+
Authenticate with action `3`, then request only the metadata needed by the current
|
|
67
|
+
screen with action `5`:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{"action": 5, "sections": ["accounts"], "credentials": {}}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Connectors opt in by defining `get_metadata(self, sections=None)`. Fabric supports
|
|
74
|
+
`accounts`, `schemas`, and `folders`; callers can request more than one section.
|
|
75
|
+
Requested sections retain their usual keys in the metadata dictionary, and static
|
|
76
|
+
capability fields may also be returned. Unrequested dynamic keys are omitted,
|
|
77
|
+
not returned as empty lists. Callers should merge partial metadata into existing
|
|
78
|
+
metadata for the same account, and clear cached metadata when switching accounts.
|
|
79
|
+
|
|
80
|
+
Action `6` accepts the same optional parameter for `get_objects(self, sections=None)`;
|
|
81
|
+
Fabric supports `tables` and `files`. Use `include_metadata: false` to avoid an
|
|
82
|
+
additional full metadata request when fetching only objects. Object results remain
|
|
83
|
+
a list in the existing response envelope.
|
|
84
|
+
|
|
85
|
+
Omitting `sections` (or using null) retains full discovery. An empty list requests
|
|
86
|
+
no dynamic sections on an opted-in connector. The SDK validates a list of non-empty
|
|
87
|
+
strings and passes it only to methods with an explicit `sections` keyword; legacy
|
|
88
|
+
connectors still perform full discovery with no arguments. Each opted-in connector
|
|
89
|
+
validates its supported section names. Internal connector TypeErrors are propagated,
|
|
90
|
+
never retried as a legacy call. The SDK does not filter a legacy response or claim
|
|
91
|
+
that a legacy connector avoided fetching unrequested data.
|
|
92
|
+
|
|
93
|
+
The SDK returns `error_phase: "metadata"` for discovery errors and keeps successful
|
|
94
|
+
authentication status. `AuthenticationError` still invalidates authentication.
|
|
95
|
+
API and UI consumers must use this distinction to show a discovery retry instead
|
|
96
|
+
of requiring reconnection. This contract applies to the Lambda handler; the local
|
|
97
|
+
HTTP server below uses a separate method-based request format.
|
|
98
|
+
|
|
64
99
|
### Running the local HTTP server
|
|
65
100
|
|
|
66
101
|
Install the SDK and start the HTTP server that wraps your connector:
|
|
@@ -109,7 +144,7 @@ Our system uses the `dc_sdk` library to gracefully throw errors. This ensures:
|
|
|
109
144
|
|
|
110
145
|
## Error Categories
|
|
111
146
|
|
|
112
|
-
The SDK provides
|
|
147
|
+
The SDK provides 25 different error classes organized into logical categories. Each error is designed to handle specific failure scenarios:
|
|
113
148
|
|
|
114
149
|
### Authentication Errors
|
|
115
150
|
- `AuthenticationError` - Invalid credentials, expired tokens
|
|
@@ -122,6 +157,8 @@ The SDK provides 21 different error classes organized into logical categories. E
|
|
|
122
157
|
- `GetFieldsError` - Cannot retrieve field information
|
|
123
158
|
- `BadFieldIDError` - Invalid field ID for object
|
|
124
159
|
- `BadObjectIDError` - Object ID doesn't exist
|
|
160
|
+
- `FieldNotFoundError` - Requested fields are missing from a file or object
|
|
161
|
+
- `ObjectNotFoundError` - File or object could not be found at the source
|
|
125
162
|
|
|
126
163
|
### Data Filtering & Mapping Errors
|
|
127
164
|
- `FilterDataTypeError` - Invalid data type for filtering
|
|
@@ -130,6 +167,7 @@ The SDK provides 21 different error classes organized into logical categories. E
|
|
|
130
167
|
|
|
131
168
|
### Data Retrieval Errors
|
|
132
169
|
- `DataError` - Generic data retrieval failure
|
|
170
|
+
- `InvalidFileFormatError` - File could not be parsed or has no usable format
|
|
133
171
|
- `APIRequestError` - API returned error status
|
|
134
172
|
- `APITimeoutError` - Request timeout
|
|
135
173
|
- `APIPermissionError` - Insufficient API permissions
|
|
@@ -142,6 +180,15 @@ The SDK provides 21 different error classes organized into logical categories. E
|
|
|
142
180
|
|
|
143
181
|
### Implementation Errors
|
|
144
182
|
- `NotImplementedError` - Required method not implemented
|
|
183
|
+
- `FileUtilsDependencyError` - Connector imported `dc_sdk.file_utils` without installing pandas/numpy
|
|
184
|
+
|
|
185
|
+
File connectors can share parsing helpers with:
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
from dc_sdk.file_utils import FileConnectorUtilis
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
That import is optional. Connectors that use it must also install pandas and numpy (for example `pip install pandas numpy`). Other connectors should keep importing `from dc_sdk import errors` only, so they never load pandas.
|
|
145
192
|
|
|
146
193
|
For detailed examples and usage patterns, see the [Examples](#examples) section below.
|
|
147
194
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dc-python-sdk"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.6.1"
|
|
8
8
|
description = "Data Connector Python SDK"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.6"
|
|
@@ -19,7 +19,7 @@ classifiers = [
|
|
|
19
19
|
dependencies = [
|
|
20
20
|
"fastapi",
|
|
21
21
|
"uvicorn",
|
|
22
|
-
"awslambdaric",
|
|
22
|
+
"awslambdaric==4.0.4",
|
|
23
23
|
"requests",
|
|
24
24
|
"boto3>=1.40.0",
|
|
25
25
|
"openai",
|
|
@@ -38,6 +38,11 @@ ai = [
|
|
|
38
38
|
"openai",
|
|
39
39
|
]
|
|
40
40
|
|
|
41
|
+
file = [
|
|
42
|
+
"numpy>=1.21.6",
|
|
43
|
+
"pandas>=1.3.5",
|
|
44
|
+
]
|
|
45
|
+
|
|
41
46
|
[project.urls]
|
|
42
47
|
"Bug Tracker" = "https://github.com/data-connector/dc-python-sdk/issues"
|
|
43
48
|
|
|
@@ -49,4 +54,4 @@ where = ["src"]
|
|
|
49
54
|
|
|
50
55
|
[tool.pytest.ini_options]
|
|
51
56
|
pythonpath = ["src", "tests"]
|
|
52
|
-
testpaths = ["tests"]
|
|
57
|
+
testpaths = ["tests"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[metadata]
|
|
2
2
|
name = dc-python-sdk
|
|
3
|
-
version = 1.
|
|
3
|
+
version = 1.6.1
|
|
4
4
|
author = DataConnector
|
|
5
5
|
author_email = josh@dataconnector.com
|
|
6
6
|
description = A small example package
|
|
@@ -22,7 +22,7 @@ python_requires = >=3.6
|
|
|
22
22
|
install_requires =
|
|
23
23
|
fastapi
|
|
24
24
|
uvicorn
|
|
25
|
-
awslambdaric
|
|
25
|
+
awslambdaric==4.0.4
|
|
26
26
|
pycryptodome
|
|
27
27
|
requests
|
|
28
28
|
boto3>=1.40.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dc-python-sdk
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6.1
|
|
4
4
|
Summary: Data Connector Python SDK
|
|
5
5
|
Home-page: https://github.com/data-connector/dc-python-sdk
|
|
6
6
|
Author: DataConnector
|
|
@@ -14,7 +14,7 @@ Description-Content-Type: text/markdown
|
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Requires-Dist: fastapi
|
|
16
16
|
Requires-Dist: uvicorn
|
|
17
|
-
Requires-Dist: awslambdaric
|
|
17
|
+
Requires-Dist: awslambdaric==4.0.4
|
|
18
18
|
Requires-Dist: requests
|
|
19
19
|
Requires-Dist: boto3>=1.40.0
|
|
20
20
|
Requires-Dist: openai
|
|
@@ -26,6 +26,9 @@ Requires-Dist: numpy>=1.21.6; extra == "test"
|
|
|
26
26
|
Requires-Dist: pandas>=1.3.5; extra == "test"
|
|
27
27
|
Provides-Extra: ai
|
|
28
28
|
Requires-Dist: openai; extra == "ai"
|
|
29
|
+
Provides-Extra: file
|
|
30
|
+
Requires-Dist: numpy>=1.21.6; extra == "file"
|
|
31
|
+
Requires-Dist: pandas>=1.3.5; extra == "file"
|
|
29
32
|
Dynamic: license-file
|
|
30
33
|
|
|
31
34
|
# Data Connector Python SDK
|
|
@@ -91,6 +94,41 @@ def get_available_objects():
|
|
|
91
94
|
return objects
|
|
92
95
|
```
|
|
93
96
|
|
|
97
|
+
### Selective discovery in the Lambda handler
|
|
98
|
+
|
|
99
|
+
Authenticate with action `3`, then request only the metadata needed by the current
|
|
100
|
+
screen with action `5`:
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{"action": 5, "sections": ["accounts"], "credentials": {}}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Connectors opt in by defining `get_metadata(self, sections=None)`. Fabric supports
|
|
107
|
+
`accounts`, `schemas`, and `folders`; callers can request more than one section.
|
|
108
|
+
Requested sections retain their usual keys in the metadata dictionary, and static
|
|
109
|
+
capability fields may also be returned. Unrequested dynamic keys are omitted,
|
|
110
|
+
not returned as empty lists. Callers should merge partial metadata into existing
|
|
111
|
+
metadata for the same account, and clear cached metadata when switching accounts.
|
|
112
|
+
|
|
113
|
+
Action `6` accepts the same optional parameter for `get_objects(self, sections=None)`;
|
|
114
|
+
Fabric supports `tables` and `files`. Use `include_metadata: false` to avoid an
|
|
115
|
+
additional full metadata request when fetching only objects. Object results remain
|
|
116
|
+
a list in the existing response envelope.
|
|
117
|
+
|
|
118
|
+
Omitting `sections` (or using null) retains full discovery. An empty list requests
|
|
119
|
+
no dynamic sections on an opted-in connector. The SDK validates a list of non-empty
|
|
120
|
+
strings and passes it only to methods with an explicit `sections` keyword; legacy
|
|
121
|
+
connectors still perform full discovery with no arguments. Each opted-in connector
|
|
122
|
+
validates its supported section names. Internal connector TypeErrors are propagated,
|
|
123
|
+
never retried as a legacy call. The SDK does not filter a legacy response or claim
|
|
124
|
+
that a legacy connector avoided fetching unrequested data.
|
|
125
|
+
|
|
126
|
+
The SDK returns `error_phase: "metadata"` for discovery errors and keeps successful
|
|
127
|
+
authentication status. `AuthenticationError` still invalidates authentication.
|
|
128
|
+
API and UI consumers must use this distinction to show a discovery retry instead
|
|
129
|
+
of requiring reconnection. This contract applies to the Lambda handler; the local
|
|
130
|
+
HTTP server below uses a separate method-based request format.
|
|
131
|
+
|
|
94
132
|
### Running the local HTTP server
|
|
95
133
|
|
|
96
134
|
Install the SDK and start the HTTP server that wraps your connector:
|
|
@@ -139,7 +177,7 @@ Our system uses the `dc_sdk` library to gracefully throw errors. This ensures:
|
|
|
139
177
|
|
|
140
178
|
## Error Categories
|
|
141
179
|
|
|
142
|
-
The SDK provides
|
|
180
|
+
The SDK provides 25 different error classes organized into logical categories. Each error is designed to handle specific failure scenarios:
|
|
143
181
|
|
|
144
182
|
### Authentication Errors
|
|
145
183
|
- `AuthenticationError` - Invalid credentials, expired tokens
|
|
@@ -152,6 +190,8 @@ The SDK provides 21 different error classes organized into logical categories. E
|
|
|
152
190
|
- `GetFieldsError` - Cannot retrieve field information
|
|
153
191
|
- `BadFieldIDError` - Invalid field ID for object
|
|
154
192
|
- `BadObjectIDError` - Object ID doesn't exist
|
|
193
|
+
- `FieldNotFoundError` - Requested fields are missing from a file or object
|
|
194
|
+
- `ObjectNotFoundError` - File or object could not be found at the source
|
|
155
195
|
|
|
156
196
|
### Data Filtering & Mapping Errors
|
|
157
197
|
- `FilterDataTypeError` - Invalid data type for filtering
|
|
@@ -160,6 +200,7 @@ The SDK provides 21 different error classes organized into logical categories. E
|
|
|
160
200
|
|
|
161
201
|
### Data Retrieval Errors
|
|
162
202
|
- `DataError` - Generic data retrieval failure
|
|
203
|
+
- `InvalidFileFormatError` - File could not be parsed or has no usable format
|
|
163
204
|
- `APIRequestError` - API returned error status
|
|
164
205
|
- `APITimeoutError` - Request timeout
|
|
165
206
|
- `APIPermissionError` - Insufficient API permissions
|
|
@@ -172,6 +213,15 @@ The SDK provides 21 different error classes organized into logical categories. E
|
|
|
172
213
|
|
|
173
214
|
### Implementation Errors
|
|
174
215
|
- `NotImplementedError` - Required method not implemented
|
|
216
|
+
- `FileUtilsDependencyError` - Connector imported `dc_sdk.file_utils` without installing pandas/numpy
|
|
217
|
+
|
|
218
|
+
File connectors can share parsing helpers with:
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
from dc_sdk.file_utils import FileConnectorUtilis
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
That import is optional. Connectors that use it must also install pandas and numpy (for example `pip install pandas numpy`). Other connectors should keep importing `from dc_sdk import errors` only, so they never load pandas.
|
|
175
225
|
|
|
176
226
|
For detailed examples and usage patterns, see the [Examples](#examples) section below.
|
|
177
227
|
|
|
@@ -13,7 +13,10 @@ src/dc_sdk/app.py
|
|
|
13
13
|
src/dc_sdk/cli.py
|
|
14
14
|
src/dc_sdk/data_stream.py
|
|
15
15
|
src/dc_sdk/errors.py
|
|
16
|
+
src/dc_sdk/file_utils.py
|
|
16
17
|
src/dc_sdk/handler.py
|
|
18
|
+
src/dc_sdk/json_safe.py
|
|
19
|
+
src/dc_sdk/row_filters.py
|
|
17
20
|
src/dc_sdk/types.py
|
|
18
21
|
src/dc_sdk/src/__init__.py
|
|
19
22
|
src/dc_sdk/src/ai.py
|
|
@@ -9,7 +9,9 @@ class Error(Exception):
|
|
|
9
9
|
self.internal = internal
|
|
10
10
|
|
|
11
11
|
def __str__(self):
|
|
12
|
-
|
|
12
|
+
name = self.error_name if self.error_name is not None else type(self).__name__
|
|
13
|
+
msg = self.message if self.message is not None else ""
|
|
14
|
+
return f"{name}{msg}"
|
|
13
15
|
|
|
14
16
|
def to_dict(self):
|
|
15
17
|
return {
|
|
@@ -35,6 +37,8 @@ class AuthenticationError(Error):
|
|
|
35
37
|
|
|
36
38
|
:param message: An error message - WILL BE VISIBLE TO CLIENT
|
|
37
39
|
"""
|
|
40
|
+
if not message:
|
|
41
|
+
message = "Authentication failed."
|
|
38
42
|
super().__init__(message, self.error_name, self.internal)
|
|
39
43
|
self.message = message
|
|
40
44
|
self.error_name = "Authentication Error - "
|
|
@@ -340,6 +344,54 @@ class NoRowsFoundError(Error):
|
|
|
340
344
|
self.internal = True
|
|
341
345
|
|
|
342
346
|
|
|
347
|
+
class InvalidFileFormatError(Error):
|
|
348
|
+
"""Raised when a file object cannot be parsed or has no usable format."""
|
|
349
|
+
error_name = "Invalid File Format Error - "
|
|
350
|
+
internal = False
|
|
351
|
+
|
|
352
|
+
def __init__(self, message=None):
|
|
353
|
+
super().__init__(message, self.error_name, self.internal)
|
|
354
|
+
self.message = message
|
|
355
|
+
self.error_name = "Invalid File Format Error - "
|
|
356
|
+
self.internal = False
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
class FieldNotFoundError(Error):
|
|
360
|
+
"""Raised when requested fields are not present in a file or object."""
|
|
361
|
+
error_name = "Field Not Found Error - "
|
|
362
|
+
internal = False
|
|
363
|
+
|
|
364
|
+
def __init__(self, message=None):
|
|
365
|
+
super().__init__(message, self.error_name, self.internal)
|
|
366
|
+
self.message = message
|
|
367
|
+
self.error_name = "Field Not Found Error - "
|
|
368
|
+
self.internal = False
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
class ObjectNotFoundError(Error):
|
|
372
|
+
"""Raised when a file or object id cannot be found at the source."""
|
|
373
|
+
error_name = "Object Not Found Error - "
|
|
374
|
+
internal = False
|
|
375
|
+
|
|
376
|
+
def __init__(self, message=None):
|
|
377
|
+
super().__init__(message, self.error_name, self.internal)
|
|
378
|
+
self.message = message
|
|
379
|
+
self.error_name = "Object Not Found Error - "
|
|
380
|
+
self.internal = False
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
class FileUtilsDependencyError(Error):
|
|
384
|
+
"""Raised when a connector imports file utils without pandas/numpy installed."""
|
|
385
|
+
error_name = "File Utils Dependency Error - "
|
|
386
|
+
internal = False
|
|
387
|
+
|
|
388
|
+
def __init__(self, message=None):
|
|
389
|
+
super().__init__(message, self.error_name, self.internal)
|
|
390
|
+
self.message = message
|
|
391
|
+
self.error_name = "File Utils Dependency Error - "
|
|
392
|
+
self.internal = False
|
|
393
|
+
|
|
394
|
+
|
|
343
395
|
def external_errors():
|
|
344
396
|
error_list = []
|
|
345
397
|
classes = [cls[1] for cls in inspect.getmembers(sys.modules[__name__],
|
|
@@ -373,4 +425,8 @@ ERROR_MAPPING = {
|
|
|
373
425
|
"NotADestinationError": NotADestinationError,
|
|
374
426
|
"NotImplementedError": NotImplementedError,
|
|
375
427
|
"NoRowsFoundError": NoRowsFoundError,
|
|
428
|
+
"InvalidFileFormatError": InvalidFileFormatError,
|
|
429
|
+
"FieldNotFoundError": FieldNotFoundError,
|
|
430
|
+
"ObjectNotFoundError": ObjectNotFoundError,
|
|
431
|
+
"FileUtilsDependencyError": FileUtilsDependencyError,
|
|
376
432
|
}
|