Airflow Study1- BashOperator

박성현·2024년 5월 27일

Airflow

목록 보기
7/28

1. 기본 라이브러리 import

from airflow import DAG
import datetime
import pendulum
from airflow.operators.bash import BashOperator

2. with DAG

WEB UI 보여지는 DAG 이름 , .py 파일명이랑 dag_id 는 일치 시키는게 좋음

with DAG(
    dag_id="dags_bash_operator",  
    schedule="0 0 * * *", # 분 시 일 월 요일
    start_date=pendulum.datetime(2021,1,1, tz = "Asia/Seoul"),
    catchup=False, # 시작 일부터(한꺼번에 돌려) = True, 오늘부터 돌릴것이냐 = False 
) as dag: 
    

3. 객체화

UI Graph에서 보이는 이름 , 객체명과 task_id명은 동일하게 작성하는게 편리함

    bash_t1 = BashOperator(
        task_id="bash_t1",  
        bash_command="echo blue sky!",
    )
    
    bash_t2 = BashOperator(
        task_id="bash_t2", 
        bash_command="echo green ground!",
    )

4.TASK 실행 순서

bash_t1 >> bash_t2
profile
다소Good한 데이터 엔지니어

0개의 댓글