Branching operators

Module Contents

class airflow.operators.branch.BaseBranchOperator[source]

Bases: airflow.models.BaseOperator, airflow.models.skipmixin.SkipMixin

This is a base class for creating operators with branching functionality, similarly to BranchPythonOperator.

Users should subclass this operator and implement the function choose_branch(self, context). This should run whatever business logic is needed to determine the branch, and return either the task_id for a single task (as a str) or a list of task_ids.

The operator will continue with the returned task_id(s), and all other tasks directly downstream of this operator will be skipped.

choose_branch(self, context: Dict)[source]

Subclasses should implement this, running whatever logic is necessary to choose a branch and returning a task_id or list of task_ids.


context (dict) – Context dictionary as passed to execute()

execute(self, context: Dict)[source]

Was this entry helpful?