从气流文档:气流:模式运行的气流subdag一次
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
我明白subdagoperator作为一个BackfillJob实际实现的,因此,我们必须提供一个schedule_interval
给操作者。然而,有没有办法获得一个subdag的schedule_interval="@once"
的语义等价物?我担心,如果我使用设置schedule_interval="@daily"
作为subdag,如果subdag运行时间超过一天,则subdag可能会运行多次。
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:如何捏造出来
为了说明起见,你建议使用[TriggerDagRunOperator](https://airflow.incubator.apache.org/code.html?highlight=trigger%20dagrun#airflow.operators.TriggerDagRunOperator)来触发一个dag而不用时间表?这个subdag的关键是我们想要阻塞语义,触发器dagrun运算符只是触发一个dagrun,然后继续前进,不会等到dagrun完成。另外,你不会在气流UI中获得一个subdag运行的透明度,你只知道一些随机的dagrun被触发。 – gnicholas