data-connect-hub 0.1.0__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.
- data_connect_hub-0.1.0/LICENSE +201 -0
- data_connect_hub-0.1.0/MANIFEST.in +7 -0
- data_connect_hub-0.1.0/PKG-INFO +316 -0
- data_connect_hub-0.1.0/README.md +278 -0
- data_connect_hub-0.1.0/pyproject.toml +108 -0
- data_connect_hub-0.1.0/setup.cfg +4 -0
- data_connect_hub-0.1.0/src/data_connect_hub/__init__.py +75 -0
- data_connect_hub-0.1.0/src/data_connect_hub/_auth.py +72 -0
- data_connect_hub-0.1.0/src/data_connect_hub/_flight.py +342 -0
- data_connect_hub-0.1.0/src/data_connect_hub/_rest.py +331 -0
- data_connect_hub-0.1.0/src/data_connect_hub/client.py +326 -0
- data_connect_hub-0.1.0/src/data_connect_hub/exceptions.py +88 -0
- data_connect_hub-0.1.0/src/data_connect_hub/models.py +146 -0
- data_connect_hub-0.1.0/src/data_connect_hub/py.typed +0 -0
- data_connect_hub-0.1.0/src/data_connect_hub.egg-info/PKG-INFO +316 -0
- data_connect_hub-0.1.0/src/data_connect_hub.egg-info/SOURCES.txt +26 -0
- data_connect_hub-0.1.0/src/data_connect_hub.egg-info/dependency_links.txt +1 -0
- data_connect_hub-0.1.0/src/data_connect_hub.egg-info/requires.txt +17 -0
- data_connect_hub-0.1.0/src/data_connect_hub.egg-info/scm_file_list.json +28 -0
- data_connect_hub-0.1.0/src/data_connect_hub.egg-info/scm_version.json +8 -0
- data_connect_hub-0.1.0/src/data_connect_hub.egg-info/top_level.txt +1 -0
- data_connect_hub-0.1.0/tests/__init__.py +0 -0
- data_connect_hub-0.1.0/tests/conftest.py +72 -0
- data_connect_hub-0.1.0/tests/test_auth.py +113 -0
- data_connect_hub-0.1.0/tests/test_client.py +373 -0
- data_connect_hub-0.1.0/tests/test_flight.py +849 -0
- data_connect_hub-0.1.0/tests/test_models.py +240 -0
- data_connect_hub-0.1.0/tests/test_rest.py +758 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Controls sdist (.tar.gz) contents only; the wheel is unaffected.
|
|
2
|
+
#
|
|
3
|
+
# setuptools-scm installs a file-finder that replaces setuptools' default sdist
|
|
4
|
+
# file set with "everything git tracks under sdk/python". That silently pulled
|
|
5
|
+
# examples/ (including quickstart.ipynb) into the sdist, which was never shipped
|
|
6
|
+
# before the setuptools-scm migration. They are documentation, not runtime code.
|
|
7
|
+
prune examples
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: data-connect-hub
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for the Data Connect Hub service
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/opendatahub-io/data-connect-hub
|
|
7
|
+
Project-URL: Repository, https://github.com/opendatahub-io/data-connect-hub
|
|
8
|
+
Project-URL: Documentation, https://opendatahub-io.github.io/data-connect-hub/
|
|
9
|
+
Project-URL: Issues, https://github.com/opendatahub-io/data-connect-hub/issues
|
|
10
|
+
Keywords: data,data-connect-hub,data-connectivity,flight-sql,opendatahub
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: httpx<1,>=0.27
|
|
23
|
+
Requires-Dist: pydantic<3,>=2.0
|
|
24
|
+
Provides-Extra: flight
|
|
25
|
+
Requires-Dist: adbc-driver-flightsql>=1.0.0; extra == "flight"
|
|
26
|
+
Requires-Dist: pyarrow>=14.0; extra == "flight"
|
|
27
|
+
Requires-Dist: pandas>=2.0; extra == "flight"
|
|
28
|
+
Requires-Dist: protobuf>=6.33.5; extra == "flight"
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
31
|
+
Requires-Dist: numpy<2.5; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest-cov>=5.0; extra == "dev"
|
|
34
|
+
Requires-Dist: ruff>=0.5; extra == "dev"
|
|
35
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
36
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
# Data Connect Hub Python SDK
|
|
40
|
+
|
|
41
|
+
Python client library for the [Data Connect Hub](https://github.com/opendatahub-io/data-connect-hub) service.
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# REST only (default)
|
|
47
|
+
pip install data-connect-hub
|
|
48
|
+
|
|
49
|
+
# REST + Flight SQL
|
|
50
|
+
pip install "data-connect-hub[flight]"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
To install from a source checkout, use `pip install sdk/python` or
|
|
54
|
+
`pip install "sdk/python[flight]"`.
|
|
55
|
+
|
|
56
|
+
TestPyPI builds are PEP 440 development releases, so `--pre` is required. Install
|
|
57
|
+
the SDK without dependencies from TestPyPI, then install its dependencies from
|
|
58
|
+
PyPI only:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install --pre --no-deps \
|
|
62
|
+
--index-url https://test.pypi.org/simple/ \
|
|
63
|
+
data-connect-hub
|
|
64
|
+
pip install --index-url https://pypi.org/simple/ \
|
|
65
|
+
"httpx>=0.27,<1" "pydantic>=2,<3"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Installing from a GitHub source archive (`.../archive/main.tar.gz`) fails: archives
|
|
69
|
+
carry no `.git` directory, so `setuptools-scm` cannot derive a version. This is
|
|
70
|
+
deliberate — a silent fallback version would sort unpredictably against published
|
|
71
|
+
releases. Install from Git instead:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install "git+https://github.com/opendatahub-io/data-connect-hub.git#subdirectory=sdk/python"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Quick Start
|
|
78
|
+
|
|
79
|
+
The client takes a single gateway `endpoint` — a host or `host:port`, no scheme required — and derives both the REST (`https://`) and Flight SQL (`grpc+tls://`) URLs from it. Only TLS endpoints are supported; use `insecure=True` or `ca_cert=` to control certificate verification.
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from data_connect_hub import CredentialsRef, DataConnectClient
|
|
83
|
+
|
|
84
|
+
client = DataConnectClient(
|
|
85
|
+
endpoint="dch.example.com:8443",
|
|
86
|
+
token="<your-token>", # or use token_provider= for auto-refresh
|
|
87
|
+
tenant_id="my-tenant",
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# Or use a token provider for automatic refresh on 401:
|
|
91
|
+
client = DataConnectClient(
|
|
92
|
+
endpoint="dch.example.com:8443",
|
|
93
|
+
token_provider=lambda: get_fresh_token(), # your function; called once, cached, refreshed on 401
|
|
94
|
+
tenant_id="my-tenant",
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
# List connections (REST)
|
|
98
|
+
connections = client.list_connections()
|
|
99
|
+
|
|
100
|
+
# Get a specific connection
|
|
101
|
+
conn = client.get_connection("conn-id")
|
|
102
|
+
|
|
103
|
+
# Create a connection
|
|
104
|
+
conn = client.create_connection(
|
|
105
|
+
name="my-db",
|
|
106
|
+
connection_type_id="dct-a1b2c3d4",
|
|
107
|
+
data_format="tabular", # DataFormat: "tabular" | "binary"
|
|
108
|
+
credentials_ref=CredentialsRef(secret="secret/my-db"),
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
# Query data via Flight SQL
|
|
112
|
+
table = client.read("SELECT * FROM prompts", connection_id="conn-uuid")
|
|
113
|
+
df = table.to_pandas()
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## API Reference
|
|
117
|
+
|
|
118
|
+
The REST API is the source of truth for every model below. See the [REST API reference](https://opendatahub-io.github.io/data-connect-hub/) for the full request/response schemas.
|
|
119
|
+
|
|
120
|
+
### Connection Types (REST)
|
|
121
|
+
|
|
122
|
+
Connection types describe a category of data source (e.g. PostgreSQL). They define the provider backend and the credential fields required to connect.
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
client.list_connection_types() -> list[ConnectionType]
|
|
126
|
+
client.get_connection_type(type_id) -> ConnectionType
|
|
127
|
+
client.create_connection_type(name=..., provider=..., description=..., credentials_fields=...) -> ConnectionType
|
|
128
|
+
client.update_connection_type(type_id, name=..., provider=..., description=..., credentials_fields=...) -> ConnectionType
|
|
129
|
+
client.delete_connection_type(type_id) -> None
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### `ConnectionType`
|
|
133
|
+
|
|
134
|
+
| Field | Type | Description |
|
|
135
|
+
|---|---|---|
|
|
136
|
+
| `id` | `str` | Unique identifier |
|
|
137
|
+
| `name` | `str` | Display name |
|
|
138
|
+
| `provider` | `str` | Backend driver (e.g. `"postgres"`) |
|
|
139
|
+
| `description` | `str \| None` | Optional description |
|
|
140
|
+
| `tenant_id` | `str` | Owning namespace |
|
|
141
|
+
| `created_at` | `datetime \| None` | Creation timestamp |
|
|
142
|
+
| `updated_at` | `datetime \| None` | Last update timestamp |
|
|
143
|
+
| `credentials_fields` | `list[CredentialField]` | Credential fields required to connect |
|
|
144
|
+
| `status` | `ConnectionTypeStatus` | Transports the provider supports |
|
|
145
|
+
|
|
146
|
+
Pass `id` as the `type_id` argument to `get_connection_type`, `update_connection_type`, and `delete_connection_type` — and as `connection_type_id` to `create_connection`.
|
|
147
|
+
|
|
148
|
+
`status.capabilities` reports which transports the provider supports (`flight` and `rest`, both `bool`), so you can check before issuing a Flight SQL query:
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
ct = client.get_connection_type("dct-a1b2c3d4")
|
|
152
|
+
if ct.status.capabilities.flight:
|
|
153
|
+
table = client.read("SELECT * FROM prompts", connection_id=conn.id)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### `CredentialField`
|
|
157
|
+
|
|
158
|
+
Describes a single input field in the connection credential form.
|
|
159
|
+
|
|
160
|
+
| Field | Type | Description |
|
|
161
|
+
|---|---|---|
|
|
162
|
+
| `name` | `str` | Field key (used as the secret key) |
|
|
163
|
+
| `label` | `str` | Human-readable label |
|
|
164
|
+
| `description` | `str \| None` | Optional help text |
|
|
165
|
+
| `required` | `bool` | Whether the field must be provided |
|
|
166
|
+
| `type` | `str` | Rendering hint for the form (see below) |
|
|
167
|
+
| `enum_values` | `list[EnumValue] \| None` | Allowed values when `type` is `"enum"` |
|
|
168
|
+
| `default_value` | `str \| None` | Optional default value |
|
|
169
|
+
|
|
170
|
+
`EnumValue` has two fields: `value` (the stored string) and `label` (the display string).
|
|
171
|
+
|
|
172
|
+
**`type` values:**
|
|
173
|
+
|
|
174
|
+
| Value | Meaning |
|
|
175
|
+
|---|---|
|
|
176
|
+
| `"string"` | Free-text single-line input |
|
|
177
|
+
| `"enum"` | One of `enum_values` |
|
|
178
|
+
|
|
179
|
+
`type` is a free-form string that only tells a client how to render the input — the server neither validates nor interprets it. Its one credential check is that every field with `required=True` is present in the submitted secret. Every connection type shipped in [`config/connection-types/`](../../config/connection-types/) uses `"string"`; your own may use any other value (e.g. `"password"` to hint that input should be masked), and clients that do not recognize it should treat it as `"string"`. The authoritative definition is the `Field` schema in the [REST API reference](https://opendatahub-io.github.io/data-connect-hub/).
|
|
180
|
+
|
|
181
|
+
### Connection Management (REST)
|
|
182
|
+
|
|
183
|
+
A connection pairs a connection type with the actual credentials (stored in a Kubernetes secret) and tracks the live status of the data source.
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
client.list_connections() -> list[DataConnection]
|
|
187
|
+
client.get_connection(connection_id) -> DataConnection
|
|
188
|
+
client.create_connection(name=..., connection_type_id=..., data_format=..., credentials_ref=..., properties=...) -> DataConnection
|
|
189
|
+
client.update_connection(connection_id, name=..., connection_type_id=..., data_format=..., credentials_ref=...) -> DataConnection
|
|
190
|
+
client.delete_connection(connection_id) -> None
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
#### `DataConnection`
|
|
194
|
+
|
|
195
|
+
| Field | Type | Description |
|
|
196
|
+
|---|---|---|
|
|
197
|
+
| `id` | `str` | Unique identifier |
|
|
198
|
+
| `name` | `str` | Display name |
|
|
199
|
+
| `data_connection_type_id` | `str` | `id` of the associated `ConnectionType` |
|
|
200
|
+
| `format` | `"tabular" \| "binary"` | Data format of the source (see below) |
|
|
201
|
+
| `tenant_id` | `str` | Owning namespace |
|
|
202
|
+
| `created_at` | `datetime` | Creation timestamp |
|
|
203
|
+
| `updated_at` | `datetime` | Last update timestamp |
|
|
204
|
+
| `credentials_ref` | `CredentialsRef` | Credential secret reference |
|
|
205
|
+
| `properties` | `dict[str, str]` | Driver-specific properties (values masked in repr) |
|
|
206
|
+
| `status` | `DataConnectionStatus` | Live connection health |
|
|
207
|
+
|
|
208
|
+
Pass `id` as the `connection_id` argument to `get_connection`, `update_connection`, `delete_connection`, and the Flight SQL methods.
|
|
209
|
+
|
|
210
|
+
**`format` values:**
|
|
211
|
+
|
|
212
|
+
| Value | Meaning | Providers |
|
|
213
|
+
|---|---|---|
|
|
214
|
+
| `"tabular"` | Queried with SQL, returns rows | `postgres`, `sqlite`, `elasticsearch`, `milvus`, `neo4j`, `uri`, `s3` |
|
|
215
|
+
| `"binary"` | Opaque objects addressed by path | `s3`, `uri` |
|
|
216
|
+
|
|
217
|
+
Tabular connections are read with the [Flight SQL methods](#tabular-data-queries-flight-sql). Binary connections are managed through the same REST methods as tabular ones, but reading their contents uses a separate Flight download path that **this SDK does not wrap yet** — there is no `client.download(...)`. Until it is added, use `pyarrow.flight` directly; see [`hack/py-tools/samples/binary_download.py`](../../hack/py-tools/samples/binary_download.py).
|
|
218
|
+
|
|
219
|
+
You normally set `format` once, at `create_connection`, but it is not immutable: `update_connection(connection_id, data_format=...)` changes it, and the server accepts the new value without checking it against the provider or re-evaluating `status`. So switching a `postgres` connection to `binary` succeeds, leaves `status` reporting `ready`, and fails only when you try to read.
|
|
220
|
+
|
|
221
|
+
`credentials_ref` is a reference to a Kubernetes secret containing the connection credentials. Use `CredentialsRef(secret="secret-name")` where `secret-name` is the **name** of an existing secret in the tenant namespace (the namespace named by the connection's `tenant_id` that you passed to `DataConnectClient`). This is a bare secret name, not a `namespace/name` pair; cross-namespace references are not supported. If the secret is missing or unreadable, `status.state` becomes `"not_ready"`. The secret's keys must cover every `CredentialField` on the connection type that has `required=True`.
|
|
222
|
+
|
|
223
|
+
**`DataConnectionStatus`:**
|
|
224
|
+
|
|
225
|
+
| Field | Type | Description |
|
|
226
|
+
|---|---|---|
|
|
227
|
+
| `state` | `"ready" \| "ingestion_not_ready" \| "not_ready"` | Connection health (see below) |
|
|
228
|
+
| `message` | `str \| None` | Status detail message |
|
|
229
|
+
| `updated_at` | `datetime \| None` | When the status was last evaluated |
|
|
230
|
+
|
|
231
|
+
**`state` values:**
|
|
232
|
+
|
|
233
|
+
| Value | Meaning |
|
|
234
|
+
|---|---|
|
|
235
|
+
| `"ready"` | Credentials are valid and the source is queryable |
|
|
236
|
+
| `"ingestion_not_ready"` | Credentials are valid, but the source cannot be queried |
|
|
237
|
+
| `"not_ready"` | The referenced secret is missing or invalid |
|
|
238
|
+
|
|
239
|
+
### Tabular Data Queries (Flight SQL)
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
client.read(sql, connection_id) -> pyarrow.Table # full result as Arrow Table
|
|
243
|
+
client.read_pandas(sql, connection_id) -> pd.DataFrame # full result as pandas DataFrame
|
|
244
|
+
client.read_batches(sql, connection_id) -> Generator[RecordBatch] # stream of Arrow RecordBatches
|
|
245
|
+
client.get_tables(connection_id) -> pyarrow.Table # table metadata
|
|
246
|
+
client.server_info() -> dict # server metadata
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
`read_batches` returns a generator that streams results instead of buffering the full result set in memory. The underlying cursor and connection are closed automatically when the generator is exhausted or garbage-collected:
|
|
250
|
+
|
|
251
|
+
```python
|
|
252
|
+
for batch in client.read_batches("SELECT * FROM prompts", "conn-uuid"):
|
|
253
|
+
process(batch)
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
A server-side failure surfaced mid-stream raises `DCHQueryError`. Automatic token refresh applies when the stream is opened; an authentication failure that occurs after the stream is open is not retried.
|
|
257
|
+
|
|
258
|
+
These require the `flight` extra. On a REST-only install the client still imports and all REST calls work; the first Flight call raises `DCHConfigError` telling you to install `data-connect-hub[flight]`.
|
|
259
|
+
|
|
260
|
+
## Error Handling
|
|
261
|
+
|
|
262
|
+
Every failure raised by the SDK derives from `DCHError`, so a single `except` covers transport failures, HTTP errors, and malformed responses alike:
|
|
263
|
+
|
|
264
|
+
```python
|
|
265
|
+
from data_connect_hub import DCHError, DCHNotFoundError
|
|
266
|
+
|
|
267
|
+
try:
|
|
268
|
+
conn = client.get_connection("conn-uuid")
|
|
269
|
+
except DCHNotFoundError:
|
|
270
|
+
...
|
|
271
|
+
except DCHError as exc: # connection, timeout, auth, schema drift, ...
|
|
272
|
+
...
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
| Exception | Raised when |
|
|
276
|
+
|---|---|
|
|
277
|
+
| `DCHConfigError` | Invalid client configuration or argument (e.g. a blank id) |
|
|
278
|
+
| `DCHConnectionError` | The server was unreachable or the transport failed |
|
|
279
|
+
| `DCHTimeoutError` | The request exceeded `rest_timeout` |
|
|
280
|
+
| `DCHAuthenticationError` / `DCHForbiddenError` | HTTP 401 / 403 |
|
|
281
|
+
| `DCHNotFoundError` | HTTP 404 |
|
|
282
|
+
| `DCHValidationError` | HTTP 400 / 422 |
|
|
283
|
+
| `DCHServerError` | HTTP 5xx |
|
|
284
|
+
| `DCHResponseError` | The response was not JSON, or did not match the expected schema |
|
|
285
|
+
| `DCHQueryError` | A Flight SQL query failed |
|
|
286
|
+
|
|
287
|
+
Transient failures — HTTP 429/502/503/504, timeouts, and network or protocol errors — are retried automatically with exponential backoff on idempotent methods. See `max_retries`, `backoff_base`, and `backoff_max`.
|
|
288
|
+
|
|
289
|
+
## Requirements
|
|
290
|
+
|
|
291
|
+
- Python 3.11+
|
|
292
|
+
- Core dependencies: httpx, pydantic
|
|
293
|
+
- Flight SQL extras: adbc-driver-flightsql, pyarrow, pandas (`pip install "data-connect-hub[flight]"`)
|
|
294
|
+
|
|
295
|
+
## Releases
|
|
296
|
+
|
|
297
|
+
The package version is derived from Git history by `setuptools-scm` — there is no
|
|
298
|
+
version file to bump. Building therefore requires a full clone with tags; a shallow
|
|
299
|
+
clone or a tree without usable package metadata fails to build.
|
|
300
|
+
|
|
301
|
+
**TestPyPI (pre-release).** Run the *Publish Python SDK to TestPyPI* workflow manually
|
|
302
|
+
from the Actions tab. The version is a development release derived from the distance
|
|
303
|
+
since the last tag, for example `0.1.devN` before the first tag exists and
|
|
304
|
+
`0.1.1.dev12` after `sdk-v0.1.0`. Re-dispatching on an already-published commit produces
|
|
305
|
+
the same version and fails on the duplicate upload; land a commit first.
|
|
306
|
+
|
|
307
|
+
**PyPI (tagged release).** Push an SDK-specific tag of `sdk-v` followed by the PEP 440
|
|
308
|
+
version, for example `sdk-v0.1.0`; the tag is what defines the published version. The
|
|
309
|
+
*Release Python SDK* workflow builds and validates the distribution, publishes it to PyPI
|
|
310
|
+
using trusted publishing, then creates the GitHub Release.
|
|
311
|
+
|
|
312
|
+
Locally, `make sdk-package-check` builds and validates the distribution the same way CI does.
|
|
313
|
+
|
|
314
|
+
## Contributing
|
|
315
|
+
|
|
316
|
+
See [CONTRIBUTING.md](../../CONTRIBUTING.md) for development setup, commands, and contribution guidelines.
|