airflow.models.mappedoperator

Module Contents

Classes

OperatorPartial

An "intermediate state" returned by BaseOperator.partial().

MappedOperator

Object representing a mapped operator in a DAG.

Functions

get_mappable_types()

validate_mapping_kwargs(op, func, value)

prevent_duplicates(kwargs1, kwargs2, *, fail_reason)

ensure_xcomarg_return_value(arg)

Attributes

Mappable

ValidationSource

MAPPABLE_LITERAL_TYPES

airflow.models.mappedoperator.Mappable[source]
airflow.models.mappedoperator.ValidationSource[source]
airflow.models.mappedoperator.MAPPABLE_LITERAL_TYPES[source]
airflow.models.mappedoperator.get_mappable_types()[source]
airflow.models.mappedoperator.validate_mapping_kwargs(op, func, value)[source]
airflow.models.mappedoperator.prevent_duplicates(kwargs1, kwargs2, *, fail_reason)[source]
airflow.models.mappedoperator.ensure_xcomarg_return_value(arg)[source]
class airflow.models.mappedoperator.OperatorPartial[source]

An “intermediate state” returned by BaseOperator.partial().

This only exists at DAG-parsing time; the only intended usage is for the user to call .expand() on it at some point (usually in a method chain) to create a MappedOperator to add into the DAG.

operator_class :Type[airflow.models.baseoperator.BaseOperator][source]
kwargs :Dict[str, Any][source]
__attrs_post_init__()[source]
__repr__()[source]

Return repr(self).

__del__()[source]
expand(**mapped_kwargs)[source]
class airflow.models.mappedoperator.MappedOperator(context=None)[source]

Bases: airflow.models.abstractoperator.AbstractOperator

Object representing a mapped operator in a DAG.

operator_class :Union[Type[airflow.models.baseoperator.BaseOperator], Dict[str, Any]][source]
mapped_kwargs :Dict[str, Mappable][source]
partial_kwargs :Dict[str, Any][source]
task_id :str[source]
params :Optional[dict][source]
deps :FrozenSet[airflow.ti_deps.deps.base_ti_dep.BaseTIDep][source]
template_ext :Sequence[str][source]
template_fields :Collection[str][source]
template_fields_renderers :Dict[str, str][source]
ui_color :str[source]
ui_fgcolor :str[source]
dag :Optional[airflow.models.dag.DAG][source]
task_group :Optional[airflow.utils.task_group.TaskGroup][source]
start_date :Optional[pendulum.DateTime][source]
end_date :Optional[pendulum.DateTime][source]
upstream_task_ids :Set[str][source]
downstream_task_ids :Set[str][source]
is_mapped :ClassVar[bool] = True[source]
subdag :None[source]
HIDE_ATTRS_FROM_UI :ClassVar[FrozenSet[str]][source]
__hash__()[source]

Return hash(self).

__repr__()[source]

Return repr(self).

__attrs_post_init__()[source]
classmethod get_serialized_fields()[source]
static deps_for(operator_class)[source]
property task_type[source]

Implementing Operator.

property inherits_from_empty_operator[source]

Implementing Operator.

property roots[source]

Implementing DAGNode.

property leaves[source]

Implementing DAGNode.

property owner[source]
property email[source]
property trigger_rule[source]
property depends_on_past[source]
property wait_for_downstream[source]
property retries[source]
property queue[source]
property pool[source]
property pool_slots[source]
property execution_timeout[source]
property retry_delay[source]
property retry_exponential_backoff[source]
property priority_weight[source]
property weight_rule[source]
property sla[source]
property max_active_tis_per_dag[source]
property resources[source]
property on_execute_callback[source]
property on_failure_callback[source]
property on_retry_callback[source]
property on_success_callback[source]
property run_as_user[source]
property executor_config[source]
property inlets[source]
property outlets[source]
get_dag()[source]

Implementing Operator.

serialize_for_task_group()[source]

Implementing DAGNode.

unmap(unmap_kwargs=None)[source]

Get the “normal” Operator after applying the current mapping.

If operator_class is not a class (i.e. this DAG has been deserialized) then this will return a SerializedBaseOperator that aims to “look like” the real operator.

Parameters

unmap_kwargs (Optional[Dict[str, Any]]) – Override the args to pass to the Operator constructor. Only used when operator_class is still an actual class.

expand_mapped_task(run_id, *, session)[source]

Create the mapped task instances for mapped task.

Returns

The newly created mapped TaskInstances (if any) in ascending order by map index, and the maximum map_index.

Return type

Tuple[Sequence[airflow.models.taskinstance.TaskInstance], int]

prepare_for_execution()[source]
render_template_fields(context, jinja_env=None)[source]

Template all attributes listed in template_fields.

Different from the BaseOperator implementation, this renders the template fields on the unmapped BaseOperator.

Parameters
  • context (airflow.utils.context.Context) – Dict with values to apply on content

  • jinja_env (Optional[jinja2.Environment]) – Jinja environment

Returns

The unmapped, populated BaseOperator

Return type

Optional[airflow.models.baseoperator.BaseOperator]

iter_mapped_dependencies()[source]

Upstream dependencies that provide XComs used by this task for task mapping.

parse_time_mapped_ti_count()[source]

Number of mapped TaskInstances that can be created at DagRun create time.

Returns

None if non-literal mapped arg encountered, or else total number of mapped TIs this task should have

Return type

Optional[int]

run_time_mapped_ti_count(run_id, *, session)[source]

Number of mapped TaskInstances that can be created at run time, or None if upstream tasks are not complete yet.

Returns

None if upstream tasks are not complete yet, or else total number of mapped TIs this task should have

Return type

Optional[int]

Was this entry helpful?