pipeloom-databricks 0.5.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.
- pipeloom_databricks-0.5.0/.gitignore +16 -0
- pipeloom_databricks-0.5.0/LICENSE +202 -0
- pipeloom_databricks-0.5.0/NOTICE +2 -0
- pipeloom_databricks-0.5.0/PKG-INFO +114 -0
- pipeloom_databricks-0.5.0/README.md +87 -0
- pipeloom_databricks-0.5.0/pyproject.toml +56 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/__init__.py +18 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/api.py +45 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/bundle.py +113 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/cli.py +561 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/client/__init__.py +121 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/client/connect.py +84 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/client/sdk.py +275 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/deploy.py +188 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/finalize_states.py +72 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/grouping.py +158 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/jobs_model.py +116 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/keys.py +45 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/options.py +66 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/py.typed +0 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/render.py +396 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/repair.py +66 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/run.py +357 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/secrets.py +50 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/serialize.py +30 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/spec.py +75 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/task.py +422 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/task_values.py +69 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/testing/__init__.py +1 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/testing/fake.py +293 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/testing/jobsim.py +179 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/unity.py +23 -0
- pipeloom_databricks-0.5.0/src/pipeloom_databricks/upload.py +217 -0
- pipeloom_databricks-0.5.0/tests/conftest.py +271 -0
- pipeloom_databricks-0.5.0/tests/goldens/by_folder.json +121 -0
- pipeloom_databricks-0.5.0/tests/goldens/by_folder.yml +92 -0
- pipeloom_databricks-0.5.0/tests/goldens/by_tag.json +151 -0
- pipeloom_databricks-0.5.0/tests/goldens/by_tag.yml +115 -0
- pipeloom_databricks-0.5.0/tests/goldens/job_cluster.json +282 -0
- pipeloom_databricks-0.5.0/tests/goldens/job_cluster.yml +204 -0
- pipeloom_databricks-0.5.0/tests/goldens/serverless.json +243 -0
- pipeloom_databricks-0.5.0/tests/goldens/serverless.yml +184 -0
- pipeloom_databricks-0.5.0/tests/goldens/submit.json +212 -0
- pipeloom_databricks-0.5.0/tests/test_bundle.py +211 -0
- pipeloom_databricks-0.5.0/tests/test_connect.py +156 -0
- pipeloom_databricks-0.5.0/tests/test_deploy.py +332 -0
- pipeloom_databricks-0.5.0/tests/test_deploy_cli.py +139 -0
- pipeloom_databricks-0.5.0/tests/test_finalize_states.py +177 -0
- pipeloom_databricks-0.5.0/tests/test_grouping.py +160 -0
- pipeloom_databricks-0.5.0/tests/test_jobsim.py +188 -0
- pipeloom_databricks-0.5.0/tests/test_keys.py +65 -0
- pipeloom_databricks-0.5.0/tests/test_options.py +56 -0
- pipeloom_databricks-0.5.0/tests/test_render.py +385 -0
- pipeloom_databricks-0.5.0/tests/test_repair.py +104 -0
- pipeloom_databricks-0.5.0/tests/test_run.py +449 -0
- pipeloom_databricks-0.5.0/tests/test_run_cli.py +302 -0
- pipeloom_databricks-0.5.0/tests/test_sdk_client.py +346 -0
- pipeloom_databricks-0.5.0/tests/test_secrets.py +134 -0
- pipeloom_databricks-0.5.0/tests/test_spec_import.py +60 -0
- pipeloom_databricks-0.5.0/tests/test_task.py +294 -0
- pipeloom_databricks-0.5.0/tests/test_unity.py +106 -0
|
@@ -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.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pipeloom-databricks
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Databricks renderer for pipeloom: a compiled plan as Jobs settings JSON and bundle YAML.
|
|
5
|
+
Project-URL: Repository, https://github.com/emanuel-luis/pipeloom
|
|
6
|
+
Project-URL: Documentation, https://emanuel-luis.github.io/pipeloom/
|
|
7
|
+
Project-URL: Changelog, https://github.com/emanuel-luis/pipeloom/blob/main/CHANGELOG.md
|
|
8
|
+
Author-email: Emanuel Luis <emanuel.filho08@gmail.com>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Keywords: bundles,data-engineering,databricks,jobs,pipelines,pipeloom
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Requires-Dist: databricks-sdk<1,>=0.50
|
|
24
|
+
Requires-Dist: pipeloom-spark~=0.5.0
|
|
25
|
+
Requires-Dist: pipeloom~=0.5.0
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# pipeloom-databricks
|
|
29
|
+
|
|
30
|
+
The Databricks renderer for [pipeloom](https://github.com/emanuel-luis/pipeloom). It turns a
|
|
31
|
+
compiled plan into Databricks Jobs settings (JSON for the Jobs API) and into a bundle YAML file.
|
|
32
|
+
|
|
33
|
+
```console
|
|
34
|
+
$ pip install "pipeloom[databricks]"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Describe the deployment in a target:
|
|
38
|
+
|
|
39
|
+
```yaml
|
|
40
|
+
targets:
|
|
41
|
+
prod:
|
|
42
|
+
engine: {kind: spark}
|
|
43
|
+
catalog: {kind: spark_catalog}
|
|
44
|
+
state: {kind: table, table: ops._pipeloom_state} # shared by every task
|
|
45
|
+
artifacts: {root: /Volumes/main/ops/pipeloom}
|
|
46
|
+
deploy:
|
|
47
|
+
kind: databricks
|
|
48
|
+
pipelines: {main: {}, daily: {select: ["tag:daily"]}}
|
|
49
|
+
compute:
|
|
50
|
+
default: {kind: serverless, environment_version: "5"}
|
|
51
|
+
task_grouping: none # none, by_tag or by_folder
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- One job per pipeline, one task per unit (or per group of units), plus a finalize task that
|
|
55
|
+
closes the run. A job above 1,000 tasks is an error (PLD001).
|
|
56
|
+
- Rendering is pure: no network, no Databricks SDK call and no credentials are needed. The
|
|
57
|
+
output is byte-for-byte the same for the same plan.
|
|
58
|
+
- Compute is serverless environments or job clusters, chosen per model with `compute_rules`.
|
|
59
|
+
- A pipeline job runs only its own units. An upstream model in another pipeline is read from
|
|
60
|
+
its persisted output, so schedule that pipeline first.
|
|
61
|
+
- Diagnostics: PLD001 (task limit), PLD003 (group cycle), PLD004 (invalid deploy options),
|
|
62
|
+
PLD005 (compute rule that matches no model), PLD013 (unresolved task parameter).
|
|
63
|
+
- Bundles: `pipeloom databricks bundle --target prod --out resources` writes one job file and
|
|
64
|
+
one manifest per pipeline into a Declarative Automation Bundle (the output folder must lie
|
|
65
|
+
inside the bundle, next to `databricks.yml`; add the job files to its `include`). Paths use
|
|
66
|
+
`${workspace.file_path}`. `--check` lists stale files and exits 1.
|
|
67
|
+
- Tasks run `pipeloom_databricks_task`, a wrapper that calls pipeloom in the task's own process,
|
|
68
|
+
so an existing Spark session is reused. A parameter that Databricks left as `{{...}}` stops
|
|
69
|
+
the task with PLD013. After a unit task the wrapper sets the task value `pipeloom`, a small
|
|
70
|
+
summary of its units (best effort).
|
|
71
|
+
- `pipeloom_databricks.testing.jobsim.simulate_job` runs a rendered job locally for tests.
|
|
72
|
+
- Direct deploy: `pipeloom databricks [--profile NAME] deploy --target prod [--pipeline NAME]...
|
|
73
|
+
[--dry-run]` uploads the project to the workspace (content addressed, under
|
|
74
|
+
`<workspace_root>/<project>/<pipeline>/<target>/<hash>`) and creates or resets one job per
|
|
75
|
+
pipeline, found by its `pipeloom_job` tag. It prints one JSON line per pipeline. `--dry-run`
|
|
76
|
+
prints the job settings and connects to nothing. The upload holds `pipeloom.yml`, the model
|
|
77
|
+
files and the `*.py` files below `python_paths` (virtual environments, `dist`, `build` and
|
|
78
|
+
similar folders are skipped). Other files below `python_paths` are not uploaded, so a Python
|
|
79
|
+
model that reads a file next to it (`.sql`, `.json`, `.csv`) works locally but not on
|
|
80
|
+
Databricks; keep such data in a table or a volume. Notebooks and files above 10 MB are refused
|
|
81
|
+
(PLD012).
|
|
82
|
+
- Connection: `--profile`, else a `DATABRICKS_CONFIG_PROFILE` you set, else `DATABRICKS_HOST`
|
|
83
|
+
with credentials, else the Databricks runtime, else PLD010. pipeloom never picks a profile
|
|
84
|
+
by itself. Other codes: PLD006 (two jobs with the same tag), PLD009 (API error).
|
|
85
|
+
- `pipeloom_databricks.api` is the stable surface for other distributions, and
|
|
86
|
+
`pipeloom_databricks.testing.fake.FakeDatabricks` a fake workspace for tests.
|
|
87
|
+
- Run: `pipeloom databricks run --target prod [--pipeline NAME] [--select S]... [--exclude S]...
|
|
88
|
+
[--run-id RID] [--full-refresh] [--ensure] [--ephemeral] [--wait|--no-wait]` starts the
|
|
89
|
+
deployed job (PLD007 when none is deployed, PLD008 when it differs from the local render,
|
|
90
|
+
unless `--ensure` deploys first). Selected units map to task keys plus finalize (`only`); a
|
|
91
|
+
partly selected group runs whole, with the warning PLD015. `--timeout SECONDS` (default 24
|
|
92
|
+
hours) bounds `--wait`. `--run-id` names the run and makes the start
|
|
93
|
+
idempotent. `--ephemeral` uploads the project and submits a one-time run on serverless
|
|
94
|
+
compute. It prints one JSON line with the ids and the run page URL, then with `--wait` (the
|
|
95
|
+
default) polls every 15 seconds, reports task transitions and the failed units, and exits 1
|
|
96
|
+
unless the run succeeded.
|
|
97
|
+
- Repair: `pipeloom databricks repair --target prod (--run-id RID | --job-run-id N)
|
|
98
|
+
[--wait|--no-wait]` reruns the tasks that failed, timed out, were cancelled or skipped, plus
|
|
99
|
+
finalize. A run that is still active is PLD014; nothing to repair exits 0.
|
|
100
|
+
- Finalize reads how each task ended from the Jobs API and gives core finalize the state of every
|
|
101
|
+
unit that wrote no attempt file, so a lost, timed-out or cancelled task fails or cancels the
|
|
102
|
+
run (a failed one is PLD011). If the API cannot be read, finalize prints one warning and judges
|
|
103
|
+
by the attempt files alone. A one-time run has no job run id, so it gets no task states.
|
|
104
|
+
|
|
105
|
+
- Unity Catalog: `catalog: {kind: unity, catalog: main}` (Spark engine only) addresses tables and
|
|
106
|
+
views as `` `catalog`.`schema`.`name` ``. The option catalog fills in when the target's naming
|
|
107
|
+
leaves it empty. A schema is created only when it does not exist yet, so a principal without
|
|
108
|
+
CREATE SCHEMA can write to an existing one.
|
|
109
|
+
- Secrets: `${secret:databricks/<scope>/<key>}` in plugin options reads a Databricks secret
|
|
110
|
+
scope at run time, with the connection rules above. The value is masked like any resolved
|
|
111
|
+
secret. A bad path, a missing connection or an API error is PLX109, naming the path and never
|
|
112
|
+
the value.
|
|
113
|
+
|
|
114
|
+
License: Apache-2.0.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# pipeloom-databricks
|
|
2
|
+
|
|
3
|
+
The Databricks renderer for [pipeloom](https://github.com/emanuel-luis/pipeloom). It turns a
|
|
4
|
+
compiled plan into Databricks Jobs settings (JSON for the Jobs API) and into a bundle YAML file.
|
|
5
|
+
|
|
6
|
+
```console
|
|
7
|
+
$ pip install "pipeloom[databricks]"
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Describe the deployment in a target:
|
|
11
|
+
|
|
12
|
+
```yaml
|
|
13
|
+
targets:
|
|
14
|
+
prod:
|
|
15
|
+
engine: {kind: spark}
|
|
16
|
+
catalog: {kind: spark_catalog}
|
|
17
|
+
state: {kind: table, table: ops._pipeloom_state} # shared by every task
|
|
18
|
+
artifacts: {root: /Volumes/main/ops/pipeloom}
|
|
19
|
+
deploy:
|
|
20
|
+
kind: databricks
|
|
21
|
+
pipelines: {main: {}, daily: {select: ["tag:daily"]}}
|
|
22
|
+
compute:
|
|
23
|
+
default: {kind: serverless, environment_version: "5"}
|
|
24
|
+
task_grouping: none # none, by_tag or by_folder
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- One job per pipeline, one task per unit (or per group of units), plus a finalize task that
|
|
28
|
+
closes the run. A job above 1,000 tasks is an error (PLD001).
|
|
29
|
+
- Rendering is pure: no network, no Databricks SDK call and no credentials are needed. The
|
|
30
|
+
output is byte-for-byte the same for the same plan.
|
|
31
|
+
- Compute is serverless environments or job clusters, chosen per model with `compute_rules`.
|
|
32
|
+
- A pipeline job runs only its own units. An upstream model in another pipeline is read from
|
|
33
|
+
its persisted output, so schedule that pipeline first.
|
|
34
|
+
- Diagnostics: PLD001 (task limit), PLD003 (group cycle), PLD004 (invalid deploy options),
|
|
35
|
+
PLD005 (compute rule that matches no model), PLD013 (unresolved task parameter).
|
|
36
|
+
- Bundles: `pipeloom databricks bundle --target prod --out resources` writes one job file and
|
|
37
|
+
one manifest per pipeline into a Declarative Automation Bundle (the output folder must lie
|
|
38
|
+
inside the bundle, next to `databricks.yml`; add the job files to its `include`). Paths use
|
|
39
|
+
`${workspace.file_path}`. `--check` lists stale files and exits 1.
|
|
40
|
+
- Tasks run `pipeloom_databricks_task`, a wrapper that calls pipeloom in the task's own process,
|
|
41
|
+
so an existing Spark session is reused. A parameter that Databricks left as `{{...}}` stops
|
|
42
|
+
the task with PLD013. After a unit task the wrapper sets the task value `pipeloom`, a small
|
|
43
|
+
summary of its units (best effort).
|
|
44
|
+
- `pipeloom_databricks.testing.jobsim.simulate_job` runs a rendered job locally for tests.
|
|
45
|
+
- Direct deploy: `pipeloom databricks [--profile NAME] deploy --target prod [--pipeline NAME]...
|
|
46
|
+
[--dry-run]` uploads the project to the workspace (content addressed, under
|
|
47
|
+
`<workspace_root>/<project>/<pipeline>/<target>/<hash>`) and creates or resets one job per
|
|
48
|
+
pipeline, found by its `pipeloom_job` tag. It prints one JSON line per pipeline. `--dry-run`
|
|
49
|
+
prints the job settings and connects to nothing. The upload holds `pipeloom.yml`, the model
|
|
50
|
+
files and the `*.py` files below `python_paths` (virtual environments, `dist`, `build` and
|
|
51
|
+
similar folders are skipped). Other files below `python_paths` are not uploaded, so a Python
|
|
52
|
+
model that reads a file next to it (`.sql`, `.json`, `.csv`) works locally but not on
|
|
53
|
+
Databricks; keep such data in a table or a volume. Notebooks and files above 10 MB are refused
|
|
54
|
+
(PLD012).
|
|
55
|
+
- Connection: `--profile`, else a `DATABRICKS_CONFIG_PROFILE` you set, else `DATABRICKS_HOST`
|
|
56
|
+
with credentials, else the Databricks runtime, else PLD010. pipeloom never picks a profile
|
|
57
|
+
by itself. Other codes: PLD006 (two jobs with the same tag), PLD009 (API error).
|
|
58
|
+
- `pipeloom_databricks.api` is the stable surface for other distributions, and
|
|
59
|
+
`pipeloom_databricks.testing.fake.FakeDatabricks` a fake workspace for tests.
|
|
60
|
+
- Run: `pipeloom databricks run --target prod [--pipeline NAME] [--select S]... [--exclude S]...
|
|
61
|
+
[--run-id RID] [--full-refresh] [--ensure] [--ephemeral] [--wait|--no-wait]` starts the
|
|
62
|
+
deployed job (PLD007 when none is deployed, PLD008 when it differs from the local render,
|
|
63
|
+
unless `--ensure` deploys first). Selected units map to task keys plus finalize (`only`); a
|
|
64
|
+
partly selected group runs whole, with the warning PLD015. `--timeout SECONDS` (default 24
|
|
65
|
+
hours) bounds `--wait`. `--run-id` names the run and makes the start
|
|
66
|
+
idempotent. `--ephemeral` uploads the project and submits a one-time run on serverless
|
|
67
|
+
compute. It prints one JSON line with the ids and the run page URL, then with `--wait` (the
|
|
68
|
+
default) polls every 15 seconds, reports task transitions and the failed units, and exits 1
|
|
69
|
+
unless the run succeeded.
|
|
70
|
+
- Repair: `pipeloom databricks repair --target prod (--run-id RID | --job-run-id N)
|
|
71
|
+
[--wait|--no-wait]` reruns the tasks that failed, timed out, were cancelled or skipped, plus
|
|
72
|
+
finalize. A run that is still active is PLD014; nothing to repair exits 0.
|
|
73
|
+
- Finalize reads how each task ended from the Jobs API and gives core finalize the state of every
|
|
74
|
+
unit that wrote no attempt file, so a lost, timed-out or cancelled task fails or cancels the
|
|
75
|
+
run (a failed one is PLD011). If the API cannot be read, finalize prints one warning and judges
|
|
76
|
+
by the attempt files alone. A one-time run has no job run id, so it gets no task states.
|
|
77
|
+
|
|
78
|
+
- Unity Catalog: `catalog: {kind: unity, catalog: main}` (Spark engine only) addresses tables and
|
|
79
|
+
views as `` `catalog`.`schema`.`name` ``. The option catalog fills in when the target's naming
|
|
80
|
+
leaves it empty. A schema is created only when it does not exist yet, so a principal without
|
|
81
|
+
CREATE SCHEMA can write to an existing one.
|
|
82
|
+
- Secrets: `${secret:databricks/<scope>/<key>}` in plugin options reads a Databricks secret
|
|
83
|
+
scope at run time, with the connection rules above. The value is masked like any resolved
|
|
84
|
+
secret. A bad path, a missing connection or an API error is PLX109, naming the path and never
|
|
85
|
+
the value.
|
|
86
|
+
|
|
87
|
+
License: Apache-2.0.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pipeloom-databricks"
|
|
7
|
+
version = "0.5.0"
|
|
8
|
+
description = "Databricks renderer for pipeloom: a compiled plan as Jobs settings JSON and bundle YAML."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
13
|
+
authors = [{ name = "Emanuel Luis", email = "emanuel.filho08@gmail.com" }]
|
|
14
|
+
keywords = ["pipeloom", "databricks", "jobs", "bundles", "data-engineering", "pipelines"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Programming Language :: Python :: 3.14",
|
|
24
|
+
"Typing :: Typed",
|
|
25
|
+
]
|
|
26
|
+
dependencies = ["pipeloom~=0.5.0", "pipeloom-spark~=0.5.0", "databricks-sdk>=0.50,<1"]
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Repository = "https://github.com/emanuel-luis/pipeloom"
|
|
30
|
+
Documentation = "https://emanuel-luis.github.io/pipeloom/"
|
|
31
|
+
Changelog = "https://github.com/emanuel-luis/pipeloom/blob/main/CHANGELOG.md"
|
|
32
|
+
|
|
33
|
+
[project.entry-points."pipeloom.renderers"]
|
|
34
|
+
databricks = "pipeloom_databricks.spec:RENDERER_SPEC"
|
|
35
|
+
|
|
36
|
+
[project.entry-points."pipeloom.catalogs"]
|
|
37
|
+
unity = "pipeloom_databricks.spec:UNITY_SPEC"
|
|
38
|
+
|
|
39
|
+
[project.entry-points."pipeloom.secret_providers"]
|
|
40
|
+
databricks = "pipeloom_databricks.spec:SECRETS_SPEC"
|
|
41
|
+
|
|
42
|
+
[project.entry-points."pipeloom.commands"]
|
|
43
|
+
databricks = "pipeloom_databricks.cli:databricks"
|
|
44
|
+
|
|
45
|
+
[project.scripts]
|
|
46
|
+
pipeloom_databricks_task = "pipeloom_databricks.task:main"
|
|
47
|
+
|
|
48
|
+
[tool.uv.sources]
|
|
49
|
+
pipeloom = { workspace = true }
|
|
50
|
+
pipeloom-spark = { workspace = true }
|
|
51
|
+
|
|
52
|
+
[tool.hatch.build.targets.wheel]
|
|
53
|
+
packages = ["src/pipeloom_databricks"]
|
|
54
|
+
|
|
55
|
+
[tool.hatch.build.targets.sdist]
|
|
56
|
+
only-include = ["src", "tests", "LICENSE", "NOTICE", "README.md"]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Databricks renderer for pipeloom: a compiled plan as Jobs settings JSON and bundle YAML.
|
|
2
|
+
|
|
3
|
+
Rendering is pure. Nothing here imports `databricks.sdk`; only the modules that talk to a
|
|
4
|
+
workspace will, and they load it lazily.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def pipeloom_databricks_task() -> None:
|
|
11
|
+
"""The entry point of a rendered task, found by `package_name` and `entry_point`.
|
|
12
|
+
|
|
13
|
+
A function of the package covers a Databricks lookup that does not read entry points. The
|
|
14
|
+
task module loads only when a task runs.
|
|
15
|
+
"""
|
|
16
|
+
from pipeloom_databricks.task import main
|
|
17
|
+
|
|
18
|
+
main()
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""The stable surface other pipeloom distributions (such as an Airflow renderer) may call.
|
|
2
|
+
|
|
3
|
+
Importing it loads no SDK: `connect` imports `databricks.sdk` only when it runs.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from pipeloom_databricks.client import (
|
|
9
|
+
ApiError,
|
|
10
|
+
ConnectionNotConfigured,
|
|
11
|
+
DatabricksClient,
|
|
12
|
+
JobSummary,
|
|
13
|
+
RunInfo,
|
|
14
|
+
TaskRunInfo,
|
|
15
|
+
connect,
|
|
16
|
+
)
|
|
17
|
+
from pipeloom_databricks.deploy import DeployResult, DuplicateJobs, deploy, find_job
|
|
18
|
+
from pipeloom_databricks.finalize_states import task_states
|
|
19
|
+
from pipeloom_databricks.grouping import task_key_map
|
|
20
|
+
from pipeloom_databricks.render import deploy_options, render_job
|
|
21
|
+
from pipeloom_databricks.repair import repair
|
|
22
|
+
from pipeloom_databricks.run import RunStarted, SelectionError, find_run, run_job
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"ApiError",
|
|
26
|
+
"ConnectionNotConfigured",
|
|
27
|
+
"DatabricksClient",
|
|
28
|
+
"DeployResult",
|
|
29
|
+
"DuplicateJobs",
|
|
30
|
+
"JobSummary",
|
|
31
|
+
"RunInfo",
|
|
32
|
+
"RunStarted",
|
|
33
|
+
"SelectionError",
|
|
34
|
+
"TaskRunInfo",
|
|
35
|
+
"connect",
|
|
36
|
+
"deploy",
|
|
37
|
+
"deploy_options",
|
|
38
|
+
"find_job",
|
|
39
|
+
"find_run",
|
|
40
|
+
"render_job",
|
|
41
|
+
"repair",
|
|
42
|
+
"run_job",
|
|
43
|
+
"task_key_map",
|
|
44
|
+
"task_states",
|
|
45
|
+
]
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"""The files of a Declarative Automation Bundle: one job file and one stable manifest per pipeline.
|
|
2
|
+
|
|
3
|
+
Pure: it returns bytes and never writes. `${workspace.file_path}` is the bundle variable that
|
|
4
|
+
resolves to the synced files at deploy time, so the job finds the project and the manifest
|
|
5
|
+
wherever the bundle lands.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from collections.abc import Sequence
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Final
|
|
14
|
+
|
|
15
|
+
from pipeloom.diagnostics import Report
|
|
16
|
+
from pipeloom.plan.manifest import manifest_bytes
|
|
17
|
+
from pipeloom.plan.model import Plan
|
|
18
|
+
from pipeloom_databricks.jobs_model import to_json
|
|
19
|
+
from pipeloom_databricks.render import (
|
|
20
|
+
Locations,
|
|
21
|
+
_own_version,
|
|
22
|
+
deploy_options,
|
|
23
|
+
job_name,
|
|
24
|
+
render_job,
|
|
25
|
+
)
|
|
26
|
+
from pipeloom_databricks.serialize import to_bundle_yaml
|
|
27
|
+
|
|
28
|
+
BUNDLE_FILE: Final = "databricks.yml"
|
|
29
|
+
WORKSPACE_FILES: Final = "${workspace.file_path}"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass(frozen=True)
|
|
33
|
+
class BundleFile:
|
|
34
|
+
path: Path
|
|
35
|
+
"""Where the file goes: `<out>/<name>`."""
|
|
36
|
+
content: bytes
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@dataclass(frozen=True)
|
|
40
|
+
class Runtime:
|
|
41
|
+
"""What the target says that the job needs to know."""
|
|
42
|
+
|
|
43
|
+
artifacts_root: str | None
|
|
44
|
+
state_shared: bool
|
|
45
|
+
cancel_grace: int = 30
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def find_bundle_root(out: Path, explicit: Path | None) -> Path | None:
|
|
49
|
+
"""`explicit`, else the nearest ancestor of `out` (itself included) that holds databricks.yml."""
|
|
50
|
+
if explicit is not None:
|
|
51
|
+
return explicit.resolve()
|
|
52
|
+
here = out.resolve()
|
|
53
|
+
for folder in (here, *here.parents):
|
|
54
|
+
if (folder / BUNDLE_FILE).is_file():
|
|
55
|
+
return folder
|
|
56
|
+
return None
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def relative_to_root(path: Path, root: Path) -> str | None:
|
|
60
|
+
"""`path` below `root` as POSIX text (empty for the root itself), or None when outside."""
|
|
61
|
+
try:
|
|
62
|
+
rel = path.resolve().relative_to(root).as_posix()
|
|
63
|
+
except ValueError:
|
|
64
|
+
return None
|
|
65
|
+
return "" if rel == "." else rel
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _workspace(rel: str) -> str:
|
|
69
|
+
return f"{WORKSPACE_FILES}/{rel}" if rel else WORKSPACE_FILES
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def render_bundle(
|
|
73
|
+
plan: Plan,
|
|
74
|
+
runtime: Runtime,
|
|
75
|
+
pipelines: Sequence[str],
|
|
76
|
+
*,
|
|
77
|
+
out: Path,
|
|
78
|
+
project_rel: str,
|
|
79
|
+
out_rel: str,
|
|
80
|
+
report: Report,
|
|
81
|
+
) -> list[BundleFile] | None:
|
|
82
|
+
"""The files of the given pipelines (all of them when empty), or None with the problems in
|
|
83
|
+
`report`. `project_rel` and `out_rel` are the project folder and the output folder relative
|
|
84
|
+
to the bundle root."""
|
|
85
|
+
opts = deploy_options(plan, report)
|
|
86
|
+
if opts is None:
|
|
87
|
+
return None
|
|
88
|
+
manifest = manifest_bytes(plan, stable=True)
|
|
89
|
+
files: list[BundleFile] = []
|
|
90
|
+
before = report.error_count
|
|
91
|
+
for pipeline in pipelines or sorted(opts.pipelines):
|
|
92
|
+
name = job_name(plan, pipeline)
|
|
93
|
+
locs = Locations(
|
|
94
|
+
project_root=_workspace(project_rel),
|
|
95
|
+
manifest_path=_workspace(f"{out_rel}/{name}.manifest.json".lstrip("/")),
|
|
96
|
+
artifacts_root=runtime.artifacts_root,
|
|
97
|
+
state_shared=runtime.state_shared,
|
|
98
|
+
cancel_grace=runtime.cancel_grace,
|
|
99
|
+
)
|
|
100
|
+
job = render_job(plan, pipeline, locs, report)
|
|
101
|
+
if job is None:
|
|
102
|
+
continue
|
|
103
|
+
header = (
|
|
104
|
+
f"Generated by pipeloom-databricks {_own_version(plan)}.\n"
|
|
105
|
+
f"Project: {plan.metadata.project}. Pipeline: {pipeline}. "
|
|
106
|
+
f"Target: {plan.metadata.target}.\n"
|
|
107
|
+
"Do not edit: run `pipeloom databricks bundle` again."
|
|
108
|
+
)
|
|
109
|
+
files.append(
|
|
110
|
+
BundleFile(out / f"{name}.job.yml", to_bundle_yaml(name, to_json(job.settings), header))
|
|
111
|
+
)
|
|
112
|
+
files.append(BundleFile(out / f"{name}.manifest.json", manifest))
|
|
113
|
+
return None if report.error_count > before else files
|