telmai 0.2.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.
- telmai-0.2.0/.gitignore +53 -0
- telmai-0.2.0/LICENSE +202 -0
- telmai-0.2.0/NOTICE +7 -0
- telmai-0.2.0/PKG-INFO +295 -0
- telmai-0.2.0/README.md +263 -0
- telmai-0.2.0/docs/history/README.md +21 -0
- telmai-0.2.0/examples/01_find_your_assets.py +65 -0
- telmai-0.2.0/examples/02_gate_a_pipeline.py +55 -0
- telmai-0.2.0/examples/03_quarantine_and_notify.py +63 -0
- telmai-0.2.0/examples/04_onboard_a_table.py +122 -0
- telmai-0.2.0/examples/05_manage_monitors.py +84 -0
- telmai-0.2.0/examples/06_monitors_as_code.py +93 -0
- telmai-0.2.0/examples/07_run_and_track_a_scan.py +80 -0
- telmai-0.2.0/examples/08_read_the_results.py +80 -0
- telmai-0.2.0/examples/09_scan_callbacks.py +102 -0
- telmai-0.2.0/examples/README.md +44 -0
- telmai-0.2.0/examples/_common.py +48 -0
- telmai-0.2.0/pyproject.toml +114 -0
- telmai-0.2.0/recipes/.ruff.toml +13 -0
- telmai-0.2.0/recipes/airflow/README.md +277 -0
- telmai-0.2.0/recipes/airflow/telmai_gate_operator.py +113 -0
- telmai-0.2.0/recipes/databricks/README.md +223 -0
- telmai-0.2.0/recipes/databricks/job.json +64 -0
- telmai-0.2.0/recipes/databricks/telmai_gate_task.py +242 -0
- telmai-0.2.0/telmai/__init__.py +51 -0
- telmai-0.2.0/telmai/__main__.py +188 -0
- telmai-0.2.0/telmai/_generated/__init__.py +5 -0
- telmai-0.2.0/telmai/_generated/api.py +3431 -0
- telmai-0.2.0/telmai/client.py +407 -0
- telmai-0.2.0/telmai/errors.py +87 -0
- telmai-0.2.0/telmai/features/__init__.py +12 -0
- telmai-0.2.0/telmai/features/gate.py +446 -0
- telmai-0.2.0/telmai/features/waiters.py +124 -0
- telmai-0.2.0/telmai/models.py +385 -0
- telmai-0.2.0/telmai/py.typed +0 -0
- telmai-0.2.0/telmai/resources/__init__.py +32 -0
- telmai-0.2.0/telmai/resources/assets.py +171 -0
- telmai-0.2.0/telmai/resources/binning.py +94 -0
- telmai-0.2.0/telmai/resources/connections.py +115 -0
- telmai-0.2.0/telmai/resources/monitors.py +214 -0
- telmai-0.2.0/telmai/resources/results.py +130 -0
- telmai-0.2.0/telmai/resources/scans.py +188 -0
- telmai-0.2.0/telmai/transport.py +347 -0
telmai-0.2.0/.gitignore
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.venv/
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
.pytest_cache/
|
|
5
|
+
.mypy_cache/
|
|
6
|
+
.ruff_cache/
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
# Credentials. Never commit a Telmai API key; the SDK reads it from the
|
|
11
|
+
# environment precisely so it does not need to live in a file.
|
|
12
|
+
.env
|
|
13
|
+
.env.*
|
|
14
|
+
*.env
|
|
15
|
+
.envrc
|
|
16
|
+
secrets/
|
|
17
|
+
# ...but the template must be committable, or a new contributor has no way to
|
|
18
|
+
# know which variables to set. Negation has to follow the patterns above.
|
|
19
|
+
!.env.example
|
|
20
|
+
|
|
21
|
+
# Coverage output embeds absolute developer paths.
|
|
22
|
+
.coverage
|
|
23
|
+
.coverage.*
|
|
24
|
+
htmlcov/
|
|
25
|
+
|
|
26
|
+
# Credential shapes, for a repo whose whole job is handling one.
|
|
27
|
+
*.pem
|
|
28
|
+
*.key
|
|
29
|
+
*.p12
|
|
30
|
+
credentials.json
|
|
31
|
+
service-account*.json
|
|
32
|
+
*-key.json
|
|
33
|
+
secrets.y*ml
|
|
34
|
+
.direnv/
|
|
35
|
+
|
|
36
|
+
# Credential files the tooling this repo recommends will actually create.
|
|
37
|
+
# `.pypirc` is the sharpest: twine is a dev dependency, the release docs walk a
|
|
38
|
+
# maintainer through publishing, and a PyPI token sits in it in cleartext.
|
|
39
|
+
.pypirc
|
|
40
|
+
.databrickscfg
|
|
41
|
+
.netrc
|
|
42
|
+
_netrc
|
|
43
|
+
id_rsa
|
|
44
|
+
id_ed25519
|
|
45
|
+
*.tfvars
|
|
46
|
+
*.tfstate
|
|
47
|
+
*.jks
|
|
48
|
+
*.pfx
|
|
49
|
+
|
|
50
|
+
# Editor and OS noise.
|
|
51
|
+
.DS_Store
|
|
52
|
+
.idea/
|
|
53
|
+
.vscode/
|
telmai-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
telmai-0.2.0/NOTICE
ADDED
telmai-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: telmai
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Python SDK for gating pipelines on Telmai data quality scans
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
License-File: NOTICE
|
|
8
|
+
Keywords: circuit breaker,data observability,data quality,databricks,telmai
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Database
|
|
19
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Requires-Dist: requests>=2.32
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: build; extra == 'dev'
|
|
25
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pyyaml; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
30
|
+
Requires-Dist: twine; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# telmai
|
|
34
|
+
|
|
35
|
+
Python SDK for gating data pipelines on Telmai data quality scans.
|
|
36
|
+
|
|
37
|
+
> **Pre-release.** Not published to PyPI yet, so `pip install telmai` does not
|
|
38
|
+
> work. Install from source — see [Getting set up](#getting-set-up). The first
|
|
39
|
+
> published version will be `0.2.0`.
|
|
40
|
+
|
|
41
|
+
## Why this exists
|
|
42
|
+
|
|
43
|
+
Telmai finds quality problems. It cannot act on them, because the moment that
|
|
44
|
+
matters is inside someone else's pipeline: the step between writing a batch and
|
|
45
|
+
publishing it. No API call can fail a customer's Databricks task or skip their
|
|
46
|
+
Airflow step. That has to be code running in their job.
|
|
47
|
+
|
|
48
|
+
Customers who want that today write their own HTTP client. Asking "did this
|
|
49
|
+
batch pass?" is four calls, a state machine, and five failure modes that all
|
|
50
|
+
have to resolve the same way. Getting it wrong is easy and the consequences are
|
|
51
|
+
asymmetric, so this ships it once, correctly.
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from telmai import CircuitBreakerTripped, Severity, Telmai
|
|
55
|
+
|
|
56
|
+
tm = Telmai.from_env() # TELMAI_HOST / TELMAI_TENANT / TELMAI_API_KEY
|
|
57
|
+
tm.circuit_breaker("a1b2c3d4e5f6") # raises if the batch is not clean
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Getting set up
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
git clone https://github.com/Telmai/telmai-python.git && cd telmai-python
|
|
64
|
+
python3 -m venv .venv && ./.venv/bin/pip install -e ".[dev]"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Every command below uses `./.venv/bin/...` explicitly, so nothing depends on
|
|
68
|
+
whether the venv is activated.
|
|
69
|
+
|
|
70
|
+
Three environment variables, and nothing else:
|
|
71
|
+
|
|
72
|
+
| | |
|
|
73
|
+
|---|---|
|
|
74
|
+
| `TELMAI_HOST` | bare hostname, no scheme — `your-tenant.telm.ai` |
|
|
75
|
+
| `TELMAI_TENANT` | the tenant id, the opaque string in your Telmai URL |
|
|
76
|
+
| `TELMAI_API_KEY` | from your secret store, never from a file in a repo |
|
|
77
|
+
|
|
78
|
+
[`.env.example`](.env.example) documents these three plus `TELMAI_LIVE`, and is
|
|
79
|
+
the fastest local setup. Nothing auto-loads it — the SDK reads the environment,
|
|
80
|
+
not a file — so source it yourself:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
cp .env.example .env # then fill in TELMAI_API_KEY
|
|
84
|
+
set -a && source .env && set +a
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`.env` is gitignored. `.env.example` deliberately leaves `TELMAI_API_KEY`
|
|
88
|
+
commented out rather than empty, so sourcing a half-filled file cannot export an
|
|
89
|
+
empty string over a key that was already working in your shell.
|
|
90
|
+
|
|
91
|
+
Python 3.9 or newer. CI runs 3.9 through 3.13. The floor is 3.9 rather than
|
|
92
|
+
something more modern because Databricks and Airflow runtimes lag, and those
|
|
93
|
+
are the two places this code actually runs.
|
|
94
|
+
|
|
95
|
+
## Assets are addressed by id
|
|
96
|
+
|
|
97
|
+
Always ids, never table names. Two tables in one project can both be called
|
|
98
|
+
`orders`; only the id is unique, and it survives a rename in Telmai while your
|
|
99
|
+
pipeline code stays put. Passing a name where an id belongs is rejected before
|
|
100
|
+
any scan is triggered.
|
|
101
|
+
|
|
102
|
+
Look the id up once, out of band, and put it in your job config:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
python -m telmai resolve gold.orders # prints the id, then exits
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
There is a `tm.resolve(name)` for scripts that must do it at runtime, but a
|
|
109
|
+
pipeline that runs every day should not be paying for a lookup — or risking an
|
|
110
|
+
ambiguous one — on every run.
|
|
111
|
+
|
|
112
|
+
## Three ways to act on a scan
|
|
113
|
+
|
|
114
|
+
One scan underneath, three responses to its result.
|
|
115
|
+
|
|
116
|
+
**Circuit Breaker.** Stop the pipeline. Wire it between the write step and the
|
|
117
|
+
promote step, so a failure skips everything downstream.
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
tm.circuit_breaker(ORDERS)
|
|
121
|
+
tm.circuit_breaker([ORDERS, CLAIMS], min_severity=Severity.MEDIUM)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Quarantine.** Keep running, route the bad records aside. Needs Data Binning
|
|
125
|
+
configured on the asset — see `tm.binning`.
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
for r in tm.quarantine([ORDERS, CLAIMS]):
|
|
129
|
+
if not r.clean:
|
|
130
|
+
if r.fully_isolated:
|
|
131
|
+
move_flagged_rows(r.location.incorrect_data_path)
|
|
132
|
+
else:
|
|
133
|
+
hold_entire_batch(r.label) # binning covers only some monitors
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Live Pass Through.** Get told, without the gate deciding for you. For
|
|
137
|
+
pipelines that must run regardless of what the scan finds.
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
tm.live_pass_through(ORDERS, on_result=lambda v: notify(v) if not v.passed else None)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
It waits for the scan to finish, same as the other two, then calls back with the
|
|
144
|
+
verdict — it does not run alongside your pipeline. What it gives you over
|
|
145
|
+
`circuit_breaker` is that it never raises for a quality result, so nothing
|
|
146
|
+
downstream is skipped.
|
|
147
|
+
|
|
148
|
+
## Fail closed, by contract
|
|
149
|
+
|
|
150
|
+
Every path that cannot confirm a clean result blocks: a scan that fails or times
|
|
151
|
+
out, a severity we cannot read, an alert type meaning the scan never read the
|
|
152
|
+
table, an asset with no monitors. A gate that reports success on bad data is
|
|
153
|
+
worse than no gate, because the pipeline then certifies the batch.
|
|
154
|
+
|
|
155
|
+
Four consequences worth knowing before reading the code:
|
|
156
|
+
|
|
157
|
+
- **A typo raises, it does not become a verdict.** An unresolvable or ambiguous
|
|
158
|
+
asset id fails the whole batch before anything is scanned. A typo should not
|
|
159
|
+
look like a data problem.
|
|
160
|
+
- **`CircuitBreakerTripped` is not a `TelmaiError`.** A blocked batch is a
|
|
161
|
+
correct decision, not an API failure, so `except TelmaiError: retry` cannot
|
|
162
|
+
silently retry past it.
|
|
163
|
+
- **A severity we cannot read blocks.** If Telmai adds a tier above `HIGH`
|
|
164
|
+
tomorrow, an SDK that predates it treats that alert as unrankable and stops
|
|
165
|
+
the pipeline, rather than reading an unfamiliar value as harmless.
|
|
166
|
+
- **"Blocked" and "bad data" are different things.** A scan that could not read
|
|
167
|
+
the table blocks too, and says so separately. `passed` decides whether the
|
|
168
|
+
pipeline continues; `blocked_by_quality` decides what you tell someone. The
|
|
169
|
+
CLI splits them as exit `2` versus exit `1`.
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
try:
|
|
173
|
+
tm.circuit_breaker([ORDERS, CLAIMS])
|
|
174
|
+
except CircuitBreakerTripped as e:
|
|
175
|
+
for v in e.failed: # every failure, not just the first
|
|
176
|
+
log.error("%s: %s", v.label, [a.policy_name for a in v.blocking_alerts])
|
|
177
|
+
raise
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Everything else
|
|
181
|
+
|
|
182
|
+
Nine namespaces, mirroring what you are working on:
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
tm.connections.create({...}) # connect a warehouse
|
|
186
|
+
tm.connections.test(conn_id, {...}) # check it can still reach the source
|
|
187
|
+
|
|
188
|
+
tm.assets.create(project_id, {...})
|
|
189
|
+
tm.assets.detect_columns(ORDERS) # async; poll with tm.jobs.wait()
|
|
190
|
+
tm.assets.set_monitored_columns(ORDERS, {...})
|
|
191
|
+
|
|
192
|
+
tm.monitors.create(ORDERS, {...})
|
|
193
|
+
tm.monitors.set_enabled(ORDERS, monitor_id, False)
|
|
194
|
+
tm.monitors.export(ORDERS) # monitors as code, with import_()
|
|
195
|
+
|
|
196
|
+
job_id, status = tm.scans.run(ORDERS, wait=True)
|
|
197
|
+
tm.scans.cancel(ORDERS, job_id) # abandoning a scan does not stop it
|
|
198
|
+
|
|
199
|
+
tm.alerts.for_scan(ORDERS, job_id)
|
|
200
|
+
tm.jobs.wait(ORDERS, job_id)
|
|
201
|
+
tm.incidents.list()
|
|
202
|
+
tm.dq_score.get(ORDERS)
|
|
203
|
+
tm.binning.set(ORDERS, {...}) # where quarantine routes bad rows
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Below those, `tm._api` carries the generated operations — every customer-facing
|
|
207
|
+
route in Telmai's OpenAPI spec, so a missing wrapper is never a dead end. It is
|
|
208
|
+
not the whole platform: `tools/generate.py` filters out `/internal` and `/admin`
|
|
209
|
+
routes plus the tag areas in its `EXCLUDE_TAGS` set, which serve the web app or
|
|
210
|
+
are configured in the product, auth among them. The names there come from the platform's own
|
|
211
|
+
`operationId`s, so they are faithful rather than pretty — creating a connection
|
|
212
|
+
is `tm._api.get_connection_4()`. See [docs/versioning.md](docs/versioning.md)
|
|
213
|
+
for why it is underscored and what that means for upgrades.
|
|
214
|
+
|
|
215
|
+
## Runnable examples
|
|
216
|
+
|
|
217
|
+
Nine scripts under [`examples/`](examples/README.md), covering all twenty
|
|
218
|
+
features, with a table of which ones cost compute. Start with the read-only one,
|
|
219
|
+
which prints the asset ids the rest need:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
./.venv/bin/python examples/01_find_your_assets.py
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Anything that costs compute asks first. Anything that writes configuration is a
|
|
226
|
+
dry run until you pass `--commit`.
|
|
227
|
+
|
|
228
|
+
## Developing
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
./.venv/bin/pytest -q # offline, no network, under a second
|
|
232
|
+
./.venv/bin/ruff check . && ./.venv/bin/ruff format --check .
|
|
233
|
+
./.venv/bin/mypy # strict
|
|
234
|
+
./.venv/bin/python tools/generate.py --check # generated layer is current
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
`mypy` takes no argument on purpose: it is configured to check the package.
|
|
238
|
+
`mypy .` would also walk the tests and the Airflow recipe, which imports a
|
|
239
|
+
package the SDK does not depend on, and it reports several hundred errors that
|
|
240
|
+
are not defects. Widening strict typing to the test suite is real work, not a
|
|
241
|
+
config flag.
|
|
242
|
+
|
|
243
|
+
**Never hand-edit `telmai/_generated/`.** Fix `tools/generate.py` and
|
|
244
|
+
regenerate. Any tool that generates code here runs the real linter and formatter
|
|
245
|
+
on its own output rather than reimplementing their rules — that bit us twice.
|
|
246
|
+
|
|
247
|
+
### The live suite
|
|
248
|
+
|
|
249
|
+
`tests/live/` creates and deletes real objects on a real tenant. It is excluded
|
|
250
|
+
from the default run and opts in by naming the tenant twice, which is what stops
|
|
251
|
+
a stray environment variable pointing destructive tests somewhere unintended:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
export TELMAI_LIVE=$TELMAI_TENANT
|
|
255
|
+
./.venv/bin/pytest tests/live -m "not costly" # free
|
|
256
|
+
./.venv/bin/pytest tests/live -m costly # triggers real scans, spends compute
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Nothing pre-existing is ever deleted: cleanup only removes ids the run itself
|
|
260
|
+
recorded. Read `tests/live/conftest.py` before changing it.
|
|
261
|
+
|
|
262
|
+
It earns its keep. Two bugs no offline test could have found: `iter_detailed`
|
|
263
|
+
looped forever on a real first page, and `alerts.counts()` could never have
|
|
264
|
+
worked because a required query parameter was generated as optional.
|
|
265
|
+
|
|
266
|
+
## Where it stands
|
|
267
|
+
|
|
268
|
+
Pre-release. All three gate modes are built and validated end to end against a
|
|
269
|
+
live tenant, not just against fakes. Real alert payloads captured from that
|
|
270
|
+
tenant are checked against our enums in `tests/test_contract.py`, which found
|
|
271
|
+
defects no offline test could — including a severity tier the platform does not
|
|
272
|
+
emit, and an alert type we were reporting as bad data when it actually meant the
|
|
273
|
+
scan could not run.
|
|
274
|
+
|
|
275
|
+
The offline suite runs in under a second and is the specification, not a safety
|
|
276
|
+
net: `tests/test_fail_closed.py` encodes decisions that look like
|
|
277
|
+
over-engineering and are not. `mypy --strict` and `ruff` are clean, and the
|
|
278
|
+
wheel ships `py.typed`, verified reaching a consumer's own type checker.
|
|
279
|
+
|
|
280
|
+
Known gaps and open questions are in [TODO.md](TODO.md). If you are picking this
|
|
281
|
+
up, start with [HANDOFF.md](HANDOFF.md).
|
|
282
|
+
|
|
283
|
+
## More
|
|
284
|
+
|
|
285
|
+
- [HANDOFF.md](HANDOFF.md) — where the project is and what to do next
|
|
286
|
+
- [ARCHITECTURE.md](ARCHITECTURE.md) — how it fits together, and the platform
|
|
287
|
+
contract read off platform source because the public docs disagree in places
|
|
288
|
+
- [docs/versioning.md](docs/versioning.md) — what you can rely on across
|
|
289
|
+
versions, and the release process
|
|
290
|
+
- [docs/phase1-features.md](docs/phase1-features.md) — the twenty features and
|
|
291
|
+
the endpoint behind each
|
|
292
|
+
- [recipes/databricks/](recipes/databricks/) — notebook, job wiring, and where
|
|
293
|
+
the halt comes from
|
|
294
|
+
- [recipes/airflow/](recipes/airflow/) — operator
|
|
295
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md) — the one rule, and what not to tidy
|