dagprobe 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dagprobe-0.1.0/.gitignore +32 -0
- dagprobe-0.1.0/LICENSE +202 -0
- dagprobe-0.1.0/PKG-INFO +110 -0
- dagprobe-0.1.0/README.md +83 -0
- dagprobe-0.1.0/examples/broken/double_task.py +12 -0
- dagprobe-0.1.0/examples/ci/github-actions.yml +51 -0
- dagprobe-0.1.0/examples/dags/branch_etl.py +54 -0
- dagprobe-0.1.0/examples/dags/db_join.py +34 -0
- dagprobe-0.1.0/examples/dags/migration_legacy.py +46 -0
- dagprobe-0.1.0/examples/dags/migration_xcom.py +48 -0
- dagprobe-0.1.0/examples/dags/sales_files.py +36 -0
- dagprobe-0.1.0/examples/fixtures/branch.yaml +9 -0
- dagprobe-0.1.0/examples/fixtures/dwh.yaml +17 -0
- dagprobe-0.1.0/examples/fixtures/files.yaml +19 -0
- dagprobe-0.1.0/pyproject.toml +82 -0
- dagprobe-0.1.0/src/dagprobe/__init__.py +1 -0
- dagprobe-0.1.0/src/dagprobe/analyze.py +243 -0
- dagprobe-0.1.0/src/dagprobe/audit.py +79 -0
- dagprobe-0.1.0/src/dagprobe/ci.py +161 -0
- dagprobe-0.1.0/src/dagprobe/cli.py +292 -0
- dagprobe-0.1.0/src/dagprobe/errors.py +41 -0
- dagprobe-0.1.0/src/dagprobe/fixtures.py +167 -0
- dagprobe-0.1.0/src/dagprobe/lint.py +138 -0
- dagprobe-0.1.0/src/dagprobe/shim/__init__.py +32 -0
- dagprobe-0.1.0/src/dagprobe/shim/_core.py +167 -0
- dagprobe-0.1.0/src/dagprobe/shim/_fileintercept.py +172 -0
- dagprobe-0.1.0/src/dagprobe/shim/_intercept.py +73 -0
- dagprobe-0.1.0/src/dagprobe/shim/_taskflow.py +161 -0
- dagprobe-0.1.0/src/dagprobe/shim/_templates.py +224 -0
- dagprobe-0.1.0/src/dagprobe/shim/airflow/__init__.py +27 -0
- dagprobe-0.1.0/src/dagprobe/shim/airflow/example_dags/__init__.py +1 -0
- dagprobe-0.1.0/src/dagprobe/shim/airflow/example_dags/plugins/__init__.py +1 -0
- dagprobe-0.1.0/src/dagprobe/shim/airflow/example_dags/plugins/workday.py +114 -0
- dagprobe-0.1.0/src/dagprobe/shim/airflow/plugins_manager.py +20 -0
- dagprobe-0.1.0/src/dagprobe/shim/airflow/providers/standard/operators/bash.py +11 -0
- dagprobe-0.1.0/src/dagprobe/shim/airflow/providers/standard/operators/empty.py +9 -0
- dagprobe-0.1.0/src/dagprobe/shim/airflow/providers/standard/operators/python.py +48 -0
- dagprobe-0.1.0/src/dagprobe/shim/airflow/sdk/__init__.py +36 -0
- dagprobe-0.1.0/src/dagprobe/shim/airflow/sdk/bases/__init__.py +0 -0
- dagprobe-0.1.0/src/dagprobe/shim/airflow/sdk/bases/hook.py +98 -0
- dagprobe-0.1.0/src/dagprobe/shim/airflow/timetables/__init__.py +1 -0
- dagprobe-0.1.0/src/dagprobe/shim/airflow/timetables/base.py +45 -0
- dagprobe-0.1.0/src/dagprobe/shim/finder.py +70 -0
- dagprobe-0.1.0/src/dagprobe/shim/xcom.py +70 -0
- dagprobe-0.1.0/src/dagprobe/task_test.py +275 -0
- dagprobe-0.1.0/tests/test_package.py +7 -0
- dagprobe-0.1.0/tests/test_parallel_runs.py +47 -0
- dagprobe-0.1.0/tests/test_slice1.py +95 -0
- dagprobe-0.1.0/tests/test_slice3.py +160 -0
- dagprobe-0.1.0/tests/test_slice4.py +134 -0
- dagprobe-0.1.0/tests/test_slice5.py +198 -0
- dagprobe-0.1.0/tests/test_slice6.py +174 -0
- dagprobe-0.1.0/tests/test_slice7.py +271 -0
- dagprobe-0.1.0/tests/test_slice8.py +123 -0
- dagprobe-0.1.0/tests/test_slice9.py +42 -0
- dagprobe-0.1.0/tests/test_spike_mode_a.py +103 -0
- dagprobe-0.1.0/tests/test_templates.py +104 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.egg-info/
|
|
6
|
+
.eggs/
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
|
|
10
|
+
# Virtual envs
|
|
11
|
+
.venv/
|
|
12
|
+
venv/
|
|
13
|
+
env/
|
|
14
|
+
# Windows-окружение рядом с linux-venv песочницы (на хосте .venv занят линуксовым, см. HANDOFF «Уроки»)
|
|
15
|
+
.venv-win/
|
|
16
|
+
|
|
17
|
+
# uv
|
|
18
|
+
.uv/
|
|
19
|
+
|
|
20
|
+
# Editors / IDE
|
|
21
|
+
.idea/
|
|
22
|
+
.vscode/
|
|
23
|
+
*.swp
|
|
24
|
+
|
|
25
|
+
# OS
|
|
26
|
+
.DS_Store
|
|
27
|
+
Thumbs.db
|
|
28
|
+
# артефакты сравнения A/B — генерятся spike/inspect_dags.py и CI
|
|
29
|
+
spike/out/
|
|
30
|
+
.coverage
|
|
31
|
+
# артефакты A/B статусов — генерятся spike/run_ab.py
|
|
32
|
+
spike/ab_dags/
|
dagprobe-0.1.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.
|
dagprobe-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: dagprobe
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Debug and test Apache Airflow DAGs without installing and running Airflow
|
|
5
|
+
Project-URL: Homepage, https://github.com/AndreyGor97/dagprobe
|
|
6
|
+
Project-URL: Repository, https://github.com/AndreyGor97/dagprobe
|
|
7
|
+
Project-URL: Issues, https://github.com/AndreyGor97/dagprobe/issues
|
|
8
|
+
Author: AndreyGor97
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: airflow,apache-airflow,ci,dag,lint,migration,testing
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
21
|
+
Classifier: Topic :: Software Development :: Testing
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Requires-Dist: jinja2>=3.1
|
|
24
|
+
Requires-Dist: pandas>=2.2
|
|
25
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# DagProbe
|
|
29
|
+
|
|
30
|
+
Debug and test [Apache Airflow](https://airflow.apache.org/) DAGs **without installing or running Airflow**.
|
|
31
|
+
|
|
32
|
+
DagProbe imports your DAG files against a lightweight shim of the Airflow SDK, then lets you
|
|
33
|
+
lint them, preview their Jinja rendering, run tasks against YAML fixtures, and audit behavior
|
|
34
|
+
differences between Airflow 2.10 and 3.3 — all in a plain Python environment, in seconds,
|
|
35
|
+
with no Airflow installation, no database and no scheduler.
|
|
36
|
+
|
|
37
|
+
```console
|
|
38
|
+
$ pip install dagprobe
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## What it does
|
|
42
|
+
|
|
43
|
+
| Command | Purpose |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `dagprobe list` | Import a DAGs folder, list DAG ids and import errors (with timing) |
|
|
46
|
+
| `dagprobe lint` | Import + static lint for CI: duplicate task ids, `datetime.now()` in DAG code, missing `catchup=`, deprecated kwargs; `--changed-only` lints just the files changed vs a base branch |
|
|
47
|
+
| `dagprobe render` | Jinja preview: rendered `template_fields` per task (before → after) |
|
|
48
|
+
| `dagprobe run` | Task Test: execute a DAG's tasks against fixtures — `PythonOperator` callables run for real, `trigger_rule` and `BranchPythonOperator` branching follow Airflow semantics, in-memory DB connections read/write across tasks |
|
|
49
|
+
| `dagprobe audit 2to3` | Run the same DAG under the 2.10 and 3.3 behavior profiles and report divergences (e.g. XCom value unwrapping, task `status` changes) |
|
|
50
|
+
|
|
51
|
+
`lint` and `run` are CI-first: `--format text|json|junit` and `--fail-on error|warning|never`,
|
|
52
|
+
stable exit codes (`0` clean, `1` findings at gate level, `2` usage/setup error), JUnit output
|
|
53
|
+
for PR test reports. A ready GitHub Actions workflow ships in
|
|
54
|
+
[`examples/ci/github-actions.yml`](examples/ci/github-actions.yml).
|
|
55
|
+
|
|
56
|
+
## Quickstart
|
|
57
|
+
|
|
58
|
+
```console
|
|
59
|
+
# what's in my DAGs folder, and does everything even import?
|
|
60
|
+
$ dagprobe list --dags-folder dags
|
|
61
|
+
|
|
62
|
+
# run one DAG's tasks against fixtures (fake conns, tables, files)
|
|
63
|
+
$ dagprobe run --dags-folder dags --dag-id branch_etl \
|
|
64
|
+
--fixtures fixtures/branch.yaml
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Fixtures are a small YAML file — no Airflow metadata database involved:
|
|
68
|
+
|
|
69
|
+
```yaml
|
|
70
|
+
conns:
|
|
71
|
+
dwh:
|
|
72
|
+
conn_type: postgres
|
|
73
|
+
tables:
|
|
74
|
+
events:
|
|
75
|
+
- {event: signup, n: 3}
|
|
76
|
+
- {event: purchase, n: 1}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
More runnable examples: [`examples/dags/`](examples/dags/) with matching
|
|
80
|
+
[`examples/fixtures/`](examples/fixtures/), including a deliberately broken DAG
|
|
81
|
+
(`examples/broken/`) that demonstrates the CI gate.
|
|
82
|
+
|
|
83
|
+
## How it works
|
|
84
|
+
|
|
85
|
+
DagProbe ships a versioned shim of the Airflow import surface (`airflow.sdk`,
|
|
86
|
+
`airflow.providers.standard`, hooks, operators). Your DAG file is imported against the shim,
|
|
87
|
+
so imports resolve without an Airflow install — typically in well under a second per file,
|
|
88
|
+
versus tens of seconds to boot a real Airflow environment. Task execution reuses the same
|
|
89
|
+
Jinja engine Airflow uses, so template rendering is comparable 1:1.
|
|
90
|
+
|
|
91
|
+
Behavior profiles: `run` defaults to the Airflow 3.3 profile; `dagprobe audit 2to3` runs the
|
|
92
|
+
same DAG under both the 2.10 legacy and the 3.3 profile and reports concrete behavioral
|
|
93
|
+
divergences per task — the things that break silently during a 2.x → 3.x migration.
|
|
94
|
+
|
|
95
|
+
## Scope and limitations
|
|
96
|
+
|
|
97
|
+
- Airflow version profiles: **2.10 and 3.3** (arbitrary version pinning is on the roadmap).
|
|
98
|
+
- SQL runs on an in-memory SQLite via an emulated engine — real warehouse dialects are out of scope.
|
|
99
|
+
- No scheduler, no real network/connections: tasks run in-process against fixtures.
|
|
100
|
+
- Static lint covers a focused rule set, not a general Python linter — pair it with `ruff`.
|
|
101
|
+
|
|
102
|
+
## Development
|
|
103
|
+
|
|
104
|
+
```console
|
|
105
|
+
$ git clone https://github.com/AndreyGor97/dagprobe
|
|
106
|
+
$ cd dagprobe && uv sync
|
|
107
|
+
$ uv run pytest
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Requires Python 3.11+. Apache-2.0 licensed; not affiliated with the Apache Software Foundation.
|
dagprobe-0.1.0/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# DagProbe
|
|
2
|
+
|
|
3
|
+
Debug and test [Apache Airflow](https://airflow.apache.org/) DAGs **without installing or running Airflow**.
|
|
4
|
+
|
|
5
|
+
DagProbe imports your DAG files against a lightweight shim of the Airflow SDK, then lets you
|
|
6
|
+
lint them, preview their Jinja rendering, run tasks against YAML fixtures, and audit behavior
|
|
7
|
+
differences between Airflow 2.10 and 3.3 — all in a plain Python environment, in seconds,
|
|
8
|
+
with no Airflow installation, no database and no scheduler.
|
|
9
|
+
|
|
10
|
+
```console
|
|
11
|
+
$ pip install dagprobe
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## What it does
|
|
15
|
+
|
|
16
|
+
| Command | Purpose |
|
|
17
|
+
|---|---|
|
|
18
|
+
| `dagprobe list` | Import a DAGs folder, list DAG ids and import errors (with timing) |
|
|
19
|
+
| `dagprobe lint` | Import + static lint for CI: duplicate task ids, `datetime.now()` in DAG code, missing `catchup=`, deprecated kwargs; `--changed-only` lints just the files changed vs a base branch |
|
|
20
|
+
| `dagprobe render` | Jinja preview: rendered `template_fields` per task (before → after) |
|
|
21
|
+
| `dagprobe run` | Task Test: execute a DAG's tasks against fixtures — `PythonOperator` callables run for real, `trigger_rule` and `BranchPythonOperator` branching follow Airflow semantics, in-memory DB connections read/write across tasks |
|
|
22
|
+
| `dagprobe audit 2to3` | Run the same DAG under the 2.10 and 3.3 behavior profiles and report divergences (e.g. XCom value unwrapping, task `status` changes) |
|
|
23
|
+
|
|
24
|
+
`lint` and `run` are CI-first: `--format text|json|junit` and `--fail-on error|warning|never`,
|
|
25
|
+
stable exit codes (`0` clean, `1` findings at gate level, `2` usage/setup error), JUnit output
|
|
26
|
+
for PR test reports. A ready GitHub Actions workflow ships in
|
|
27
|
+
[`examples/ci/github-actions.yml`](examples/ci/github-actions.yml).
|
|
28
|
+
|
|
29
|
+
## Quickstart
|
|
30
|
+
|
|
31
|
+
```console
|
|
32
|
+
# what's in my DAGs folder, and does everything even import?
|
|
33
|
+
$ dagprobe list --dags-folder dags
|
|
34
|
+
|
|
35
|
+
# run one DAG's tasks against fixtures (fake conns, tables, files)
|
|
36
|
+
$ dagprobe run --dags-folder dags --dag-id branch_etl \
|
|
37
|
+
--fixtures fixtures/branch.yaml
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Fixtures are a small YAML file — no Airflow metadata database involved:
|
|
41
|
+
|
|
42
|
+
```yaml
|
|
43
|
+
conns:
|
|
44
|
+
dwh:
|
|
45
|
+
conn_type: postgres
|
|
46
|
+
tables:
|
|
47
|
+
events:
|
|
48
|
+
- {event: signup, n: 3}
|
|
49
|
+
- {event: purchase, n: 1}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
More runnable examples: [`examples/dags/`](examples/dags/) with matching
|
|
53
|
+
[`examples/fixtures/`](examples/fixtures/), including a deliberately broken DAG
|
|
54
|
+
(`examples/broken/`) that demonstrates the CI gate.
|
|
55
|
+
|
|
56
|
+
## How it works
|
|
57
|
+
|
|
58
|
+
DagProbe ships a versioned shim of the Airflow import surface (`airflow.sdk`,
|
|
59
|
+
`airflow.providers.standard`, hooks, operators). Your DAG file is imported against the shim,
|
|
60
|
+
so imports resolve without an Airflow install — typically in well under a second per file,
|
|
61
|
+
versus tens of seconds to boot a real Airflow environment. Task execution reuses the same
|
|
62
|
+
Jinja engine Airflow uses, so template rendering is comparable 1:1.
|
|
63
|
+
|
|
64
|
+
Behavior profiles: `run` defaults to the Airflow 3.3 profile; `dagprobe audit 2to3` runs the
|
|
65
|
+
same DAG under both the 2.10 legacy and the 3.3 profile and reports concrete behavioral
|
|
66
|
+
divergences per task — the things that break silently during a 2.x → 3.x migration.
|
|
67
|
+
|
|
68
|
+
## Scope and limitations
|
|
69
|
+
|
|
70
|
+
- Airflow version profiles: **2.10 and 3.3** (arbitrary version pinning is on the roadmap).
|
|
71
|
+
- SQL runs on an in-memory SQLite via an emulated engine — real warehouse dialects are out of scope.
|
|
72
|
+
- No scheduler, no real network/connections: tasks run in-process against fixtures.
|
|
73
|
+
- Static lint covers a focused rule set, not a general Python linter — pair it with `ruff`.
|
|
74
|
+
|
|
75
|
+
## Development
|
|
76
|
+
|
|
77
|
+
```console
|
|
78
|
+
$ git clone https://github.com/AndreyGor97/dagprobe
|
|
79
|
+
$ cd dagprobe && uv sync
|
|
80
|
+
$ uv run pytest
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Requires Python 3.11+. Apache-2.0 licensed; not affiliated with the Apache Software Foundation.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""DAG с дублем `task_id` — демонстрация CI-гейта (§6.21).
|
|
2
|
+
|
|
3
|
+
`dagprobe lint --dags-folder examples/broken` отдаёт DUPLICATE_TASK_ID (error),
|
|
4
|
+
exit 1 и JUnit с `<failure>`: ровно то, на чём CI не пропускает мердж.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from airflow.providers.standard.operators.python import PythonOperator
|
|
8
|
+
from airflow.sdk import DAG
|
|
9
|
+
|
|
10
|
+
with DAG("double_task", schedule=None, start_date=None, catchup=False) as dag:
|
|
11
|
+
PythonOperator(task_id="extract", python_callable=lambda **_: 1)
|
|
12
|
+
PythonOperator(task_id="extract", python_callable=lambda **_: 2)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# DAGProbe в CI (§6.21): шаблон GitHub Actions.
|
|
2
|
+
# Копируется в <ваш-репозиторий>/.github/workflows/dagprobe.yml и правится
|
|
3
|
+
# только --dags-folder (каталог с DAG'ами) и база diff.
|
|
4
|
+
#
|
|
5
|
+
# Поведение: линтуются и импортируются только изменённые в PR файлы; ошибки
|
|
6
|
+
# роняют джобу (exit 1 — шаг падает), рядом падает отчёт JUnit в PR.
|
|
7
|
+
# Уровень, который роняет мердж, настраивается --fail-on error|warning|never.
|
|
8
|
+
name: dagprobe
|
|
9
|
+
|
|
10
|
+
on: pull_request
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
dags:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
with:
|
|
18
|
+
fetch-depth: 0 # нужен diff к базовой ветке для --changed-only
|
|
19
|
+
|
|
20
|
+
- uses: astral-sh/setup-uv@v5
|
|
21
|
+
- run: uv sync --frozen
|
|
22
|
+
|
|
23
|
+
# exit 1 при находках уровня gate: джоба падает, мердж не проходит
|
|
24
|
+
- name: Линт изменённых DAG
|
|
25
|
+
run: |
|
|
26
|
+
uv run dagprobe lint --dags-folder dags --changed-only \
|
|
27
|
+
--base-ref "origin/${{ github.base_ref }}" --format junit \
|
|
28
|
+
> dagprobe-lint.xml
|
|
29
|
+
|
|
30
|
+
# отчёт в PR — даже когда шаг выше упал (файл уже записан)
|
|
31
|
+
- name: Отчёт в PR
|
|
32
|
+
if: always()
|
|
33
|
+
uses: dorny/test-reporter@v1
|
|
34
|
+
with:
|
|
35
|
+
name: dagprobe lint
|
|
36
|
+
path: dagprobe-lint.xml
|
|
37
|
+
reporter: java-junit
|
|
38
|
+
|
|
39
|
+
# прогон DAG на фикстурах: те же exit-коды и тот же JUnit
|
|
40
|
+
- name: Прогон DAG на фикстурах
|
|
41
|
+
run: |
|
|
42
|
+
uv run dagprobe run --dags-folder examples/dags --dag-id db_join_etl \
|
|
43
|
+
--fixtures examples/fixtures/dwh.yaml --format junit > dagprobe-run.xml
|
|
44
|
+
|
|
45
|
+
- name: Отчёт по прогону
|
|
46
|
+
if: always()
|
|
47
|
+
uses: dorny/test-reporter@v1
|
|
48
|
+
with:
|
|
49
|
+
name: dagprobe run
|
|
50
|
+
path: dagprobe-run.xml
|
|
51
|
+
reporter: java-junit
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Пример Среза 7: ветвление и trigger_rule в прогоне.
|
|
2
|
+
|
|
3
|
+
``route`` — BranchPythonOperator: на непустых данных выбирает ``load_events``,
|
|
4
|
+
иначе ``load_empty``. Невыбранные ветки получают skipped, дальше решает
|
|
5
|
+
trigger_rule: ``load_empty`` стоит с ``all_failed`` (не выполнено → skipped,
|
|
6
|
+
как в Airflow), ``report`` после ``load_events`` — обычный all_success.
|
|
7
|
+
|
|
8
|
+
``load_events`` пишет в таблицу через ``DbApiHook.insert_rows`` (Срез 7),
|
|
9
|
+
``report`` читает её обратно — запись видна следующей задаче прогона.
|
|
10
|
+
|
|
11
|
+
Запуск из клона DagProbe:
|
|
12
|
+
|
|
13
|
+
uv run dagprobe run --dags-folder examples/dags --dag-id branch_etl \\
|
|
14
|
+
--fixtures examples/fixtures/branch.yaml
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from airflow.providers.standard.operators.python import BranchPythonOperator, PythonOperator
|
|
18
|
+
from airflow.sdk import DAG
|
|
19
|
+
from airflow.sdk.bases.hook import DbApiHook
|
|
20
|
+
|
|
21
|
+
with DAG("branch_etl", schedule=None, start_date=None, catchup=False) as dag:
|
|
22
|
+
|
|
23
|
+
def extract(**_):
|
|
24
|
+
return DbApiHook(conn_id="dwh").get_records("SELECT * FROM events")
|
|
25
|
+
|
|
26
|
+
def route(rows, **_):
|
|
27
|
+
return "load_events" if rows else "load_empty"
|
|
28
|
+
|
|
29
|
+
def load_events(rows, **_):
|
|
30
|
+
# таблицу создаём сами: фикстура даёт только events, INSERT в несуществующую — ошибка
|
|
31
|
+
DbApiHook(conn_id="dwh").run("CREATE TABLE IF NOT EXISTS events_loaded (event, n)")
|
|
32
|
+
DbApiHook(conn_id="dwh").insert_rows("events_loaded", rows, target_fields=["event", "n"])
|
|
33
|
+
return f"loaded {len(rows)} rows"
|
|
34
|
+
|
|
35
|
+
def report(msg, **_):
|
|
36
|
+
count = DbApiHook(conn_id="dwh").get_records("SELECT COUNT(*) AS c FROM events_loaded")
|
|
37
|
+
return f"{msg}; в таблице events_loaded строк: {count[0]['c']}"
|
|
38
|
+
|
|
39
|
+
extract_task = PythonOperator(task_id="extract", python_callable=extract)
|
|
40
|
+
route_task = BranchPythonOperator(
|
|
41
|
+
task_id="route", python_callable=route, op_kwargs={"rows": extract_task.output}
|
|
42
|
+
)
|
|
43
|
+
load_empty = PythonOperator(
|
|
44
|
+
task_id="load_empty", python_callable=lambda **_: "пустые данные", trigger_rule="all_failed"
|
|
45
|
+
)
|
|
46
|
+
load_events_task = PythonOperator(
|
|
47
|
+
task_id="load_events", python_callable=load_events, op_kwargs={"rows": extract_task.output}
|
|
48
|
+
)
|
|
49
|
+
report_task = PythonOperator(
|
|
50
|
+
task_id="report", python_callable=report, op_kwargs={"msg": load_events_task.output}
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
extract_task >> route_task >> [load_events_task, load_empty]
|
|
54
|
+
load_events_task >> report_task
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Пример Среза 4: честный SQL (JOIN + GROUP BY) без Postgres и без Docker.
|
|
2
|
+
|
|
3
|
+
Данные для соединения ``dwh`` лежат в ``examples/fixtures/dwh.yaml`` (уровень
|
|
4
|
+
Emulated Engine §8.2): таблицы грузятся в in-memory SQLite, и запрос исполняется
|
|
5
|
+
по-настоящему — считает движок, а не фикстура.
|
|
6
|
+
|
|
7
|
+
Запуск из клона DagProbe:
|
|
8
|
+
|
|
9
|
+
uv run dagprobe run --dags-folder examples/dags --dag-id db_join_etl \\
|
|
10
|
+
--fixtures examples/fixtures/dwh.yaml
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from airflow.providers.standard.operators.python import PythonOperator
|
|
14
|
+
from airflow.sdk import DAG, task
|
|
15
|
+
from airflow.sdk.bases.hook import DbApiHook
|
|
16
|
+
|
|
17
|
+
with DAG("db_join_etl", schedule=None, start_date=None, catchup=False) as dag:
|
|
18
|
+
|
|
19
|
+
def extract(**_):
|
|
20
|
+
return DbApiHook(conn_id="dwh").get_records(
|
|
21
|
+
"SELECT c.name AS customer, SUM(o.amount) AS revenue"
|
|
22
|
+
" FROM orders o JOIN customers c ON o.customer_id = c.customer_id"
|
|
23
|
+
" WHERE o.amount > 0"
|
|
24
|
+
" GROUP BY c.name ORDER BY revenue DESC"
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
extract_task = PythonOperator(task_id="extract", python_callable=extract)
|
|
28
|
+
|
|
29
|
+
@task
|
|
30
|
+
def load(rows):
|
|
31
|
+
assert rows, "нечего грузить: extract вернул пусто"
|
|
32
|
+
return [f"{r['customer']}: {r['revenue']}" for r in rows]
|
|
33
|
+
|
|
34
|
+
load(extract_task.output)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Пример Среза 8: поведенческий аудит миграции Airflow 2.10 → 3.x.
|
|
2
|
+
|
|
3
|
+
``uses_execution_date`` — эталон из G2 (demand_validation_report): шаблон с
|
|
4
|
+
легаси-ключом контекста. В 2.10 он рендерится в дату (задача ok), в 3.x ключ
|
|
5
|
+
удалён из контекста (задача падает) — именно это находит ``audit``.
|
|
6
|
+
``uses_tomorrow_ds`` — помягче: в обеих версиях задача ok, но значение разное
|
|
7
|
+
(дата против пустой строки) — находка уровня ``value``. ``plain`` — чистая
|
|
8
|
+
задача, находок не даёт (контроль).
|
|
9
|
+
|
|
10
|
+
Запуск из клона DagProbe:
|
|
11
|
+
|
|
12
|
+
uv run dagprobe audit 2to3 --dags-folder examples/dags --dag-id migration_legacy
|
|
13
|
+
|
|
14
|
+
Exit 1 = есть расхождения (см. JSON: ``--format json``), 0 = поведение совпадает.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from airflow.providers.standard.operators.python import PythonOperator
|
|
18
|
+
from airflow.sdk import DAG
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def fail_on_empty(value):
|
|
22
|
+
if not value:
|
|
23
|
+
raise ValueError("легаси-ключ контекста не отрендерился (удалён в Airflow 3?)")
|
|
24
|
+
return value
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def echo(value):
|
|
28
|
+
return value
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
with DAG("migration_legacy", schedule=None, start_date=None, catchup=False) as dag:
|
|
32
|
+
PythonOperator(
|
|
33
|
+
task_id="uses_execution_date",
|
|
34
|
+
python_callable=fail_on_empty,
|
|
35
|
+
op_kwargs={"value": "{{ execution_date }}"},
|
|
36
|
+
)
|
|
37
|
+
PythonOperator(
|
|
38
|
+
task_id="uses_tomorrow_ds",
|
|
39
|
+
python_callable=echo,
|
|
40
|
+
op_kwargs={"value": "{{ tomorrow_ds }}"},
|
|
41
|
+
)
|
|
42
|
+
PythonOperator(
|
|
43
|
+
task_id="plain",
|
|
44
|
+
python_callable=echo,
|
|
45
|
+
op_kwargs={"value": "{{ ds }}"},
|
|
46
|
+
)
|