Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
922 B
1
Indexable
Never
from airflow import DAG
from airflow.operators.python import PythonOperator
from datetime import datetime

# Define the default arguments for the DAG
default_args = {
    'owner': 'your_name',
    'start_date': datetime(2023, 11, 7),
    'retries': 1,
}

# Create the DAG object
dag = DAG('math_operations', default_args=default_args, schedule_interval=None)

# Define two Python functions for addition and subtraction
def add_numbers():
    result = 5 + 3
    print(f'Addition result: {result}')

def subtract_numbers():
    result = 10 - 4
    print(f'Subtraction result: {result}')

# Create PythonOperator tasks for addition and subtraction
add_task = PythonOperator(
    task_id='addition_task',
    python_callable=add_numbers,
    dag=dag,
)

subtract_task = PythonOperator(
    task_id='subtraction_task',
    python_callable=subtract_numbers,
    dag=dag,
)

# Set the task dependencies
add_task >> subtract_task