개발중/AirFlow

[Airflow] 아주 간단한 DAG 실행시키기

Binsoo 2025. 4. 3.
728x90
반응형

목적

say_hello1 > say_hello2 > say_hello3 함수를 차례대로 실행시켜보자.

 

say_hello1.py

def say_hello1():
    print("Hello from say_hello1!")

 

say_hello2.py

def say_hello2():
    print("Hello from say_hello2!")

 

say_hello1.py

def say_hello3():
    print("Hello from say_hello3!")

 

 

hello_airflow_test.py

from airflow import DAG
from airflow.operators.python import PythonOperator
from datetime import datetime

from say_hello1 import say_hello1
from say_hello2 import say_hello2
from say_hello3 import say_hello3

with DAG(
    dag_id='hello_airflow_test',
    start_date=datetime(2024, 1, 1),
    schedule_interval='@once',
    catchup=False,
    tags=['test']
) as dag:
    task1 = PythonOperator(
        task_id='say_hello_task1',
        python_callable=say_hello1
    )

    task2 = PythonOperator(
        task_id='say_hello_task2',
        python_callable=say_hello2
    )

    task3 = PythonOperator(
        task_id='say_hello_task3',
        python_callable=say_hello3
    )

    task1 >> task2 >> task3  # 순차 실행
728x90
반응형

댓글