airflow.providers.standard.operators.datetime

BranchDateTimeOperator

根據當前日期時間將分支指向兩個任務列表之一。

函式

target_times_as_dates(base_date, lower, upper)

透過將上下時間目標與基準日期組合,確保它們是 datetime 物件。

模組內容

class airflow.providers.standard.operators.datetime.BranchDateTimeOperator(*, follow_task_ids_if_true, follow_task_ids_if_false, target_lower, target_upper, use_task_logical_date=False, **kwargs)[source]

基類: airflow.providers.standard.operators.branch.BaseBranchOperator

根據當前日期時間將分支指向兩個任務列表之一。

有關如何使用此運算元的更多資訊,請參閱指南:BranchDateTimeOperator

datetime.datetime.now() 介於 target_lowertarget_upper 之間時,返回 true 分支。

引數:
  • follow_task_ids_if_true (str | collections.abc.Iterable[str]) – 如果 datetime.datetime.now() 介於 target_lower 和 target_upper 之間,則要跟蹤的任務 ID、任務組 ID 或任務 ID 和/或任務組 ID 列表。

  • follow_task_ids_if_false (str | collections.abc.Iterable[str]) – 如果 datetime.datetime.now() 小於 target_lower 或大於 target_upper,則要跟蹤的任務 ID、任務組 ID 或任務 ID 和/或任務組 ID 列表。

  • target_lower (datetime.datetime | datetime.time | None) – 目標下限。

  • target_upper (datetime.datetime | datetime.time | None) – 目標上限。

  • use_task_logical_date (bool) – 如果為 True,則使用任務的邏輯日期與目標進行比較。邏輯日期對於回填很有用。如果為 False,則使用系統日期。

target_lower[source]
target_upper[source]
follow_task_ids_if_true[source]
follow_task_ids_if_false[source]
use_task_logical_date = False[source]
choose_branch(context)[source]

選擇要執行哪個分支的抽象方法。

子類應實現此方法,執行選擇分支所需的任何邏輯,並返回一個 task_id 或 task_ids 列表。

引數:

context (airflow.sdk.definitions.context.Context) – 傳遞給 execute() 的上下文字典。

airflow.providers.standard.operators.datetime.target_times_as_dates(base_date, lower, upper)[source]

透過將上下時間目標與基準日期組合,確保它們是 datetime 物件。

此條目是否有幫助?