airflow.models.abstractoperator
¶
Module Contents¶
Classes¶
Common implementation for operators, including unmapped and mapped. |
Attributes¶
- airflow.models.abstractoperator.DEFAULT_TRIGGER_RULE :airflow.utils.trigger_rule.TriggerRule[source]¶
- airflow.models.abstractoperator.DEFAULT_TASK_EXECUTION_TIMEOUT :Optional[datetime.timedelta][source]¶
- class airflow.models.abstractoperator.AbstractOperator(context=None)[source]¶
Bases:
airflow.utils.log.logging_mixin.LoggingMixin
,airflow.models.taskmixin.DAGNode
Common implementation for operators, including unmapped and mapped.
This base class is more about sharing implementations, not defining a common interface. Unfortunately it’s difficult to use this as the common base class for typing due to BaseOperator carrying too much historical baggage.
The union type
from airflow.models.operator import Operator
is easier to use for typing purposes.- get_template_env(self)[source]¶
Fetch a Jinja template environment from the DAG or instantiate empty environment if no DAG.
- prepare_template(self)[source]¶
Hook triggered after the templated fields get replaced by their content.
If you need your operator to alter the content of the file before the template is rendered, it should override this method to do so.
- resolve_template_files(self)[source]¶
Getting the content of files for template_field / template_ext.
- get_direct_relative_ids(self, upstream=False)[source]¶
Get direct relative IDs to the current task, upstream or downstream.
- get_flat_relative_ids(self, upstream=False, found_descendants=None)[source]¶
Get a flat set of relative IDs, upstream or downstream.
- get_flat_relatives(self, upstream=False)[source]¶
Get a flat list of relatives, either upstream or downstream.
- property priority_weight_total(self)[source]¶
Total priority weight for the task. It might include all upstream or downstream tasks.
Depending on the weight rule:
WeightRule.ABSOLUTE - only own weight
WeightRule.DOWNSTREAM - adds priority weight of all downstream tasks
WeightRule.UPSTREAM - adds priority weight of all upstream tasks
- get_extra_links(self, ti, link_name)[source]¶
For an operator, gets the URLs that the
extra_links
entry points to.- Raises
ValueError – The error message of a ValueError will be passed on through to the fronted to show up as a tooltip on the disabled link.
- Parameters
ti (airflow.models.taskinstance.TaskInstance) – The TaskInstance for the URL being searched for.
link_name (str) – The name of the link we’re looking for the URL for. Should be one of the options specified in
extra_links
.
- abstract render_template_fields(self, context, jinja_env=None)[source]¶
Template all attributes listed in template_fields.
If the operator is mapped, this should return the unmapped, fully rendered, and map-expanded operator. The mapped operator should not be modified.
If the operator is not mapped, this should modify the operator in-place and return either None (for backwards compatibility) or self.
- render_template(self, content, context, jinja_env=None, seen_oids=None)[source]¶
Render a templated string.
If content is a collection holding multiple templated strings, strings in the collection will be templated recursively.
- Parameters
content (Any) – Content to template. Only strings can be templated (may be inside a collection).
context (airflow.utils.context.Context) – Dict with values to apply on templated content
jinja_env (Optional[jinja2.Environment]) – Jinja environment. Can be provided to avoid re-creating Jinja environments during recursion.
seen_oids (Optional[Set]) – template fields already rendered (to avoid RecursionError on circular dependencies)
- Returns
Templated content
- Return type
Any