pipeloom-airflow 0.6.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.
Files changed (65) hide show
  1. pipeloom_airflow-0.6.0/.gitignore +16 -0
  2. pipeloom_airflow-0.6.0/LICENSE +202 -0
  3. pipeloom_airflow-0.6.0/NOTICE +2 -0
  4. pipeloom_airflow-0.6.0/PKG-INFO +142 -0
  5. pipeloom_airflow-0.6.0/README.md +108 -0
  6. pipeloom_airflow-0.6.0/pyproject.toml +52 -0
  7. pipeloom_airflow-0.6.0/src/pipeloom_airflow/__init__.py +35 -0
  8. pipeloom_airflow-0.6.0/src/pipeloom_airflow/_compat.py +92 -0
  9. pipeloom_airflow-0.6.0/src/pipeloom_airflow/_compat_k8s.py +36 -0
  10. pipeloom_airflow-0.6.0/src/pipeloom_airflow/commands.py +164 -0
  11. pipeloom_airflow-0.6.0/src/pipeloom_airflow/config.py +182 -0
  12. pipeloom_airflow-0.6.0/src/pipeloom_airflow/dag.py +331 -0
  13. pipeloom_airflow-0.6.0/src/pipeloom_airflow/databricks/__init__.py +6 -0
  14. pipeloom_airflow-0.6.0/src/pipeloom_airflow/databricks/connection.py +114 -0
  15. pipeloom_airflow-0.6.0/src/pipeloom_airflow/databricks/launch.py +165 -0
  16. pipeloom_airflow-0.6.0/src/pipeloom_airflow/databricks/launch_logic.py +176 -0
  17. pipeloom_airflow-0.6.0/src/pipeloom_airflow/databricks/mirror.py +136 -0
  18. pipeloom_airflow-0.6.0/src/pipeloom_airflow/databricks/sensor.py +139 -0
  19. pipeloom_airflow-0.6.0/src/pipeloom_airflow/databricks/triggers.py +160 -0
  20. pipeloom_airflow-0.6.0/src/pipeloom_airflow/errors.py +15 -0
  21. pipeloom_airflow-0.6.0/src/pipeloom_airflow/load.py +237 -0
  22. pipeloom_airflow-0.6.0/src/pipeloom_airflow/naming.py +58 -0
  23. pipeloom_airflow-0.6.0/src/pipeloom_airflow/operators/__init__.py +5 -0
  24. pipeloom_airflow-0.6.0/src/pipeloom_airflow/operators/kubernetes.py +99 -0
  25. pipeloom_airflow-0.6.0/src/pipeloom_airflow/operators/local.py +241 -0
  26. pipeloom_airflow-0.6.0/src/pipeloom_airflow/py.typed +0 -0
  27. pipeloom_airflow-0.6.0/src/pipeloom_airflow/render.py +222 -0
  28. pipeloom_airflow-0.6.0/src/pipeloom_airflow/states.py +109 -0
  29. pipeloom_airflow-0.6.0/src/pipeloom_airflow/testing/__init__.py +1 -0
  30. pipeloom_airflow-0.6.0/src/pipeloom_airflow/testing/cases.py +118 -0
  31. pipeloom_airflow-0.6.0/src/pipeloom_airflow/testing/context.py +48 -0
  32. pipeloom_airflow-0.6.0/src/pipeloom_airflow/version.py +51 -0
  33. pipeloom_airflow-0.6.0/tests/airflow/_dag_test_helper.py +21 -0
  34. pipeloom_airflow-0.6.0/tests/airflow/_parse_helper.py +74 -0
  35. pipeloom_airflow-0.6.0/tests/airflow/conftest.py +134 -0
  36. pipeloom_airflow-0.6.0/tests/airflow/dags/shop_databricks.py +21 -0
  37. pipeloom_airflow-0.6.0/tests/airflow/dags/shop_group.py +21 -0
  38. pipeloom_airflow-0.6.0/tests/airflow/dags/shop_k8s.py +34 -0
  39. pipeloom_airflow-0.6.0/tests/airflow/dags/shop_local.py +18 -0
  40. pipeloom_airflow-0.6.0/tests/airflow/dags/shop_venv.py +26 -0
  41. pipeloom_airflow-0.6.0/tests/airflow/dags/wide_500.py +19 -0
  42. pipeloom_airflow-0.6.0/tests/airflow/project/models/models.yml +8 -0
  43. pipeloom_airflow-0.6.0/tests/airflow/project/pipeloom.yml +13 -0
  44. pipeloom_airflow-0.6.0/tests/airflow/project/src/afproj/__init__.py +0 -0
  45. pipeloom_airflow-0.6.0/tests/airflow/project/src/afproj/models.py +26 -0
  46. pipeloom_airflow-0.6.0/tests/airflow/test_dag.py +190 -0
  47. pipeloom_airflow-0.6.0/tests/airflow/test_databricks_launch.py +387 -0
  48. pipeloom_airflow-0.6.0/tests/airflow/test_databricks_trigger.py +232 -0
  49. pipeloom_airflow-0.6.0/tests/airflow/test_e2e.py +61 -0
  50. pipeloom_airflow-0.6.0/tests/airflow/test_finalize_operator.py +121 -0
  51. pipeloom_airflow-0.6.0/tests/airflow/test_kubernetes.py +279 -0
  52. pipeloom_airflow-0.6.0/tests/airflow/test_local_operator.py +136 -0
  53. pipeloom_airflow-0.6.0/tests/airflow/test_parse.py +175 -0
  54. pipeloom_airflow-0.6.0/tests/conftest.py +43 -0
  55. pipeloom_airflow-0.6.0/tests/data/child.jsonl +6 -0
  56. pipeloom_airflow-0.6.0/tests/test_commands.py +153 -0
  57. pipeloom_airflow-0.6.0/tests/test_config.py +151 -0
  58. pipeloom_airflow-0.6.0/tests/test_db_connection.py +91 -0
  59. pipeloom_airflow-0.6.0/tests/test_import.py +75 -0
  60. pipeloom_airflow-0.6.0/tests/test_launch_logic.py +194 -0
  61. pipeloom_airflow-0.6.0/tests/test_load.py +215 -0
  62. pipeloom_airflow-0.6.0/tests/test_mirror.py +100 -0
  63. pipeloom_airflow-0.6.0/tests/test_naming.py +68 -0
  64. pipeloom_airflow-0.6.0/tests/test_render.py +196 -0
  65. pipeloom_airflow-0.6.0/tests/test_states.py +106 -0
@@ -0,0 +1,16 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ build/
5
+ dist/
6
+ *.egg-info/
7
+ .pytest_cache/
8
+ .mypy_cache/
9
+ .ruff_cache/
10
+ .coverage
11
+ coverage.xml
12
+ htmlcov/
13
+ site/
14
+ target/
15
+ .pipeloom/
16
+ .env
@@ -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,2 @@
1
+ pipeloom
2
+ Copyright 2026 Emanuel Luis
@@ -0,0 +1,142 @@
1
+ Metadata-Version: 2.5
2
+ Name: pipeloom-airflow
3
+ Version: 0.6.0
4
+ Summary: Apache Airflow renderer for pipeloom: a compiled plan as one Airflow task per unit.
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: airflow,dag,data-engineering,orchestration,pipelines,pipeloom
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Framework :: Apache Airflow
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.11
24
+ Requires-Dist: pipeloom~=0.6.0
25
+ Provides-Extra: airflow
26
+ Requires-Dist: apache-airflow<4,>=3.2; extra == 'airflow'
27
+ Provides-Extra: databricks
28
+ Requires-Dist: apache-airflow<4,>=3.2; extra == 'databricks'
29
+ Requires-Dist: pipeloom-databricks~=0.6.0; extra == 'databricks'
30
+ Provides-Extra: kubernetes
31
+ Requires-Dist: apache-airflow-providers-cncf-kubernetes<11,>=10.25; extra == 'kubernetes'
32
+ Requires-Dist: apache-airflow<4,>=3.2; extra == 'kubernetes'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # pipeloom-airflow
36
+
37
+ The Apache Airflow renderer for [pipeloom](https://github.com/emanuel-luis/pipeloom). It turns a
38
+ compiled plan into the tasks of an Airflow DAG: one task per execution unit, plus a finalize task
39
+ that closes the run.
40
+
41
+ ```console
42
+ $ pip install "pipeloom-airflow[airflow]"
43
+ ```
44
+
45
+ Airflow is not a hard dependency. The extra pulls `apache-airflow>=3.2,<4`. Everything in this
46
+ release of the package is pure Python: configuration, loading a plan from a manifest or by
47
+ compiling the project, the task graph, the command lines a task runs and how Airflow task states
48
+ map to unit states. Importing the package never imports `airflow`.
49
+
50
+ - Load a plan from a stable manifest (`pipeloom compile --stable`), or compile the project on
51
+ the DAG parse path with a small on-disk cache keyed by the project files, the installed
52
+ pipeloom versions, the target and the variables.
53
+ - Every task runs `python -m pipeloom run --select unit:<id>` with a run id derived from the DAG
54
+ id and the Airflow run id, so a retried task and the finalize task agree on the run.
55
+ - The artifact root of the target must be one directory that every task and the finalize task
56
+ can see (a shared volume). A task that succeeded without a visible result file fails the run
57
+ with PLA004.
58
+ - Diagnostics: PLA001 (unsupported execution mode), PLA002 (invalid configuration), PLA003
59
+ (the selection renders no unit), PLA004 (a task ended without a unit result), PLA005
60
+ (unsupported Airflow version), PLA006 (the compile cache cannot be used), PLA007 (the target
61
+ boundary is not task).
62
+ - `PipeloomDag` (a `DAG` subclass) and `PipeloomTaskGroup` (a `TaskGroup` subclass) build the
63
+ tasks at parse time. Both add nothing else to the DAG; `PipeloomDag` adds the param
64
+ `full_refresh` (default false) unless you define it.
65
+ - Execution modes `local` (the worker's own interpreter) and `virtualenv`
66
+ (`ExecutionConfig.virtualenv_dir`, created on every worker with pipeloom installed). Each task
67
+ runs the core in a child process group; killing the task sends SIGTERM, then SIGKILL after
68
+ the cancel grace (the core default of 30 seconds; the manifest does not carry the target's
69
+ `cancel_grace`, and the same value sets a pod's termination grace). Exit 2, and exit 1 with a permanent error under
70
+ `retry_on: transient`, fail the task without a retry.
71
+ - The finalize task (`pipeloom_finalize`, trigger rule `all_done`, one retry) reads the states
72
+ of the unit tasks and runs `pipeloom finalize --unit-states`; it fails when the run failed, so
73
+ the DAG run fails too.
74
+
75
+ ```python
76
+ from datetime import datetime
77
+ from pipeloom_airflow.config import ProjectConfig
78
+ from pipeloom_airflow.dag import PipeloomDag
79
+
80
+ dag = PipeloomDag(
81
+ dag_id="shop",
82
+ schedule=None,
83
+ start_date=datetime(2026, 1, 1),
84
+ project_config=ProjectConfig("/srv/shop", manifest_path="/srv/shop/target/manifest.json"),
85
+ target="prod",
86
+ )
87
+ ```
88
+
89
+ ### Kubernetes mode
90
+
91
+ ```console
92
+ $ pip install "pipeloom-airflow[kubernetes]"
93
+ ```
94
+
95
+ `ExecutionMode.KUBERNETES` runs every unit, and the finalize step, as a pod built by
96
+ `KubernetesPodOperator` (cncf-kubernetes provider `>=10.25,<11`). Set
97
+ `ExecutionConfig.kubernetes=KubernetesConfig(image=..., namespace=..., python=..., pod_kwargs=...)`;
98
+ `project_dir` and `manifest_path` of the execution config are paths inside the pod. `pod_kwargs`
99
+ passes volumes, mounts, resources and a service account straight through, and
100
+ `ExecutionConfig.env` becomes pod environment variables. The artifact root must be shared storage
101
+ mounted at the same path in every pod (a ReadWriteMany claim or an object-store CSI mount, given
102
+ through `volumes` and `volume_mounts`). Pods are never deferrable and push no XCom, the arguments
103
+ are set when the task runs, and `retry_on` is not enforced because Airflow sees only the pod's
104
+ result. The finalize pod gets the unit states inline (`--unit-states-json`); above 120 KiB (one Linux exec argument is capped at 128 KiB) it
105
+ fails with PLA002, so split the project with `render_config.select`.
106
+
107
+ ### Databricks mode
108
+
109
+ ```console
110
+ $ pip install "pipeloom-airflow[databricks]"
111
+ ```
112
+
113
+ `ExecutionMode.DATABRICKS` runs the project as the Databricks job that `pipeloom-databricks`
114
+ renders, without the Databricks Airflow provider. The DAG gets a `pipeloom_launch` task, one
115
+ sensor per Databricks task key (with the plan's edges) and a `pipeloom_finalize` sensor on the
116
+ job's finalize task (trigger rule `all_done`) that fails when the pipeloom run failed.
117
+
118
+ - The launch compiles the project at `project_dir` on the worker, checks its plan hash against
119
+ the DAG's (PLX103), and starts the job run named after the DAG run. A missing job is PLD007 and
120
+ a job deployed from other settings is PLD008, unless `databricks_ensure_job=True` deploys it. A
121
+ retried or cleared launch attaches to the same run, or repairs it when a task failed;
122
+ Databricks owns the task retries. Launch retries default to 2.
123
+ - The Airflow connection `databricks_conn_id` (default `databricks_default`) holds the host and a
124
+ token in its password (or `extra.token`); with `extra.service_principal_oauth` true, the OAuth
125
+ client id is the login and its secret the password. No profile, `~/.databrickscfg` or
126
+ `DATABRICKS_*` variable is read; a connection that cannot be used is PLD010.
127
+ - `databricks_poll="per_task"` (the default) mirrors the run live: the launch returns right after
128
+ run-now or repair, and each sensor makes one `get_run` call. Without a verdict yet it defers on
129
+ its own trigger, which polls every `databricks_poll_interval` seconds (30 by default), rides out
130
+ up to 5 transient API errors in a row (429, 5xx, no answer) with doubling sleeps, and fails the
131
+ sensor on any other API error or when the retries run out. A sensor gives up after
132
+ `databricks_timeout` seconds (24 hours by default). Cost: one API call per waiting sensor per interval.
133
+ - `databricks_poll="shared"`: the launch defers on one trigger that polls the whole run, keeps
134
+ the final snapshot in its XCom, and the sensors read it without calling the API. One call per
135
+ interval in total, but a task's result shows only when the whole run is over.
136
+ - The triggerer needs `pipeloom-airflow[databricks]` installed in both modes. In `shared` mode the
137
+ launch's wait also ends after `databricks_timeout` seconds; the launch then retries and
138
+ attaches to the same run.
139
+
140
+ Airflow does not run on Windows, so neither do the DAG classes.
141
+
142
+ License: Apache-2.0.
@@ -0,0 +1,108 @@
1
+ # pipeloom-airflow
2
+
3
+ The Apache Airflow renderer for [pipeloom](https://github.com/emanuel-luis/pipeloom). It turns a
4
+ compiled plan into the tasks of an Airflow DAG: one task per execution unit, plus a finalize task
5
+ that closes the run.
6
+
7
+ ```console
8
+ $ pip install "pipeloom-airflow[airflow]"
9
+ ```
10
+
11
+ Airflow is not a hard dependency. The extra pulls `apache-airflow>=3.2,<4`. Everything in this
12
+ release of the package is pure Python: configuration, loading a plan from a manifest or by
13
+ compiling the project, the task graph, the command lines a task runs and how Airflow task states
14
+ map to unit states. Importing the package never imports `airflow`.
15
+
16
+ - Load a plan from a stable manifest (`pipeloom compile --stable`), or compile the project on
17
+ the DAG parse path with a small on-disk cache keyed by the project files, the installed
18
+ pipeloom versions, the target and the variables.
19
+ - Every task runs `python -m pipeloom run --select unit:<id>` with a run id derived from the DAG
20
+ id and the Airflow run id, so a retried task and the finalize task agree on the run.
21
+ - The artifact root of the target must be one directory that every task and the finalize task
22
+ can see (a shared volume). A task that succeeded without a visible result file fails the run
23
+ with PLA004.
24
+ - Diagnostics: PLA001 (unsupported execution mode), PLA002 (invalid configuration), PLA003
25
+ (the selection renders no unit), PLA004 (a task ended without a unit result), PLA005
26
+ (unsupported Airflow version), PLA006 (the compile cache cannot be used), PLA007 (the target
27
+ boundary is not task).
28
+ - `PipeloomDag` (a `DAG` subclass) and `PipeloomTaskGroup` (a `TaskGroup` subclass) build the
29
+ tasks at parse time. Both add nothing else to the DAG; `PipeloomDag` adds the param
30
+ `full_refresh` (default false) unless you define it.
31
+ - Execution modes `local` (the worker's own interpreter) and `virtualenv`
32
+ (`ExecutionConfig.virtualenv_dir`, created on every worker with pipeloom installed). Each task
33
+ runs the core in a child process group; killing the task sends SIGTERM, then SIGKILL after
34
+ the cancel grace (the core default of 30 seconds; the manifest does not carry the target's
35
+ `cancel_grace`, and the same value sets a pod's termination grace). Exit 2, and exit 1 with a permanent error under
36
+ `retry_on: transient`, fail the task without a retry.
37
+ - The finalize task (`pipeloom_finalize`, trigger rule `all_done`, one retry) reads the states
38
+ of the unit tasks and runs `pipeloom finalize --unit-states`; it fails when the run failed, so
39
+ the DAG run fails too.
40
+
41
+ ```python
42
+ from datetime import datetime
43
+ from pipeloom_airflow.config import ProjectConfig
44
+ from pipeloom_airflow.dag import PipeloomDag
45
+
46
+ dag = PipeloomDag(
47
+ dag_id="shop",
48
+ schedule=None,
49
+ start_date=datetime(2026, 1, 1),
50
+ project_config=ProjectConfig("/srv/shop", manifest_path="/srv/shop/target/manifest.json"),
51
+ target="prod",
52
+ )
53
+ ```
54
+
55
+ ### Kubernetes mode
56
+
57
+ ```console
58
+ $ pip install "pipeloom-airflow[kubernetes]"
59
+ ```
60
+
61
+ `ExecutionMode.KUBERNETES` runs every unit, and the finalize step, as a pod built by
62
+ `KubernetesPodOperator` (cncf-kubernetes provider `>=10.25,<11`). Set
63
+ `ExecutionConfig.kubernetes=KubernetesConfig(image=..., namespace=..., python=..., pod_kwargs=...)`;
64
+ `project_dir` and `manifest_path` of the execution config are paths inside the pod. `pod_kwargs`
65
+ passes volumes, mounts, resources and a service account straight through, and
66
+ `ExecutionConfig.env` becomes pod environment variables. The artifact root must be shared storage
67
+ mounted at the same path in every pod (a ReadWriteMany claim or an object-store CSI mount, given
68
+ through `volumes` and `volume_mounts`). Pods are never deferrable and push no XCom, the arguments
69
+ are set when the task runs, and `retry_on` is not enforced because Airflow sees only the pod's
70
+ result. The finalize pod gets the unit states inline (`--unit-states-json`); above 120 KiB (one Linux exec argument is capped at 128 KiB) it
71
+ fails with PLA002, so split the project with `render_config.select`.
72
+
73
+ ### Databricks mode
74
+
75
+ ```console
76
+ $ pip install "pipeloom-airflow[databricks]"
77
+ ```
78
+
79
+ `ExecutionMode.DATABRICKS` runs the project as the Databricks job that `pipeloom-databricks`
80
+ renders, without the Databricks Airflow provider. The DAG gets a `pipeloom_launch` task, one
81
+ sensor per Databricks task key (with the plan's edges) and a `pipeloom_finalize` sensor on the
82
+ job's finalize task (trigger rule `all_done`) that fails when the pipeloom run failed.
83
+
84
+ - The launch compiles the project at `project_dir` on the worker, checks its plan hash against
85
+ the DAG's (PLX103), and starts the job run named after the DAG run. A missing job is PLD007 and
86
+ a job deployed from other settings is PLD008, unless `databricks_ensure_job=True` deploys it. A
87
+ retried or cleared launch attaches to the same run, or repairs it when a task failed;
88
+ Databricks owns the task retries. Launch retries default to 2.
89
+ - The Airflow connection `databricks_conn_id` (default `databricks_default`) holds the host and a
90
+ token in its password (or `extra.token`); with `extra.service_principal_oauth` true, the OAuth
91
+ client id is the login and its secret the password. No profile, `~/.databrickscfg` or
92
+ `DATABRICKS_*` variable is read; a connection that cannot be used is PLD010.
93
+ - `databricks_poll="per_task"` (the default) mirrors the run live: the launch returns right after
94
+ run-now or repair, and each sensor makes one `get_run` call. Without a verdict yet it defers on
95
+ its own trigger, which polls every `databricks_poll_interval` seconds (30 by default), rides out
96
+ up to 5 transient API errors in a row (429, 5xx, no answer) with doubling sleeps, and fails the
97
+ sensor on any other API error or when the retries run out. A sensor gives up after
98
+ `databricks_timeout` seconds (24 hours by default). Cost: one API call per waiting sensor per interval.
99
+ - `databricks_poll="shared"`: the launch defers on one trigger that polls the whole run, keeps
100
+ the final snapshot in its XCom, and the sensors read it without calling the API. One call per
101
+ interval in total, but a task's result shows only when the whole run is over.
102
+ - The triggerer needs `pipeloom-airflow[databricks]` installed in both modes. In `shared` mode the
103
+ launch's wait also ends after `databricks_timeout` seconds; the launch then retries and
104
+ attaches to the same run.
105
+
106
+ Airflow does not run on Windows, so neither do the DAG classes.
107
+
108
+ License: Apache-2.0.
@@ -0,0 +1,52 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "pipeloom-airflow"
7
+ version = "0.6.0"
8
+ description = "Apache Airflow renderer for pipeloom: a compiled plan as one Airflow task per unit."
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", "airflow", "dag", "orchestration", "data-engineering", "pipelines"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Developers",
18
+ "Framework :: Apache Airflow",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3 :: Only",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Programming Language :: Python :: 3.14",
25
+ "Typing :: Typed",
26
+ ]
27
+ # Airflow is not a hard dependency: the pure modules (configs, loading, rendering, argv, states)
28
+ # run without it. Install the extra on a machine that runs DAGs.
29
+ dependencies = ["pipeloom~=0.6.0"]
30
+
31
+ [project.optional-dependencies]
32
+ airflow = ["apache-airflow>=3.2,<4"]
33
+ kubernetes = [
34
+ "apache-airflow>=3.2,<4",
35
+ "apache-airflow-providers-cncf-kubernetes>=10.25,<11",
36
+ ]
37
+ databricks = ["apache-airflow>=3.2,<4", "pipeloom-databricks~=0.6.0"]
38
+
39
+ [project.urls]
40
+ Repository = "https://github.com/emanuel-luis/pipeloom"
41
+ Documentation = "https://emanuel-luis.github.io/pipeloom/"
42
+ Changelog = "https://github.com/emanuel-luis/pipeloom/blob/main/CHANGELOG.md"
43
+
44
+ [tool.uv.sources]
45
+ pipeloom = { workspace = true }
46
+ pipeloom-databricks = { workspace = true }
47
+
48
+ [tool.hatch.build.targets.wheel]
49
+ packages = ["src/pipeloom_airflow"]
50
+
51
+ [tool.hatch.build.targets.sdist]
52
+ only-include = ["src", "tests", "LICENSE", "NOTICE", "README.md"]
@@ -0,0 +1,35 @@
1
+ """Apache Airflow renderer for pipeloom.
2
+
3
+ Importing the package imports nothing: names load on first use (PEP 562). Only the modules
4
+ `_compat` and `_compat_k8s`, which arrive with the DAG classes, may import `airflow`.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import importlib
10
+ from typing import Any
11
+
12
+ _LAZY = {
13
+ "ExecutionConfig": "config",
14
+ "ExecutionMode": "config",
15
+ "KubernetesConfig": "config",
16
+ "LoadMode": "config",
17
+ "ProjectConfig": "config",
18
+ "RenderConfig": "config",
19
+ "validate_configs": "config",
20
+ "PipeloomAirflowError": "errors",
21
+ "LoadedPlan": "load",
22
+ "load_plan": "load",
23
+ "TaskPlan": "render",
24
+ "UnitTask": "render",
25
+ "render_plan": "render",
26
+ }
27
+
28
+ __all__ = list(_LAZY)
29
+
30
+
31
+ def __getattr__(name: str) -> Any:
32
+ module = _LAZY.get(name)
33
+ if module is None:
34
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
35
+ return getattr(importlib.import_module(f"{__name__}.{module}"), name)
@@ -0,0 +1,92 @@
1
+ """The one module of the plugin that imports `airflow` (with `_compat_k8s`). Every name the plugin
2
+ uses from Airflow comes from here, so a move between Airflow minors is fixed in one place."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import asyncio
7
+ from collections.abc import Mapping, Sequence
8
+ from typing import TYPE_CHECKING, Any
9
+
10
+ from pipeloom_airflow.version import require_airflow
11
+
12
+ # Before any Airflow import: an unsupported or missing Airflow is PLA005, not an ImportError.
13
+ require_airflow()
14
+
15
+ from airflow.sdk import (
16
+ DAG,
17
+ Asset,
18
+ BaseHook,
19
+ BaseOperator,
20
+ BaseSensorOperator,
21
+ Param,
22
+ TaskGroup,
23
+ )
24
+ from airflow.sdk.exceptions import (
25
+ AirflowException,
26
+ AirflowFailException,
27
+ AirflowSkipException,
28
+ )
29
+ from airflow.triggers.base import BaseTrigger, TriggerEvent
30
+
31
+ if TYPE_CHECKING:
32
+ from airflow.sdk import Context
33
+ else:
34
+ Context = Mapping[str, Any]
35
+
36
+ __all__ = [
37
+ "DAG",
38
+ "AirflowException",
39
+ "AirflowFailException",
40
+ "AirflowSkipException",
41
+ "Asset",
42
+ "BaseHook",
43
+ "BaseOperator",
44
+ "BaseSensorOperator",
45
+ "BaseTrigger",
46
+ "Context",
47
+ "Param",
48
+ "TaskGroup",
49
+ "TriggerEvent",
50
+ "aget_connection",
51
+ "airflow_version",
52
+ "get_connection",
53
+ "get_task_states",
54
+ "mask_secret",
55
+ ]
56
+
57
+
58
+ def get_connection(conn_id: str) -> Any:
59
+ """The connection, from a worker."""
60
+ return BaseHook.get_connection(conn_id)
61
+
62
+
63
+ def mask_secret(value: str) -> None:
64
+ """Hide `value` in task and triggerer logs."""
65
+ import airflow.sdk
66
+
67
+ masker = getattr(airflow.sdk, "mask_secret", None)
68
+ if masker is not None:
69
+ masker(value)
70
+
71
+
72
+ def airflow_version() -> str:
73
+ from airflow import __version__
74
+
75
+ return str(__version__)
76
+
77
+
78
+ def get_task_states(
79
+ ti: Any, dag_id: str, task_ids: Sequence[str], run_id: str
80
+ ) -> dict[str, str | None]:
81
+ """Task id -> state of the given tasks in one DAG run, as the task SDK reports them."""
82
+ found = ti.get_task_states(dag_id=dag_id, task_ids=list(task_ids), run_ids=[run_id])
83
+ states = found.get(run_id, {}) if isinstance(found, Mapping) else {}
84
+ return {str(k): (None if v is None else str(v)) for k, v in states.items()}
85
+
86
+
87
+ async def aget_connection(conn_id: str) -> Any:
88
+ """The connection, without blocking the event loop of a trigger."""
89
+ getter = getattr(BaseHook, "aget_connection", None)
90
+ if getter is not None:
91
+ return await getter(conn_id)
92
+ return await asyncio.to_thread(BaseHook.get_connection, conn_id)