Reputation: 853
I have use case to create 2 tasks of BigqueryOperator that have same destination table but I need one to run daily, and the second one to be run manually just when I need.
Below are the illustration of Tree View
| task_3rd_adhoc
| task_3rd
|---- task_2nd
|---- task_1st_a
|---- task_1st_b
From example above, DAG are run daily. And I aim to the task will be:
But I still can't find what is the correct TriggerRule for step #4 above. I tried TriggerRule.DUMMY because I thought it can be used to set no Trigger, but task_3rd_adhoc also run in daily job when I tried create DAG above. (based on this doc dependencies are just for show, trigger at will)
Upvotes: 0
Views: 1911
Reputation: 11607
First of all, you've misunderstood TriggerRule.DUMMY
.
task_a >> task_b
, B would run only after A is complete (success / failed, based on B's trigger_rule
).TriggerRule.DUMMY
means that even after wiring tasks A & B together as before, B would run independently of A (run at will). It doesn't mean run at your will, rather it runs at Airflow's will (it will trigger it whenever it feels like). So clearly tasks having dummy trigger rule will pretty much ALWAYS run, albeit, at an unpredictable timeWhat you need here (to have a particular task in DAG always but run it only when manually specified) is a combination of
Here's roughly how you can do
Variable
should hold the command for this task (whether or not it should run). This Variable, of course, you can edit anytime from UI (thereby controlling whether or not that task runs in next DagRun)execute()
method for custom-operator or just python_callable
in case of PythonOperator
), you'll check value of Variable (whether or not the task is supposed to run)AirflowSkipException
, so that the task will be marked at skipped. Or else, it will just run as usualUpvotes: 1