airflow_ha.HighAvailabilityOperator

class airflow_ha.HighAvailabilityOperator(python_callable: Callable[[...], Tuple[Result, Action]], pass_trigger_kwargs: Dict[str, Any] | None = None, fail_trigger_kwargs: Dict[str, Any] | None = None, **kwargs)[source]

Bases: HighAvailabilityOperatorMixin, PythonSensor

__init__(python_callable: Callable[[...], Tuple[Result, Action]], pass_trigger_kwargs: Dict[str, Any] | None = None, fail_trigger_kwargs: Dict[str, Any] | None = None, **kwargs) None

The HighAvailabilityOperator is an Airflow Meta-Operator for long-running or “always-on” tasks.

It resembles a BranchPythonOperator with the following predefined set of outcomes:

check -> decide -> PASS/RETRIGGER

-> PASS/STOP -> FAIL/RETRIGGER -> FAIL/STOP -> */CONTINUE

Any setup should be state-aware (e.g. don’t just start a process, check if it is currently started first).

Methods

__init__(python_callable[, ...])

The HighAvailabilityOperator is an Airflow Meta-Operator for long-running or "always-on" tasks.

add_inlets(inlets)

Set inlets to this operator.

add_outlets(outlets)

Define the outlets of this operator.

as_setup()

Mark a task as setup task.

as_teardown(*[, setups, on_failure_fail_dagrun])

Mark a task as teardown and set its setups as direct relatives.

clear([start_date, end_date, upstream, ...])

Clear the state of task instances associated with the task, following the parameters specified.

defer(*, trigger, method_name[, kwargs, timeout])

Mark this Operator "deferred", suspending its execution until the provided trigger fires an event.

dry_run()

Perform dry run for the operator - just render template fields.

execute(context)

Derive when creating an operator.

expand_mapped_task(run_id, *, session)

Create the mapped task instances for mapped task.

expand_start_from_trigger(*, context, session)

Get the start_from_trigger value of the current abstract operator.

expand_start_trigger_args(*, context, session)

Get the start_trigger_args value of the current abstract operator.

get_closest_mapped_task_group()

Get the mapped task group "closest" to this task in the DAG.

get_dag()

get_direct_relative_ids([upstream])

Get direct relative IDs to the current task, upstream or downstream.

get_direct_relatives([upstream])

Get list of the direct relatives to the current task, upstream or downstream.

get_extra_links(ti, link_name)

For an operator, gets the URLs that the extra_links entry points to.

get_flat_relative_ids(*[, upstream])

Get a flat set of relative IDs, upstream or downstream.

get_flat_relatives([upstream])

Get a flat list of relatives, either upstream or downstream.

get_inlet_defs()

Get inlet definitions on this task.

get_mapped_ti_count(run_id, *, session)

Return the number of mapped TaskInstances that can be created at run time.

get_needs_expansion()

Return true if the task is MappedOperator or is in a mapped task group.

get_outlet_defs()

Get outlet definitions on this task.

get_serialized_fields()

Stringified DAGs and operators contain exactly these fields.

get_task_instances([start_date, end_date, ...])

Get task instances related to this task for a specific date range.

get_template_env([dag])

Get the template environment for rendering templates.

get_upstreams_follow_setups()

All upstreams and, for each upstream setup, its respective teardowns.

get_upstreams_only_setups()

Return relevant upstream setups.

get_upstreams_only_setups_and_teardowns()

Only relevant upstream setups and their teardowns.

has_dag()

Return True if the Operator has been assigned to a DAG.

iter_mapped_dependants()

Return mapped nodes that depend on the current task the expansion.

iter_mapped_task_groups()

Return mapped task groups this task belongs to.

logger()

Return a logger.

on_kill()

Override this method to clean up subprocesses when a task instance gets killed.

partial(*, task_id[, dag, task_group, ...])

poke(context)

Override when deriving this class.

post_execute(context[, result])

Execute right after self.execute() is called.

pre_execute(context)

Execute right before self.execute() is called.

prepare_for_execution()

Lock task for execution to disable custom action in __setattr__ and return a copy.

prepare_template()

Execute after the templated fields get replaced by their content.

render_template(content, context[, ...])

Render a templated string.

render_template_fields(context[, jinja_env])

Template all attributes listed in self.template_fields.

resolve_template_files()

Get the content of files for template_field / template_ext.

resume_execution(next_method, next_kwargs, ...)

Call this method when a deferred task is resumed.

run([start_date, end_date, ...])

Run a set of task instances for a date range.

serialize_for_task_group()

Serialize; required by DAGNode.

set_downstream(task_or_task_list[, ...])

Set a node (or nodes) to be directly downstream from the current node.

set_upstream(task_or_task_list[, edge_modifier])

Set a node (or nodes) to be directly upstream from the current node.

set_xcomargs_dependencies()

Resolve upstream dependencies of a task.

skip(dag_run, execution_date, tasks[, map_index])

Facade for compatibility for call to internal API.

skip_all_except(ti, branch_task_ids)

Facade for compatibility for call to internal API.

unmap(resolve)

Get the "normal" operator from the current operator.

update_relative(other[, upstream, edge_modifier])

Update relationship information about another TaskMixin.

xcom_pull(context[, task_ids, dag_id, key, ...])

Pull XComs that optionally meet certain criteria.

xcom_push(context, key, value[, execution_date])

Make an XCom available for tasks to pull.

Attributes

HIDE_ATTRS_FROM_UI

dag

Returns the Operator's DAG if set, otherwise raises an error.

dag_id

Returns dag id if it has one or an adhoc + owner.

deps

Returns the set of dependencies for the operator.

downstream_list

List of nodes directly downstream.

end_date

extra_links

get_parse_time_mapped_ti_count

global_operator_extra_link_dict

Returns dictionary of all global extra links.

inherits_from_empty_operator

Used to determine if an Operator is inherited from EmptyOperator.

is_setup

Whether the operator is a setup task.

is_teardown

Whether the operator is a teardown task.

label

leaves

Required by DAGNode.

log

Return a logger.

node_id

on_failure_fail_dagrun

Whether the operator should fail the dagrun on failure.

operator_class

operator_extra_link_dict

Returns dictionary of all extra links for the operator.

operator_extra_links

operator_name

use a more friendly display name for the operator, if set.

output

Returns reference to XCom pushed by current operator.

pool

priority_weight_total

Total priority weight for the task.

reschedule

Define mode rescheduled sensors.

retrigger_fail

retrigger_pass

roots

Required by DAGNode.

shallow_copy_attrs

start_date

start_from_trigger

start_trigger_args

stop_fail

stop_pass

subdag

supports_lineage

task_display_name

task_group

The task_group that contains this node

task_type

type of the task.

template_ext

template_fields

template_fields_renderers

ui_color

ui_fgcolor

upstream_list

List of nodes directly upstream.

valid_modes

weight_rule

priority_weight

owner

task_id

outlets

inlets

trigger_rule

upstream_task_ids

downstream_task_ids