-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecute_multiple_task.py
More file actions
61 lines (48 loc) · 1.25 KB
/
execute_multiple_task.py
File metadata and controls
61 lines (48 loc) · 1.25 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from datetime import datetime, timedelta
from airflow.utils.dates import days_ago
from airflow import DAG
from airflow.operators.bash import BashOperator
default_args = {
'owner': 'asadali'
}
with DAG(
dag_id='executing_multiple_tasks',
description='DAG with multiple tasks and dependencies',
default_args=default_args,
start_date=days_ago(1),
schedule_interval=timedelta(days=1),
tags=['upstream', 'downstream']
) as dag:
taskA = BashOperator(
task_id='taskA',
bash_command='''
echo TASK A has started!
for i in {1..10}
do
echo TASK A printing $i
done
echo TASK A has ended!
'''
)
taskB = BashOperator(
task_id='taskB',
bash_command='''
echo TASK B has started!
sleep 4
echo TASK B has ended!
'''
)
taskC = BashOperator(
task_id='taskC',
bash_command='''
echo TASK C has started!
sleep 15
echo TASK C has ended!
'''
)
taskD = BashOperator(
task_id='taskD',
bash_command='echo TASK D completed!'
)
taskA >> [taskB, taskC]
taskD << [taskB, taskC]