I’m new to Airflow. I need to come up with a clean easy solution for DAG dependencies with different schedules.
I have DAG 1 running Daily and DAG 2 - Weekly. How do I use TriggerDAGRunOperator to trigger weekly DAG from Daily one?
DAG 1:
with DAG('DAG 1',
schedule_interval='0 10 * * *'
) as dag:
TASK1 = BashOperator(task_id='TASK1',
bash_command='sample')
TRG_TASK=TriggerDAGRunOperator(task_id='TRG_TASK',trigger_dag_id='DAG 2')
TASK1 >> TRG_TASK
DAG 2:
with DAG('DAG 2',
schedule_interval='15 10 * * 5'
) as dag:
TASK1 = BashOperator(task_id='TASK1',
bash_command='sample')
I know I can use ExternalTaskSensor Operator and mention timedelta, but it would become messy in long run.
Is there any easy/clean option with TriggerDAGRunOperator to check everyday if DAG 2 is indeed scheduled to run for that day then only trigger it else skip it on other days?
Thanks