카테고리 없음

[Airflow] Dag의 Bash Operator 만들어보기

박경태 2022. 4. 18. 15:04

https://github.com/ParkGyeongTae/airflow-pgt/tree/main/0_airflow

 

GitHub - ParkGyeongTae/airflow-pgt

Contribute to ParkGyeongTae/airflow-pgt development by creating an account on GitHub.

github.com

 

from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime

dag = DAG (
	dag_id            = 'my_bash_dag',
	start_date        = datetime(2022, 4, 16),
	schedule_interval = '* * * * *',
    catchup           = False
    )

sleep_1 = BashOperator (
	task_id      = 'sleep_1',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_2 = BashOperator (
	task_id      = 'sleep_2',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_3 = BashOperator (
	task_id      = 'sleep_3',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_4 = BashOperator (
	task_id      = 'sleep_4',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_5 = BashOperator (
	task_id      = 'sleep_5',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_6 = BashOperator (
	task_id      = 'sleep_6',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_1 >> sleep_2 >> [sleep_3, sleep_4] >> sleep_6
sleep_1 >> sleep_5 >> sleep_6

 

from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime

dag = DAG (
	dag_id            = 'my_bash_dag',
	start_date        = datetime(2022, 4, 16),
	schedule_interval = '* * * * *',
	catchup           = False
    )

sleep_1 = BashOperator (
	task_id      = 'sleep_1',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_2 = BashOperator (
	task_id      = 'sleep_2',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_3 = BashOperator (
	task_id      = 'sleep_3',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_4 = BashOperator (
	task_id      = 'sleep_4',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_5 = BashOperator (
	task_id      = 'sleep_5',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_6 = BashOperator (
	task_id      = 'sleep_6',
	bash_command = 'sleep 10',
	dag          = dag
    )

 

 

from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime

dag = DAG (
	dag_id            = 'my_bash_dag',
	start_date        = datetime(2022, 4, 16),
	schedule_interval = '* * * * *',
	catchup           = False
    )

sleep_1 = BashOperator (
	task_id      = 'sleep_1',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_2 = BashOperator (
	task_id      = 'sleep_2',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_3 = BashOperator (
	task_id      = 'sleep_3',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_4 = BashOperator (
	task_id      = 'sleep_4',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_5 = BashOperator (
	task_id      = 'sleep_5',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_6 = BashOperator (
	task_id      = 'sleep_6',
	bash_command = 'sleep 10',
	dag          = dag
    )

sleep_1 >> [sleep_2, sleep_3, sleep_4, sleep_5] >> sleep_6