| :py:mod:`airflow.models.abstractoperator` |
| ========================================= |
| |
| .. py:module:: airflow.models.abstractoperator |
| |
| |
| Module Contents |
| --------------- |
| |
| Classes |
| ~~~~~~~ |
| |
| .. autoapisummary:: |
| |
| airflow.models.abstractoperator.AbstractOperator |
| |
| |
| |
| |
| Attributes |
| ~~~~~~~~~~ |
| |
| .. autoapisummary:: |
| |
| airflow.models.abstractoperator.TaskStateChangeCallback |
| airflow.models.abstractoperator.DEFAULT_OWNER |
| airflow.models.abstractoperator.DEFAULT_POOL_SLOTS |
| airflow.models.abstractoperator.DEFAULT_PRIORITY_WEIGHT |
| airflow.models.abstractoperator.DEFAULT_QUEUE |
| airflow.models.abstractoperator.DEFAULT_IGNORE_FIRST_DEPENDS_ON_PAST |
| airflow.models.abstractoperator.DEFAULT_RETRIES |
| airflow.models.abstractoperator.DEFAULT_RETRY_DELAY |
| airflow.models.abstractoperator.DEFAULT_WEIGHT_RULE |
| airflow.models.abstractoperator.DEFAULT_TRIGGER_RULE |
| airflow.models.abstractoperator.DEFAULT_TASK_EXECUTION_TIMEOUT |
| |
| |
| .. py:data:: TaskStateChangeCallback |
| |
| |
| |
| |
| .. py:data:: DEFAULT_OWNER |
| :annotation: :str |
| |
| |
| |
| .. py:data:: DEFAULT_POOL_SLOTS |
| :annotation: :int = 1 |
| |
| |
| |
| .. py:data:: DEFAULT_PRIORITY_WEIGHT |
| :annotation: :int = 1 |
| |
| |
| |
| .. py:data:: DEFAULT_QUEUE |
| :annotation: :str |
| |
| |
| |
| .. py:data:: DEFAULT_IGNORE_FIRST_DEPENDS_ON_PAST |
| :annotation: :bool |
| |
| |
| |
| .. py:data:: DEFAULT_RETRIES |
| :annotation: :int |
| |
| |
| |
| .. py:data:: DEFAULT_RETRY_DELAY |
| :annotation: :datetime.timedelta |
| |
| |
| |
| .. py:data:: DEFAULT_WEIGHT_RULE |
| :annotation: :airflow.utils.weight_rule.WeightRule |
| |
| |
| |
| .. py:data:: DEFAULT_TRIGGER_RULE |
| :annotation: :airflow.utils.trigger_rule.TriggerRule |
| |
| |
| |
| .. py:data:: DEFAULT_TASK_EXECUTION_TIMEOUT |
| :annotation: :datetime.timedelta | None |
| |
| |
| |
| .. py:class:: AbstractOperator(context=None) |
| |
| Bases: :py:obj:`airflow.utils.log.logging_mixin.LoggingMixin`, :py:obj:`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. |
| |
| :meta private: |
| |
| .. py:attribute:: operator_class |
| :annotation: :type[BaseOperator] | dict[str, Any] |
| |
| |
| |
| .. py:attribute:: weight_rule |
| :annotation: :str |
| |
| |
| |
| .. py:attribute:: priority_weight |
| :annotation: :int |
| |
| |
| |
| .. py:attribute:: operator_extra_links |
| :annotation: :Collection[airflow.models.baseoperator.BaseOperatorLink] |
| |
| |
| |
| .. py:attribute:: template_fields |
| :annotation: :Collection[str] |
| |
| |
| |
| .. py:attribute:: template_ext |
| :annotation: :Sequence[str] |
| |
| |
| |
| .. py:attribute:: owner |
| :annotation: :str |
| |
| |
| |
| .. py:attribute:: task_id |
| :annotation: :str |
| |
| |
| |
| .. py:attribute:: outlets |
| :annotation: :list |
| |
| |
| |
| .. py:attribute:: inlets |
| :annotation: :list |
| |
| |
| |
| .. py:attribute:: HIDE_ATTRS_FROM_UI |
| :annotation: :ClassVar[frozenset[str]] |
| |
| |
| |
| .. py:method:: get_dag() |
| :abstractmethod: |
| |
| |
| .. py:method:: task_type() |
| :property: |
| |
| |
| .. py:method:: operator_name() |
| :property: |
| |
| |
| .. py:method:: inherits_from_empty_operator() |
| :property: |
| |
| |
| .. py:method:: dag_id() |
| :property: |
| |
| Returns dag id if it has one or an adhoc + owner |
| |
| |
| .. py:method:: node_id() |
| :property: |
| |
| |
| .. py:method:: get_template_env() |
| |
| Fetch a Jinja template environment from the DAG or instantiate empty environment if no DAG. |
| |
| |
| .. py:method:: prepare_template() |
| |
| 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. |
| |
| |
| .. py:method:: resolve_template_files() |
| |
| Getting the content of files for template_field / template_ext. |
| |
| |
| .. py:method:: get_direct_relative_ids(upstream = False) |
| |
| Get direct relative IDs to the current task, upstream or downstream. |
| |
| |
| .. py:method:: get_flat_relative_ids(upstream = False, found_descendants = None) |
| |
| Get a flat set of relative IDs, upstream or downstream. |
| |
| |
| .. py:method:: get_flat_relatives(upstream = False) |
| |
| Get a flat list of relatives, either upstream or downstream. |
| |
| |
| .. py:method:: iter_mapped_dependants() |
| |
| Return mapped nodes that depend on the current task the expansion. |
| |
| For now, this walks the entire DAG to find mapped nodes that has this |
| current task as an upstream. We cannot use ``downstream_list`` since it |
| only contains operators, not task groups. In the future, we should |
| provide a way to record an DAG node's all downstream nodes instead. |
| |
| |
| .. py:method:: unmap(resolve) |
| :abstractmethod: |
| |
| Get the "normal" operator from current abstract operator. |
| |
| MappedOperator uses this to unmap itself based on the map index. A non- |
| mapped operator (i.e. BaseOperator subclass) simply returns itself. |
| |
| :meta private: |
| |
| |
| .. py:method:: priority_weight_total() |
| :property: |
| |
| 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 |
| |
| |
| .. py:method:: operator_extra_link_dict() |
| |
| Returns dictionary of all extra links for the operator |
| |
| |
| .. py:method:: global_operator_extra_link_dict() |
| |
| Returns dictionary of all global extra links |
| |
| |
| .. py:method:: extra_links() |
| |
| |
| .. py:method:: get_extra_links(ti, link_name) |
| |
| For an operator, gets the URLs that the ``extra_links`` entry points to. |
| |
| :meta private: |
| |
| :raise 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. |
| :param ti: The TaskInstance for the URL being searched for. |
| :param link_name: The name of the link we're looking for the URL for. Should be |
| one of the options specified in ``extra_links``. |
| |
| |
| .. py:method:: render_template_fields(context, jinja_env = None) |
| :abstractmethod: |
| |
| 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*. |
| |
| |
| .. py:method:: render_template(content, context, jinja_env = None, seen_oids = None) |
| |
| Render a templated string. |
| |
| If *content* is a collection holding multiple templated strings, strings |
| in the collection will be templated recursively. |
| |
| :param content: Content to template. Only strings can be templated (may |
| be inside a collection). |
| :param context: Dict with values to apply on templated content |
| :param jinja_env: Jinja environment. Can be provided to avoid |
| re-creating Jinja environments during recursion. |
| :param seen_oids: template fields already rendered (to avoid |
| *RecursionError* on circular dependencies) |
| :return: Templated content |
| |
| |
| |