From the airflow documentation:
SubDAGs must have a schedule and be enabled. If the SubDAG’s schedule is set to None or @once, the SubDAG will succeed without having done anything
I understand the subdagoperator is actually implemented as a BackfillJob and thus we must provide a schedule_interval
to the operator. However, is there a way to get the semantic equivalent of schedule_interval="@once"
for a subdag? I'm worried that if I use set schedule_interval="@daily"
for the subdag that the subdag may run more than once if the subdag takes longer than a day to run.
def subdag_factory(parent_dag_name, child_dag_name, args):
subdag = DAG(
dag_id="{parent_dag_name}.{child_dag_name}".format(
parent_dag_name=parent_dag_name, child_dag_name=child_dag_name
),
schedule_interval="@daily", # <--- this bit here
default_args=args
)
... do more stuff to the subdag here
return subdag
TLDR: how to fake out "only run this subdag once per trigger of the parent dag"