forked from astronomer/2-9-example-dags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdownstream1_on_any.py
37 lines (31 loc) · 888 Bytes
/
downstream1_on_any.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
## Toy DAG scheduled to run on an update to any of 4 upstream datasets
"""
from airflow.decorators import dag, task
from airflow.datasets import Dataset
from pendulum import datetime
@dag(
start_date=datetime(2024, 3, 1),
schedule=(
Dataset("dataset1")
| Dataset("dataset2")
| Dataset("dataset3")
| Dataset("dataset4")
), # Runs when any of the datasets are updated
# NEW in Airflow 2.9: Use conditional logic to schedule a DAG based on datasets
# Use () instead of [] to be able to use conditional dataset scheduling!
catchup=False,
doc_md=__doc__,
tags=["toy", "Conditional Dataset Scheduling"],
)
def downstream1_on_any():
@task
def say_hello() -> None:
"""
Print Hello
"""
import time
time.sleep(10)
print("Hello")
say_hello()
downstream1_on_any()