#In the dags folder, create a new Python file called simple_dag.py:
from airflow import DAG
from airflow.operators.python import PythonOperator
from airflow.operators.bash import BashOperator
from datetime import datetime, timedelta
def print_hello():
print("Hello, Seemab!")
default_args = {
'owner': 'airflow',
'retries': 1,
'retry_delay': timedelta(minutes=5),
}
with DAG(
'simple_dag',
default_args=default_args,
description='A simple DAG',
schedule_interval=timedelta(days=1),
start_date=datetime(2023, 1, 1),
catchup=False,
) as dag:
# Task 1: Python function to print "Hello, World!"
hello_task = PythonOperator(
task_id='hello_task',
python_callable=print_hello,
)
# Task 2: Bash command to display the current date
date_task = BashOperator(
task_id='date_task',
bash_command='date',
)
# Set dependencies
hello_task >> date_task