從氣流文檔:氣流:模式運行的氣流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