from airflow import DAG from datetime import datetime, timedelta from airflow.operators import MyFirstOperator, MyFirstSensor default_arguments = { 'owner': 'airflow', 'start_date': datetime(2020, 5, 15, 0, 0, 0), 'retries': 3, 'retry_delay': timedelta(minutes=10) } dag = DAG(dag_id='my_first_dag', max_active_runs=5, schedule_interval='0 * * * *', default_args=default_arguments, catchup=False) task_1 = MyFirstOperator(task_id='task_id1', param='some random text', dag=dag) task_2 = MyFirstSensor(task_id='task_id2', poke_interval=30, dag=dag) task_2 >> task_1 # task_2 será executando antes da task_1
from datetime import datetime from airflow import DAG from airflow.operators.dummy_operator import DummyOperator from airflow.operators import MyFirstOperator, MyFirstSensor dag = DAG('my_test_dag', description='Another tutorial DAG', schedule_interval='0 12 * * *', start_date=datetime(2017, 3, 20), catchup=False) sensor_task = MyFirstSensor(task_id='my_sensor_task', poke_interval=30, dag=dag) dummy_task = DummyOperator(task_id='dummy_task', dag=dag) operator_task = MyFirstOperator(my_operator_param='This is a test.', task_id='my_first_operator_task', dag=dag) sensor_task >> dummy_task >> operator_task
from datetime import datetime from airflow import DAG from airflow.operators.dummy_operator import DummyOperator from airflow.operators import MyFirstOperator, MyFirstSensor def print_hello(): return 'Hello world MM!' dag = DAG('hello_world', description='Simple tutorial DAG', schedule_interval='0 12 * * *', start_date=datetime(2020, 5, 1), catchup=False) dummy_operator = DummyOperator(task_id='dummy_task', retries=3, dag=dag) sensor_task = MyFirstSensor(task_id='my_sensor_task', poke_interval=30, dag=dag, mode='reschedule') hello_operator = MyFirstOperator(my_operator_param='This is a test', task_id='my_first_operator_task', dag=dag) dummy_operator >> sensor_task >> hello_operator