airflow.operators.branch

分支運算子。

模組內容

類別

BranchMixIn

用於單行處理分支的實用輔助工具。

BaseBranchOperator

用於建立具有分支功能的運算子的基礎類別,例如 BranchPythonOperator。

class airflow.operators.branch.BranchMixIn(context=None)[source]

基底類別: airflow.models.skipmixin.SkipMixin

用於單行處理分支的實用輔助工具。

do_branch(context, branches_to_execute)[source]

實作分支處理,包含日誌記錄。

class airflow.operators.branch.BaseBranchOperator(task_id, owner=DEFAULT_OWNER, email=None, email_on_retry=conf.getboolean('email', 'default_email_on_retry', fallback=True), email_on_failure=conf.getboolean('email', 'default_email_on_failure', fallback=True), retries=DEFAULT_RETRIES, retry_delay=DEFAULT_RETRY_DELAY, retry_exponential_backoff=False, max_retry_delay=None, start_date=None, end_date=None, depends_on_past=False, ignore_first_depends_on_past=DEFAULT_IGNORE_FIRST_DEPENDS_ON_PAST, wait_for_past_depends_before_skipping=DEFAULT_WAIT_FOR_PAST_DEPENDS_BEFORE_SKIPPING, wait_for_downstream=False, dag=None, params=None, default_args=None, priority_weight=DEFAULT_PRIORITY_WEIGHT, weight_rule=DEFAULT_WEIGHT_RULE, queue=DEFAULT_QUEUE, pool=None, pool_slots=DEFAULT_POOL_SLOTS, sla=None, execution_timeout=DEFAULT_TASK_EXECUTION_TIMEOUT, on_execute_callback=None, on_failure_callback=None, on_success_callback=None, on_retry_callback=None, on_skipped_callback=None, pre_execute=None, post_execute=None, trigger_rule=DEFAULT_TRIGGER_RULE, resources=None, run_as_user=None, task_concurrency=None, map_index_template=None, max_active_tis_per_dag=None, max_active_tis_per_dagrun=None, executor=None, executor_config=None, do_xcom_push=True, multiple_outputs=False, inlets=None, outlets=None, task_group=None, doc=None, doc_md=None, doc_json=None, doc_yaml=None, doc_rst=None, task_display_name=None, logger_name=None, allow_nested_operators=True, **kwargs)[source]

基底類別: airflow.models.baseoperator.BaseOperator, BranchMixIn

用於建立具有分支功能的運算子的基礎類別,例如 BranchPythonOperator。

使用者應從此運算子建立子類別,並實作 choose_branch(self, context) 函數。這應執行任何必要的業務邏輯來決定分支,並返回以下其中一項:- 單個 task_id (字串格式) - 單個 task_group_id (字串格式) - 包含 task_ids 和 task_group_ids 組合的列表

運算子將繼續執行返回的 task_id(s) 和/或 task_group_id(s),並且此運算子直接下游的所有其他任務都將被跳過。

abstract choose_branch(context)[source]

選擇要運行的分支的抽象方法。

子類別應實作此方法,運行任何必要的邏輯來選擇分支並返回 task_id 或 task_ids 列表。

參數

context (airflow.utils.context.Context) – 傳遞給 execute() 的 Context 字典

execute(context)[source]

在建立運算子時衍生。

Context 是與渲染 jinja 範本時使用的字典相同。

請參閱 get_template_context 以獲得更多上下文。

此條目是否有幫助?