How do we trigger single airflow dag multipler times using TriggerDagRunOperator?

Issue

This Content is from Stack Overflow. Question asked by Tarun Bhardwaj

I have a Dag with schedule interval None. I want to trigger this Dag by TriggerDagRunOperator multiple times in a day.

I crated a PreDag with schedule_interval “* 1/12 * * *”
Inside PreDag a task of TriggerDagRunOperator runs that Trigger the main Dag.
As scheduled PreDag runs twice a day 1st time when PreDag runs it trigger the Dag but 2nd time when PreDag runs then task of triggerDagRunOperator show error :
” A Dag Run already exists for dag id {{ dag_id}} at {{ execution_date}} with run id {{ trigger_run_id}}” `

trigger_run = TriggerDagRunOperator(
                task_id="main_dag_trigger",
                trigger_dag_id=str('DW_Test_TriggerDag'),  
                pool='branch_pool_limit', 
                wait_for_completion=True, 
                poke_interval=20, 
                trigger_run_id = 'trig__' + str(datetime.now()),
                execution_date = '{{ ds }}',
                # reset_dag_run = True ,
                dag = predag
            )`

Is it possible to Trigger a dag multiple times in a day using TriggerDagRunOperator.



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?