canvod-airflow 1.0.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.
- canvod_airflow-1.0.0/LICENSE +203 -0
- canvod_airflow-1.0.0/NOTICE +14 -0
- canvod_airflow-1.0.0/PKG-INFO +112 -0
- canvod_airflow-1.0.0/README.md +82 -0
- canvod_airflow-1.0.0/pyproject.toml +55 -0
- canvod_airflow-1.0.0/pyproject.toml.orig +51 -0
- canvod_airflow-1.0.0/src/canvod/airflow/__init__.py +16 -0
- canvod_airflow-1.0.0/src/canvod/airflow/backfill.py +152 -0
- canvod_airflow-1.0.0/src/canvod/airflow/daily_processing.py +234 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Nicolas François Bader
|
|
190
|
+
Climate and Environmental Remote Sensing Research Unit (CLIMERS)
|
|
191
|
+
Department of Geodesy and Geoinformation, TU Wien
|
|
192
|
+
|
|
193
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
194
|
+
you may not use this file except in compliance with the License.
|
|
195
|
+
You may obtain a copy of the License at
|
|
196
|
+
|
|
197
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
198
|
+
|
|
199
|
+
Unless required by applicable law or agreed to in writing, software
|
|
200
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
201
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
202
|
+
See the License for the specific language governing permissions and
|
|
203
|
+
limitations under the License.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
canvodpy-extensions
|
|
2
|
+
Copyright 2026 Nicolas François Bader, TU Wien
|
|
3
|
+
|
|
4
|
+
This product includes software developed at the
|
|
5
|
+
Climate and Environmental Remote Sensing Research Unit (CLIMERS),
|
|
6
|
+
Department of Geodesy and Geoinformation, TU Wien.
|
|
7
|
+
|
|
8
|
+
This product includes contributions from the canVODpy community.
|
|
9
|
+
Individual contributors are listed in the CONTRIBUTORS.md file and
|
|
10
|
+
recorded in the Git revision history of the repository:
|
|
11
|
+
https://github.com/TUW-GEO/canvodpy-extensions
|
|
12
|
+
|
|
13
|
+
canvodpy-extensions is an optional extension monorepo for
|
|
14
|
+
https://github.com/TUW-GEO/canvodpy.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: canvod-airflow
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Airflow DAG definitions for canvodpy GNSS-T pipelines
|
|
5
|
+
Keywords: GNSS,GNSS-T,Airflow,workflow,VOD,remote sensing
|
|
6
|
+
Author: Nicolas François Bader
|
|
7
|
+
Author-email: Nicolas François Bader <support@canvodpy.eu>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: NOTICE
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: POSIX
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering
|
|
18
|
+
Requires-Dist: structlog>=23.0
|
|
19
|
+
Requires-Dist: canvodpy>=1.0.0
|
|
20
|
+
Requires-Dist: canvod-config>=1.0.0
|
|
21
|
+
Requires-Dist: apache-airflow>=3.3.2
|
|
22
|
+
Maintainer: Climate and Environmental Remote Sensing (CLIMERS)
|
|
23
|
+
Maintainer-email: Climate and Environmental Remote Sensing (CLIMERS) <support@canvodpy.eu>
|
|
24
|
+
Requires-Python: >=3.14
|
|
25
|
+
Project-URL: Homepage, https://github.com/TUW-GEO/canvodpy-extensions
|
|
26
|
+
Project-URL: Documentation, https://extensions.canvodpy.eu/packages/airflow/overview/
|
|
27
|
+
Project-URL: Repository, https://github.com/TUW-GEO/canvodpy-extensions
|
|
28
|
+
Project-URL: Issues, https://github.com/TUW-GEO/canvodpy-extensions/issues
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
<p align="center">
|
|
32
|
+
<picture>
|
|
33
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/TUW-GEO/canvodpy/main/docs/assets/logo/canvodpy_logo_dark_mode.svg">
|
|
34
|
+
<img alt="canVODpy" src="https://raw.githubusercontent.com/TUW-GEO/canvodpy/main/docs/assets/logo/canvodpy_logo_bright_mode.svg" width="260">
|
|
35
|
+
</picture>
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+
# canvod-airflow
|
|
39
|
+
|
|
40
|
+
[](https://pypi.org/project/canvod-airflow/)
|
|
41
|
+
[](https://www.python.org/)
|
|
42
|
+
[](https://github.com/TUW-GEO/canvodpy-extensions/blob/main/LICENSE)
|
|
43
|
+
[](https://doi.org/10.5281/zenodo.21359005)
|
|
44
|
+
|
|
45
|
+
**Apache Airflow DAGs that run the canVODpy pipeline every day.** `canvod-airflow` is one of the
|
|
46
|
+
[canVODpy extensions](https://extensions.canvodpy.eu/), optional packages
|
|
47
|
+
for [canVODpy](https://canvodpy.eu/), an open Python ecosystem for
|
|
48
|
+
GNSS-Transmissometry (GNSS-T) canopy VOD retrievals.
|
|
49
|
+
|
|
50
|
+
## What it does
|
|
51
|
+
|
|
52
|
+
`canvod-airflow` wraps the task functions of `canvodpy run`
|
|
53
|
+
(`canvodpy.workflows.tasks`) into Airflow TaskFlow DAGs. No pipeline logic
|
|
54
|
+
lives here: every task calls `canvodpy.workflows.tasks`, which has no
|
|
55
|
+
Airflow dependency of its own.
|
|
56
|
+
|
|
57
|
+
| DAG | Trigger | Tasks |
|
|
58
|
+
|---|---|---|
|
|
59
|
+
| `canvod_{site}` | `@daily` | `t_validate_dirs → t_wait_for_data (→ t_wait_for_sp3) → t_process_day → t_validate_ingest → t_calculate_vod` |
|
|
60
|
+
| `canvod_backfill` | manual (params `site`, `start_date`, `end_date`) | `t_resolve_dates → t_process_day`, one mapped task per day |
|
|
61
|
+
|
|
62
|
+
There is one daily DAG per site of the canvodpy settings, created when
|
|
63
|
+
Airflow parses the DAG file. `t_wait_for_sp3` runs only when the settings use
|
|
64
|
+
agency orbit and clock products instead of broadcast ephemerides.
|
|
65
|
+
|
|
66
|
+
## Install
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
uv add canvod-airflow
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
This installs `apache-airflow>=3.3.2` too, the first release without
|
|
73
|
+
known vulnerabilities; an installed Airflow older than that is upgraded. canVODpy requires Python 3.14.
|
|
74
|
+
Airflow runs on POSIX systems (Linux, macOS); on Windows, run it in WSL2
|
|
75
|
+
([Airflow's prerequisites](https://airflow.apache.org/docs/apache-airflow/stable/installation/prerequisites.html)).
|
|
76
|
+
|
|
77
|
+
## Deployment
|
|
78
|
+
|
|
79
|
+
Point Airflow's `dags_folder` at a module that imports both DAG modules
|
|
80
|
+
(Airflow only parses files that contain the words "airflow" and "dag"):
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
# <dags_folder>/canvod_dags.py
|
|
84
|
+
from canvod.airflow.daily_processing import * # noqa: F403 (airflow dag)
|
|
85
|
+
from canvod.airflow.backfill import * # noqa: F403
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Create the `canvod_store_write` pool with one slot. Every task that writes
|
|
89
|
+
to a store (`t_process_day`, `t_calculate_vod`) runs in it, so commits to an
|
|
90
|
+
Icechunk store happen one at a time across all DAGs and backfill runs:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
airflow pools set canvod_store_write 1 "Serialize Icechunk commits"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Documentation
|
|
97
|
+
|
|
98
|
+
[airflow documentation](https://extensions.canvodpy.eu/packages/airflow/overview/)
|
|
99
|
+
and the [canVODpy documentation](https://canvodpy.eu/).
|
|
100
|
+
|
|
101
|
+
## Citation
|
|
102
|
+
|
|
103
|
+
Please cite the canVODpy extensions with their Zenodo DOI,
|
|
104
|
+
[10.5281/zenodo.21359005](https://doi.org/10.5281/zenodo.21359005), and
|
|
105
|
+
canVODpy with
|
|
106
|
+
[10.5281/zenodo.18496233](https://doi.org/10.5281/zenodo.18496233).
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
Apache License 2.0. See
|
|
111
|
+
[LICENSE](https://github.com/TUW-GEO/canvodpy-extensions/blob/main/LICENSE)
|
|
112
|
+
and [NOTICE](https://github.com/TUW-GEO/canvodpy-extensions/blob/main/NOTICE).
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/TUW-GEO/canvodpy/main/docs/assets/logo/canvodpy_logo_dark_mode.svg">
|
|
4
|
+
<img alt="canVODpy" src="https://raw.githubusercontent.com/TUW-GEO/canvodpy/main/docs/assets/logo/canvodpy_logo_bright_mode.svg" width="260">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
# canvod-airflow
|
|
9
|
+
|
|
10
|
+
[](https://pypi.org/project/canvod-airflow/)
|
|
11
|
+
[](https://www.python.org/)
|
|
12
|
+
[](https://github.com/TUW-GEO/canvodpy-extensions/blob/main/LICENSE)
|
|
13
|
+
[](https://doi.org/10.5281/zenodo.21359005)
|
|
14
|
+
|
|
15
|
+
**Apache Airflow DAGs that run the canVODpy pipeline every day.** `canvod-airflow` is one of the
|
|
16
|
+
[canVODpy extensions](https://extensions.canvodpy.eu/), optional packages
|
|
17
|
+
for [canVODpy](https://canvodpy.eu/), an open Python ecosystem for
|
|
18
|
+
GNSS-Transmissometry (GNSS-T) canopy VOD retrievals.
|
|
19
|
+
|
|
20
|
+
## What it does
|
|
21
|
+
|
|
22
|
+
`canvod-airflow` wraps the task functions of `canvodpy run`
|
|
23
|
+
(`canvodpy.workflows.tasks`) into Airflow TaskFlow DAGs. No pipeline logic
|
|
24
|
+
lives here: every task calls `canvodpy.workflows.tasks`, which has no
|
|
25
|
+
Airflow dependency of its own.
|
|
26
|
+
|
|
27
|
+
| DAG | Trigger | Tasks |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| `canvod_{site}` | `@daily` | `t_validate_dirs → t_wait_for_data (→ t_wait_for_sp3) → t_process_day → t_validate_ingest → t_calculate_vod` |
|
|
30
|
+
| `canvod_backfill` | manual (params `site`, `start_date`, `end_date`) | `t_resolve_dates → t_process_day`, one mapped task per day |
|
|
31
|
+
|
|
32
|
+
There is one daily DAG per site of the canvodpy settings, created when
|
|
33
|
+
Airflow parses the DAG file. `t_wait_for_sp3` runs only when the settings use
|
|
34
|
+
agency orbit and clock products instead of broadcast ephemerides.
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
uv add canvod-airflow
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This installs `apache-airflow>=3.3.2` too, the first release without
|
|
43
|
+
known vulnerabilities; an installed Airflow older than that is upgraded. canVODpy requires Python 3.14.
|
|
44
|
+
Airflow runs on POSIX systems (Linux, macOS); on Windows, run it in WSL2
|
|
45
|
+
([Airflow's prerequisites](https://airflow.apache.org/docs/apache-airflow/stable/installation/prerequisites.html)).
|
|
46
|
+
|
|
47
|
+
## Deployment
|
|
48
|
+
|
|
49
|
+
Point Airflow's `dags_folder` at a module that imports both DAG modules
|
|
50
|
+
(Airflow only parses files that contain the words "airflow" and "dag"):
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
# <dags_folder>/canvod_dags.py
|
|
54
|
+
from canvod.airflow.daily_processing import * # noqa: F403 (airflow dag)
|
|
55
|
+
from canvod.airflow.backfill import * # noqa: F403
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Create the `canvod_store_write` pool with one slot. Every task that writes
|
|
59
|
+
to a store (`t_process_day`, `t_calculate_vod`) runs in it, so commits to an
|
|
60
|
+
Icechunk store happen one at a time across all DAGs and backfill runs:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
airflow pools set canvod_store_write 1 "Serialize Icechunk commits"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Documentation
|
|
67
|
+
|
|
68
|
+
[airflow documentation](https://extensions.canvodpy.eu/packages/airflow/overview/)
|
|
69
|
+
and the [canVODpy documentation](https://canvodpy.eu/).
|
|
70
|
+
|
|
71
|
+
## Citation
|
|
72
|
+
|
|
73
|
+
Please cite the canVODpy extensions with their Zenodo DOI,
|
|
74
|
+
[10.5281/zenodo.21359005](https://doi.org/10.5281/zenodo.21359005), and
|
|
75
|
+
canVODpy with
|
|
76
|
+
[10.5281/zenodo.18496233](https://doi.org/10.5281/zenodo.18496233).
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
Apache License 2.0. See
|
|
81
|
+
[LICENSE](https://github.com/TUW-GEO/canvodpy-extensions/blob/main/LICENSE)
|
|
82
|
+
and [NOTICE](https://github.com/TUW-GEO/canvodpy-extensions/blob/main/NOTICE).
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "canvod-airflow"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "Airflow DAG definitions for canvodpy GNSS-T pipelines"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.14"
|
|
7
|
+
license = "Apache-2.0"
|
|
8
|
+
license-files = [
|
|
9
|
+
"LICENSE",
|
|
10
|
+
"NOTICE",
|
|
11
|
+
]
|
|
12
|
+
keywords = [
|
|
13
|
+
"GNSS",
|
|
14
|
+
"GNSS-T",
|
|
15
|
+
"Airflow",
|
|
16
|
+
"workflow",
|
|
17
|
+
"VOD",
|
|
18
|
+
"remote sensing",
|
|
19
|
+
]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Development Status :: 5 - Production/Stable",
|
|
22
|
+
"Intended Audience :: Science/Research",
|
|
23
|
+
"Operating System :: POSIX",
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
26
|
+
"Programming Language :: Python :: 3.14",
|
|
27
|
+
"Topic :: Scientific/Engineering",
|
|
28
|
+
]
|
|
29
|
+
dependencies = [
|
|
30
|
+
"structlog>=23.0",
|
|
31
|
+
"canvodpy>=1.0.0",
|
|
32
|
+
"canvod-config>=1.0.0",
|
|
33
|
+
"apache-airflow>=3.3.2",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[[project.authors]]
|
|
37
|
+
name = "Nicolas François Bader"
|
|
38
|
+
email = "support@canvodpy.eu"
|
|
39
|
+
|
|
40
|
+
[[project.maintainers]]
|
|
41
|
+
name = "Climate and Environmental Remote Sensing (CLIMERS)"
|
|
42
|
+
email = "support@canvodpy.eu"
|
|
43
|
+
|
|
44
|
+
[project.urls]
|
|
45
|
+
Homepage = "https://github.com/TUW-GEO/canvodpy-extensions"
|
|
46
|
+
Documentation = "https://extensions.canvodpy.eu/packages/airflow/overview/"
|
|
47
|
+
Repository = "https://github.com/TUW-GEO/canvodpy-extensions"
|
|
48
|
+
Issues = "https://github.com/TUW-GEO/canvodpy-extensions/issues"
|
|
49
|
+
|
|
50
|
+
[build-system]
|
|
51
|
+
requires = ["uv_build>=0.13.0,<0.14.0"]
|
|
52
|
+
build-backend = "uv_build"
|
|
53
|
+
|
|
54
|
+
[tool.uv.build-backend]
|
|
55
|
+
module-name = "canvod.airflow"
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "canvod-airflow"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "Airflow DAG definitions for canvodpy GNSS-T pipelines"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.14"
|
|
7
|
+
authors = [
|
|
8
|
+
{name = "Nicolas François Bader", email = "support@canvodpy.eu"},
|
|
9
|
+
]
|
|
10
|
+
maintainers = [
|
|
11
|
+
{name = "Climate and Environmental Remote Sensing (CLIMERS)", email = "support@canvodpy.eu"},
|
|
12
|
+
]
|
|
13
|
+
license = "Apache-2.0"
|
|
14
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
15
|
+
keywords = [
|
|
16
|
+
"GNSS",
|
|
17
|
+
"GNSS-T",
|
|
18
|
+
"Airflow",
|
|
19
|
+
"workflow",
|
|
20
|
+
"VOD",
|
|
21
|
+
"remote sensing",
|
|
22
|
+
]
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 5 - Production/Stable",
|
|
25
|
+
"Intended Audience :: Science/Research",
|
|
26
|
+
"Operating System :: POSIX",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
29
|
+
"Programming Language :: Python :: 3.14",
|
|
30
|
+
"Topic :: Scientific/Engineering",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
dependencies = [
|
|
34
|
+
"structlog>=23.0",
|
|
35
|
+
"canvodpy>=1.0.0",
|
|
36
|
+
"canvod-config>=1.0.0",
|
|
37
|
+
"apache-airflow>=3.3.2",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[project.urls]
|
|
41
|
+
Homepage = "https://github.com/TUW-GEO/canvodpy-extensions"
|
|
42
|
+
Documentation = "https://extensions.canvodpy.eu/packages/airflow/overview/"
|
|
43
|
+
Repository = "https://github.com/TUW-GEO/canvodpy-extensions"
|
|
44
|
+
Issues = "https://github.com/TUW-GEO/canvodpy-extensions/issues"
|
|
45
|
+
|
|
46
|
+
[build-system]
|
|
47
|
+
requires = ["uv_build>=0.13.0,<0.14.0"]
|
|
48
|
+
build-backend = "uv_build"
|
|
49
|
+
|
|
50
|
+
[tool.uv.build-backend]
|
|
51
|
+
module-name = "canvod.airflow"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""canvod-airflow: Airflow DAG definitions for canvodpy GNSS-T pipelines.
|
|
2
|
+
|
|
3
|
+
See ``daily_processing.py`` (one daily DAG per site) and
|
|
4
|
+
``backfill.py`` (manual date-range backfill DAG). No pipeline logic lives
|
|
5
|
+
here; every task wraps a stateless function from ``canvodpy.workflows.tasks``.
|
|
6
|
+
|
|
7
|
+
``daily_processing.py`` and ``backfill.py`` import ``airflow`` at module
|
|
8
|
+
level (``apache-airflow`` is a dependency of this package), since these
|
|
9
|
+
modules only ever run inside an Airflow scheduler process. ``canvodpy``-side config/task imports are deferred
|
|
10
|
+
inside each DAG-construction function instead, so a missing or
|
|
11
|
+
misconfigured ``canvodpy`` config doesn't crash DAG parsing.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from importlib.metadata import version
|
|
15
|
+
|
|
16
|
+
__version__ = version("canvod-airflow")
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"""Manual backfill DAG for reprocessing historical GNSS-T data.
|
|
2
|
+
|
|
3
|
+
Triggered manually with parameters. Each date in the range becomes an
|
|
4
|
+
independent Airflow task instance via dynamic task mapping.
|
|
5
|
+
A failure on one date retries that date only — the rest of the batch
|
|
6
|
+
continues unaffected.
|
|
7
|
+
|
|
8
|
+
**Concurrency safety** — Icechunk stores require serialised commits on a
|
|
9
|
+
branch. ``max_active_tis_per_dagrun=1`` enforces this within a single
|
|
10
|
+
backfill run. The ``canvod_store_write`` pool (create it with one slot in
|
|
11
|
+
the Airflow UI) provides the same guarantee across simultaneous backfill
|
|
12
|
+
runs and the daily DAGs::
|
|
13
|
+
|
|
14
|
+
airflow pools set canvod_store_write 1 "Serialise Icechunk commits"
|
|
15
|
+
|
|
16
|
+
All three parameters are required: the site and the first and last day,
|
|
17
|
+
both ``YYYYDDD``. Usage (Airflow UI or CLI)::
|
|
18
|
+
|
|
19
|
+
airflow dags trigger canvod_backfill --conf '{
|
|
20
|
+
"site": "fangorn",
|
|
21
|
+
"start_date": "2025001",
|
|
22
|
+
"end_date": "2025010"
|
|
23
|
+
}'
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
from datetime import datetime, timedelta
|
|
29
|
+
|
|
30
|
+
import structlog
|
|
31
|
+
|
|
32
|
+
from airflow.sdk import Param, dag, task # type: ignore[unresolved-import]
|
|
33
|
+
|
|
34
|
+
logger = structlog.get_logger(__name__)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _task_failure_callback(context):
|
|
38
|
+
"""Log structured failure info."""
|
|
39
|
+
ti = context["task_instance"]
|
|
40
|
+
logger.error(
|
|
41
|
+
"BACKFILL TASK FAILED | dag=%s task=%s map_index=%s error=%s",
|
|
42
|
+
ti.dag_id,
|
|
43
|
+
ti.task_id,
|
|
44
|
+
ti.map_index,
|
|
45
|
+
context.get("exception", "unknown"),
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@dag(
|
|
50
|
+
dag_id="canvod_backfill",
|
|
51
|
+
schedule=None, # manual trigger only
|
|
52
|
+
start_date=datetime(2025, 1, 1),
|
|
53
|
+
catchup=False,
|
|
54
|
+
max_active_runs=3, # allow a few concurrent backfill runs (pool controls writes)
|
|
55
|
+
default_args={
|
|
56
|
+
"owner": "canvod",
|
|
57
|
+
"retries": 2,
|
|
58
|
+
"retry_delay": timedelta(minutes=10),
|
|
59
|
+
"retry_exponential_backoff": True,
|
|
60
|
+
"max_retry_delay": timedelta(hours=1),
|
|
61
|
+
"on_failure_callback": _task_failure_callback,
|
|
62
|
+
},
|
|
63
|
+
tags=["canvod", "gnss", "backfill"],
|
|
64
|
+
params={
|
|
65
|
+
# No defaults: a trigger without site and days fails instead of
|
|
66
|
+
# processing a range nobody asked for.
|
|
67
|
+
"site": Param(type="string", description="Site name in the canvodpy settings"),
|
|
68
|
+
"start_date": Param(
|
|
69
|
+
type="string",
|
|
70
|
+
pattern=r"^\d{7}$",
|
|
71
|
+
description="First day, YYYYDDD (e.g. 2025001)",
|
|
72
|
+
),
|
|
73
|
+
"end_date": Param(
|
|
74
|
+
type="string",
|
|
75
|
+
pattern=r"^\d{7}$",
|
|
76
|
+
description="Last day, YYYYDDD (e.g. 2025010), inclusive",
|
|
77
|
+
),
|
|
78
|
+
},
|
|
79
|
+
doc_md=__doc__,
|
|
80
|
+
)
|
|
81
|
+
def canvod_backfill():
|
|
82
|
+
"""Process a date range for a single site."""
|
|
83
|
+
|
|
84
|
+
@task
|
|
85
|
+
def t_resolve_dates(**context) -> list[str]:
|
|
86
|
+
"""Expand start_date..end_date into a list of YYYYDDD strings."""
|
|
87
|
+
import datetime as dt
|
|
88
|
+
|
|
89
|
+
from canvod.utils.tools import YYYYDOY
|
|
90
|
+
|
|
91
|
+
params = context["params"]
|
|
92
|
+
start = YYYYDOY.from_str(params["start_date"])
|
|
93
|
+
end = YYYYDOY.from_str(params["end_date"])
|
|
94
|
+
|
|
95
|
+
if start.date is None:
|
|
96
|
+
raise ValueError(f"Invalid start_date: {params['start_date']!r}")
|
|
97
|
+
if end.date is None:
|
|
98
|
+
raise ValueError(f"Invalid end_date: {params['end_date']!r}")
|
|
99
|
+
|
|
100
|
+
dates: list[str] = []
|
|
101
|
+
current = start.date
|
|
102
|
+
while current <= end.date:
|
|
103
|
+
doy = (current - dt.date(current.year, 1, 1)).days + 1
|
|
104
|
+
dates.append(f"{current.year}{doy:03d}")
|
|
105
|
+
current += dt.timedelta(days=1)
|
|
106
|
+
|
|
107
|
+
logger.info(
|
|
108
|
+
"backfill: %s — %d days (%s → %s)",
|
|
109
|
+
params["site"],
|
|
110
|
+
len(dates),
|
|
111
|
+
params["start_date"],
|
|
112
|
+
params["end_date"],
|
|
113
|
+
)
|
|
114
|
+
return dates
|
|
115
|
+
|
|
116
|
+
@task(
|
|
117
|
+
execution_timeout=timedelta(hours=6),
|
|
118
|
+
# Serialise commits within this DAG run. One date at a time prevents
|
|
119
|
+
# concurrent Icechunk writes to the same branch.
|
|
120
|
+
max_active_tis_per_dagrun=1,
|
|
121
|
+
# Optional pool for cross-run serialisation (create with slot=1 in UI).
|
|
122
|
+
pool="canvod_store_write",
|
|
123
|
+
pool_slots=1,
|
|
124
|
+
)
|
|
125
|
+
def t_process_day(yyyydoy: str, **context) -> dict:
|
|
126
|
+
"""Process the full ingest + VOD pipeline for a single date.
|
|
127
|
+
|
|
128
|
+
Idempotent: already-processed dates are skipped by the store's
|
|
129
|
+
three-layer dedup (hash match → temporal overlap → intra-batch).
|
|
130
|
+
"""
|
|
131
|
+
from canvodpy.workflows.tasks import (
|
|
132
|
+
calculate_vod,
|
|
133
|
+
check_day,
|
|
134
|
+
process_day,
|
|
135
|
+
validate_ingest,
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
site = context["params"]["site"]
|
|
139
|
+
check_day(site, yyyydoy)
|
|
140
|
+
process_day(site, yyyydoy)
|
|
141
|
+
validate_ingest(site, yyyydoy)
|
|
142
|
+
calculate_vod(site, yyyydoy)
|
|
143
|
+
|
|
144
|
+
logger.info("backfill: %s %s — ok", site, yyyydoy)
|
|
145
|
+
return {"site": site, "yyyydoy": yyyydoy, "status": "ok"}
|
|
146
|
+
|
|
147
|
+
dates = t_resolve_dates()
|
|
148
|
+
t_process_day.expand(yyyydoy=dates)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
# Instantiate
|
|
152
|
+
canvod_backfill()
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"""Airflow DAG for GNSS-Transmissometry daily processing.
|
|
2
|
+
|
|
3
|
+
One DAG per configured site (``canvod_{site}``)::
|
|
4
|
+
|
|
5
|
+
validate_dirs → wait_for_data (→ wait_for_sp3)
|
|
6
|
+
→ process_day → validate_ingest → calculate_vod
|
|
7
|
+
|
|
8
|
+
``process_day`` and ``calculate_vod`` run the code of ``canvodpy run``
|
|
9
|
+
(``canvodpy.workflows.tasks``): each receiver is read in the
|
|
10
|
+
``reader_format`` of its site configuration, with the ephemeris source of
|
|
11
|
+
``processing.params.ephemeris_source``. With agency ephemerides the DAG
|
|
12
|
+
also waits for the SP3/CLK products (12-18 days for final products).
|
|
13
|
+
|
|
14
|
+
Requirements
|
|
15
|
+
------------
|
|
16
|
+
* ``canvodpy`` installed in the Airflow worker environment.
|
|
17
|
+
* Apache Airflow >= 3.0 (a dependency of canvod-airflow).
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
from datetime import datetime, timedelta
|
|
23
|
+
|
|
24
|
+
import structlog
|
|
25
|
+
|
|
26
|
+
from airflow.sdk import dag, task # type: ignore[unresolved-import]
|
|
27
|
+
|
|
28
|
+
logger = structlog.get_logger(__name__)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# ---------------------------------------------------------------------------
|
|
32
|
+
# Configuration helpers (parse-time safe)
|
|
33
|
+
# ---------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _get_configured_sites() -> dict:
|
|
37
|
+
"""Return {site_name: site_cfg} from canvodpy config.
|
|
38
|
+
|
|
39
|
+
Imports are deferred so that the DAG file can be parsed by the Airflow
|
|
40
|
+
scheduler even when ``canvodpy`` is unavailable (parse-time safety).
|
|
41
|
+
"""
|
|
42
|
+
try:
|
|
43
|
+
from canvod.config import load_config
|
|
44
|
+
|
|
45
|
+
return dict(load_config().sites.sites)
|
|
46
|
+
except Exception:
|
|
47
|
+
logger.warning("Could not load canvodpy config — no DAGs generated")
|
|
48
|
+
return {}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _uses_agency_ephemeris() -> bool:
|
|
52
|
+
"""Whether runs use agency SP3/CLK products (``ephemeris_source``)."""
|
|
53
|
+
from canvod.config import load_config
|
|
54
|
+
|
|
55
|
+
return load_config().processing.params.ephemeris_source != "broadcast"
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _ds_to_yyyydoy(ds: str) -> str:
|
|
59
|
+
"""Convert Airflow ``ds`` (``YYYY-MM-DD``) to ``YYYYDDD``."""
|
|
60
|
+
import datetime as dt
|
|
61
|
+
|
|
62
|
+
date = dt.date.fromisoformat(ds)
|
|
63
|
+
doy = (date - dt.date(date.year, 1, 1)).days + 1
|
|
64
|
+
return f"{date.year}{doy:03d}"
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# ---------------------------------------------------------------------------
|
|
68
|
+
# Failure callback
|
|
69
|
+
# ---------------------------------------------------------------------------
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _task_failure_callback(context):
|
|
73
|
+
"""Log structured failure info. Future: Slack/email hook."""
|
|
74
|
+
ti = context["task_instance"]
|
|
75
|
+
logger.error(
|
|
76
|
+
"TASK FAILED | dag=%s task=%s date=%s error=%s log_url=%s",
|
|
77
|
+
ti.dag_id,
|
|
78
|
+
ti.task_id,
|
|
79
|
+
context.get("ds", "?"),
|
|
80
|
+
context.get("exception", "unknown"),
|
|
81
|
+
ti.log_url,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
# ---------------------------------------------------------------------------
|
|
86
|
+
# Shared default_args
|
|
87
|
+
# ---------------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
_DEFAULT_ARGS = {
|
|
90
|
+
"owner": "canvod",
|
|
91
|
+
"retries": 5,
|
|
92
|
+
"retry_delay": timedelta(minutes=30),
|
|
93
|
+
"retry_exponential_backoff": True,
|
|
94
|
+
"max_retry_delay": timedelta(hours=12),
|
|
95
|
+
"execution_timeout": timedelta(hours=2),
|
|
96
|
+
"on_failure_callback": _task_failure_callback,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
_START_DATE = datetime(2025, 1, 1)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
# ---------------------------------------------------------------------------
|
|
103
|
+
# Daily DAG
|
|
104
|
+
# ---------------------------------------------------------------------------
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def create_daily_dag(site_name: str, agency_ephemeris: bool):
|
|
108
|
+
"""Create the daily processing DAG for *site_name*.
|
|
109
|
+
|
|
110
|
+
Parameters
|
|
111
|
+
----------
|
|
112
|
+
site_name : str
|
|
113
|
+
Site name in the canvodpy configuration.
|
|
114
|
+
agency_ephemeris : bool
|
|
115
|
+
Whether runs use agency SP3/CLK products; the DAG then waits for
|
|
116
|
+
them before processing.
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
@dag(
|
|
120
|
+
dag_id=f"canvod_{site_name}",
|
|
121
|
+
schedule="@daily",
|
|
122
|
+
start_date=_START_DATE,
|
|
123
|
+
catchup=False,
|
|
124
|
+
max_active_runs=1,
|
|
125
|
+
default_args=_DEFAULT_ARGS,
|
|
126
|
+
tags=["canvod", "gnss", site_name],
|
|
127
|
+
doc_md=__doc__,
|
|
128
|
+
)
|
|
129
|
+
def daily_dag():
|
|
130
|
+
@task(retries=0)
|
|
131
|
+
def t_validate_dirs(ds: str = "{{ ds }}") -> dict:
|
|
132
|
+
from canvodpy.workflows.tasks import validate_data_dirs
|
|
133
|
+
|
|
134
|
+
return validate_data_dirs(site_name)
|
|
135
|
+
|
|
136
|
+
@task.sensor(
|
|
137
|
+
poke_interval=3600,
|
|
138
|
+
timeout=3600 * 24 * 21,
|
|
139
|
+
mode="reschedule",
|
|
140
|
+
)
|
|
141
|
+
def t_wait_for_data(
|
|
142
|
+
valid_info: dict,
|
|
143
|
+
ds: str = "{{ ds }}",
|
|
144
|
+
):
|
|
145
|
+
"""Wait until every receiver has files for the day (up to 21 days)."""
|
|
146
|
+
from canvodpy.workflows.tasks import check_day
|
|
147
|
+
|
|
148
|
+
from airflow.sdk import (
|
|
149
|
+
PokeReturnValue, # type: ignore[unresolved-import]
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
_ = valid_info
|
|
153
|
+
try:
|
|
154
|
+
result = check_day(site_name, _ds_to_yyyydoy(ds))
|
|
155
|
+
except RuntimeError:
|
|
156
|
+
return PokeReturnValue(is_done=False)
|
|
157
|
+
return PokeReturnValue(is_done=True, xcom_value=result)
|
|
158
|
+
|
|
159
|
+
@task.sensor(
|
|
160
|
+
poke_interval=3600 * 6,
|
|
161
|
+
timeout=3600 * 24 * 21,
|
|
162
|
+
mode="reschedule",
|
|
163
|
+
)
|
|
164
|
+
def t_wait_for_sp3(
|
|
165
|
+
data_info: dict,
|
|
166
|
+
ds: str = "{{ ds }}",
|
|
167
|
+
):
|
|
168
|
+
"""Wait for SP3/CLK products (date-age heuristic, up to 21 days)."""
|
|
169
|
+
from canvodpy.workflows.tasks import check_sp3_availability
|
|
170
|
+
|
|
171
|
+
_ = data_info
|
|
172
|
+
return check_sp3_availability(ds)
|
|
173
|
+
|
|
174
|
+
@task(
|
|
175
|
+
execution_timeout=timedelta(hours=4),
|
|
176
|
+
pool="canvod_store_write",
|
|
177
|
+
pool_slots=1,
|
|
178
|
+
)
|
|
179
|
+
def t_process_day(
|
|
180
|
+
ready_info: dict,
|
|
181
|
+
ds: str = "{{ ds }}",
|
|
182
|
+
) -> dict:
|
|
183
|
+
from canvodpy.workflows.tasks import process_day
|
|
184
|
+
|
|
185
|
+
_ = ready_info
|
|
186
|
+
return process_day(site_name, _ds_to_yyyydoy(ds))
|
|
187
|
+
|
|
188
|
+
@task(execution_timeout=timedelta(hours=1))
|
|
189
|
+
def t_validate_ingest(
|
|
190
|
+
process_info: dict,
|
|
191
|
+
ds: str = "{{ ds }}",
|
|
192
|
+
) -> dict:
|
|
193
|
+
from canvodpy.workflows.tasks import validate_ingest
|
|
194
|
+
|
|
195
|
+
_ = process_info
|
|
196
|
+
return validate_ingest(site_name, _ds_to_yyyydoy(ds))
|
|
197
|
+
|
|
198
|
+
@task(
|
|
199
|
+
execution_timeout=timedelta(hours=1),
|
|
200
|
+
pool="canvod_store_write",
|
|
201
|
+
pool_slots=1,
|
|
202
|
+
)
|
|
203
|
+
def t_calculate_vod(
|
|
204
|
+
ingest_valid: dict,
|
|
205
|
+
ds: str = "{{ ds }}",
|
|
206
|
+
) -> dict:
|
|
207
|
+
from canvodpy.workflows.tasks import calculate_vod
|
|
208
|
+
|
|
209
|
+
_ = ingest_valid
|
|
210
|
+
return calculate_vod(site_name, _ds_to_yyyydoy(ds))
|
|
211
|
+
|
|
212
|
+
# Calling a task in the DAG body passes an XComArg, which Airflow
|
|
213
|
+
# resolves to the upstream task's return value at run time. The
|
|
214
|
+
# airflow.sdk type hints expect the resolved type, hence the ignores.
|
|
215
|
+
valid_info = t_validate_dirs()
|
|
216
|
+
ready_info = t_wait_for_data(valid_info=valid_info) # ty: ignore[invalid-argument-type]
|
|
217
|
+
if agency_ephemeris:
|
|
218
|
+
ready_info = t_wait_for_sp3(data_info=ready_info) # ty: ignore[invalid-argument-type]
|
|
219
|
+
process_info = t_process_day(ready_info=ready_info) # ty: ignore[invalid-argument-type]
|
|
220
|
+
ingest_valid = t_validate_ingest(process_info=process_info) # ty: ignore[invalid-argument-type]
|
|
221
|
+
t_calculate_vod(ingest_valid=ingest_valid) # ty: ignore[invalid-argument-type]
|
|
222
|
+
|
|
223
|
+
return daily_dag()
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
# ---------------------------------------------------------------------------
|
|
227
|
+
# Dynamic DAG generation: one DAG per configured site
|
|
228
|
+
# ---------------------------------------------------------------------------
|
|
229
|
+
|
|
230
|
+
_SITES = _get_configured_sites()
|
|
231
|
+
if _SITES:
|
|
232
|
+
_AGENCY_EPHEMERIS = _uses_agency_ephemeris()
|
|
233
|
+
for _site_name in _SITES:
|
|
234
|
+
globals()[f"canvod_{_site_name}"] = create_daily_dag(_site_name, _AGENCY_EPHEMERIS)
|