Skip to content

Instantly share code, notes, and snippets.

@andscoop
Created September 25, 2018 18:26
Show Gist options
  • Save andscoop/8e946b10abfe3d9ad083a21fea0e9a8c to your computer and use it in GitHub Desktop.
Save andscoop/8e946b10abfe3d9ad083a21fea0e9a8c to your computer and use it in GitHub Desktop.
"""
Example of sequential dynamic task creation
"""
from datetime import datetime, timedelta
from airflow import DAG, configuration
from airflow.operators.dummy_operator import DummyOperator
dag = DAG(
dag_id="dynamic_tasks_example",
start_date=datetime(2018, 2, 9),
schedule_interval='15 * * * *',
catchup=True,
)
start = DummyOperator(
task_id='start',
dag=dag
)
tasks = [start]
for t in ["task1", "task2", "task3"]:
taskOp = DummyOperator(
task_id=t,
dag=dag)
tasks[-1] >> taskOp
tasks.append(taskOp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment