Created
September 20, 2021 02:41
-
-
Save MatrixManAtYrService/654827111dc190407a3c81008da6ee16 to your computer and use it in GitHub Desktop.
a dag with tasks that complete one after another
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from airflow.decorators import dag, task | |
from airflow.sensors.date_time import DateTimeSensor, DateTimeSensorAsync | |
from airflow.utils.dates import days_ago | |
from time import sleep | |
def tensec_taskfactory(i): | |
@task(task_id=f"task_{i}") | |
def wait(): | |
print(f"I am task {i}") | |
sleep(10) | |
return wait() | |
@dag( | |
schedule_interval="@once", | |
start_date=days_ago(1), | |
default_args={"owner": "airflow"}, | |
catchup=False, | |
) | |
def steady_task_stream(): | |
prev = tensec_taskfactory(1) | |
for i in range(2, 10): | |
current = tensec_taskfactory(i) | |
prev >> current | |
prev = current | |
the_dag = steady_task_stream() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment