Untitled

mail@pastecode.io avatar
unknown
python
2 months ago
991 B
0
Indexable
Never
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from airflow.operators.python_operator import PythonOperator
from datetime import datetime

# Define default arguments
default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
    'start_date': datetime(2024, 2, 20),
    'email_on_failure': False,
    'email_on_retry': False,
    'retries': 1
}

# Define DAG
dag = DAG(
    'hello_goodbye_dag',
    default_args=default_args,
    description='A simple DAG with two tasks',
    schedule_interval=None,
)

# Task 1: BashOperator to print "Hello World"
task_1 = BashOperator(
    task_id='hello_world',
    bash_command='echo "Hello World"',
    dag=dag,
)

# Task 2: PythonOperator to print "Goodbye World"
def print_goodbye():
    print("Goodbye World")

task_2 = PythonOperator(
    task_id='goodbye_world',
    python_callable=print_goodbye,
    dag=dag,
)

# Define task dependencies
task_1 >> task_2
Leave a Comment