Untitled
unknown
plain_text
2 years ago
922 B
11
Indexable
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
Editor is loading...