-
Notifications
You must be signed in to change notification settings - Fork 67
/
example-dag.py
91 lines (75 loc) · 1.9 KB
/
example-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
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'start_date': datetime(2018, 1, 1),
'email_on_failure': False,
'email_on_retry': False,
'retries': 1,
'retry_delay': timedelta(minutes=5),
}
dag = DAG('example_dag',
max_active_runs=3,
schedule_interval=timedelta(minutes=5),
default_args=default_args)
t1 = BashOperator(
task_id='print_date1',
bash_command='sleep $[ ( $RANDOM % 30 ) + 1 ]s',
dag=dag)
t2 = BashOperator(
task_id='print_date2',
bash_command='sleep $[ ( $RANDOM % 30 ) + 1 ]s',
dag=dag)
t3 = BashOperator(
task_id='print_date3',
bash_command='sleep $[ ( $RANDOM % 30 ) + 1 ]s',
dag=dag)
t4 = BashOperator(
task_id='print_date4',
bash_command='sleep $[ ( $RANDOM % 30 ) + 1 ]s',
dag=dag)
t5 = BashOperator(
task_id='print_date5',
bash_command='sleep $[ ( $RANDOM % 30 ) + 1 ]s',
dag=dag)
t6 = BashOperator(
task_id='print_date6',
bash_command='sleep $[ ( $RANDOM % 30 ) + 1 ]s',
dag=dag)
t7 = BashOperator(
task_id='print_date7',
bash_command='sleep $[ ( $RANDOM % 30 ) + 1 ]s',
dag=dag)
t8 = BashOperator(
task_id='print_date8',
bash_command='sleep $[ ( $RANDOM % 30 ) + 1 ]s',
dag=dag)
t2.set_upstream(t1)
t3.set_upstream(t2)
t4.set_upstream(t3)
t5.set_upstream(t3)
t6.set_upstream(t3)
t7.set_upstream(t3)
t8.set_upstream(t3)
t9 = BashOperator(
task_id='print_date9',
bash_command='sleep $[ ( $RANDOM % 30 ) + 1 ]s',
dag=dag)
t10 = BashOperator(
task_id='print_date10',
bash_command='sleep $[ ( $RANDOM % 30 ) + 1 ]s',
dag=dag)
t11 = BashOperator(
task_id='print_date11',
bash_command='sleep $[ ( $RANDOM % 30 ) + 1 ]s',
dag=dag)
t12 = BashOperator(
task_id='print_date12',
bash_command='sleep $[ ( $RANDOM % 30 ) + 1 ]s',
dag=dag)
t9.set_upstream(t8)
t10.set_upstream(t8)
t11.set_upstream(t8)
t12.set_upstream(t8)