forked from marclamberti/airflow-dags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparallel_dag.py
28 lines (18 loc) · 880 Bytes
/
parallel_dag.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
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from airflow.operators.python_operator import PythonOperator
from datetime import datetime
default_args = {
'start_date': datetime(2019, 1, 1),
'owner': 'Airflow',
}
def process(p1):
print(p1)
return 'done'
with DAG(dag_id='parallel_dag', schedule_interval='0 0 * * *', default_args=default_args, catchup=False) as dag:
# Tasks dynamically generated
tasks = [BashOperator(task_id='task_{0}'.format(t), bash_command='sleep 60'.format(t)) for t in range(1, 4)]
task_4 = PythonOperator(task_id='task_4', python_callable=process, op_args=['my super parameter'])
task_5 = BashOperator(task_id='task_5', bash_command='echo "pipeline done"')
task_6 = BashOperator(task_id='task_6', bash_command='sleep 60')
tasks >> task_4 >> task_5 >> task_6