-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_n.py
More file actions
71 lines (60 loc) · 1.41 KB
/
task_n.py
File metadata and controls
71 lines (60 loc) · 1.41 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
61
62
63
64
65
66
67
68
69
70
71
""" TERCERA PARTE AIRFLOW """
""" APARTADO 3) """
from datetime import timedelta, datetime
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
default_args = {
'owner': 'airflow',
'depends_on_past': False,
# ¿Sería necesario empezar desde 1900??
#'start_date': datetime(1900, 1, 1),
'start_date': datetime(2020, 11, 21),
'retries': 1,
'retry_delay': timedelta(seconds=5)
}
dag = DAG(
'task_n',
default_args=default_args,
description='A task_n DAG',
#https://crontab.guru/ --> 3:00 UTC,
schedule_interval='0 3 * * *',
)
task_1 = BashOperator(
task_id='task_1_print_date',
bash_command='date',
dag=dag,
)
task_2 = BashOperator(
task_id='task_2_sleep',
depends_on_past=False,
bash_command='sleep 5',
retries=3,
dag=dag,
)
task_3 = BashOperator(
task_id='task_3_print_date',
bash_command='date',
dag=dag,
)
task_4 = BashOperator(
task_id='task_4_sleep',
depends_on_past=False,
bash_command='sleep 5',
retries=3,
dag=dag,
)
task_5 = BashOperator(
task_id='task_5_print_date',
bash_command='date',
dag=dag,
)
task_6 = BashOperator(
task_id='task_6_sleep',
depends_on_past=False,
bash_command='sleep 5',
retries=3,
dag=dag,
)
task_2.set_downstream([task_1, task_3, task_5])
task_4.set_downstream([task_1, task_3, task_5])
task_6.set_downstream([task_1, task_3, task_5])