-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6_pools_dag.py
47 lines (35 loc) · 1.5 KB
/
6_pools_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
from airflow.models import DAG
from airflow.operators.dummy import DummyOperator
from airflow.operators.python import PythonOperator
from airflow.operators.bash import BashOperator
from datetime import datetime
NAME_LIST = ['Tinmar','Alejandra','Kenya','Atocha','Francisco','Paola','Lucy','Ajna']
default_args = {
"owner":"Tinmar",
"start_date": datetime(2023, 1, 9),
"pool":"Alta Prioridad" # Podemos hacer que TODAS las tasks de un DAG se ejecuten en una misma pool
}
# PythonOperator: prueba_python
def hello_world_loop(*args):
for palabra in args:
print(f'Hola {palabra}')
with DAG(
'6_pools_dag',
catchup = False,
default_args=default_args,
schedule_interval=None,
tags=['Curso 2', 'Apache_Airflow']
) as dag:
start_task = DummyOperator(task_id='start_task')
prueba_python = PythonOperator(
task_id='python_op',
python_callable=hello_world_loop,
op_args=NAME_LIST,
#pool='Alta Prioridad' # También podemos hacer que solo una tarea se ejecute en una pool diferente a la de default
)
prueba_bash = BashOperator(
task_id='bash_op',
bash_command='echo Prueba Bash'
)
end_task = DummyOperator(task_id='end_task')
start_task >> prueba_python >> prueba_bash >> end_task