airflow.operators.branch
¶
Branching operators.
Module Contents¶
Classes¶
Utility helper which handles the branching as one-liner. |
|
A base class for creating operators with branching functionality, like to BranchPythonOperator. |
- class airflow.operators.branch.BranchMixIn(context=None)[source]¶
Bases:
airflow.models.skipmixin.SkipMixin
Utility helper which handles the branching as one-liner.
- class airflow.operators.branch.BaseBranchOperator(pre_execute=None, post_execute=None, on_execute_callback=None, on_failure_callback=None, on_success_callback=None, on_retry_callback=None, on_skipped_callback=None, **kwargs)[source]¶
Bases:
airflow.models.baseoperator.BaseOperator
,BranchMixIn
A base class for creating operators with branching functionality, like to BranchPythonOperator.
Users should create a subclass from this operator and implement the function choose_branch(self, context). This should run whatever business logic is needed to determine the branch, and return one of the following: - A single task_id (as a str) - A single task_group_id (as a str) - A list containing a combination of task_ids and task_group_ids
The operator will continue with the returned task_id(s) and/or task_group_id(s), and all other tasks directly downstream of this operator will be skipped.
- abstract choose_branch(context)[source]¶
Abstract method to choose which branch to run.
Subclasses should implement this, running whatever logic is necessary to choose a branch and returning a task_id or list of task_ids.
- Parameters
context (airflow.utils.context.Context) – Context dictionary as passed to execute()