Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow/decorators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@
from airflow.typing_compat import ParamSpec, Protocol
from airflow.utils import timezone
from airflow.utils.context import KNOWN_CONTEXT_KEYS
from airflow.utils.decorators import remove_task_decorator
from airflow.utils.helpers import prevent_duplicates
from airflow.utils.trigger_rule import TriggerRule
from airflow.utils.types import NOTSET
from providers.src.airflow.providers.standard.utils.decorators import remove_task_decorator

if TYPE_CHECKING:
from sqlalchemy.orm import Session
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_asset_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

from airflow import DAG
from airflow.assets import Asset, AssetAlias
from airflow.decorators import task
from airflow.providers.standard.decorators import task

with DAG(
dag_id="asset_s3_bucket_producer",
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_bash_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

import pendulum

from airflow.decorators import dag, task
from airflow.exceptions import AirflowSkipException
from airflow.models.baseoperator import chain
from airflow.operators.empty import EmptyOperator
from airflow.providers.standard.decorators import dag, task
from airflow.utils.trigger_rule import TriggerRule
from airflow.utils.weekday import WeekDay

Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_branch_operator_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@

import pendulum

from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.operators.empty import EmptyOperator
from airflow.providers.standard.decorators import task
from airflow.utils.edgemodifier import Label
from airflow.utils.trigger_rule import TriggerRule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

import pendulum

from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.operators.empty import EmptyOperator
from airflow.providers.standard.decorators import task


@task.branch()
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_dag_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import httpx
import pendulum

from airflow.decorators import dag, task
from airflow.models.baseoperator import BaseOperator
from airflow.operators.email import EmailOperator
from airflow.providers.standard.decorators import dag, task

if TYPE_CHECKING:
from airflow.utils.context import Context
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_display_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import pendulum

from airflow.decorators import dag, task
from airflow.operators.empty import EmptyOperator
from airflow.providers.standard.decorators import dag, task


# [START dag_decorator_usage]
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_dynamic_task_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

from datetime import datetime

from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.providers.standard.decorators import task

with DAG(dag_id="example_dynamic_task_mapping", schedule=None, start_date=datetime(2022, 3, 4)) as dag:

Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_inlet_event_extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import datetime

from airflow.assets import Asset
from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.providers.standard.decorators import task
from airflow.providers.standard.operators.bash import BashOperator

asset = Asset("s3://output/1.txt")
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_kubernetes_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import pendulum

from airflow.configuration import conf
from airflow.decorators import task
from airflow.example_dags.libs.helper import print_stuff
from airflow.models.dag import DAG
from airflow.providers.standard.decorators import task

log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_local_kubernetes_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
from datetime import datetime

from airflow.configuration import conf
from airflow.decorators import task
from airflow.example_dags.libs.helper import print_stuff
from airflow.models.dag import DAG
from airflow.providers.standard.decorators import task

log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_nested_branch_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

import pendulum

from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.operators.empty import EmptyOperator
from airflow.providers.standard.decorators import task
from airflow.utils.trigger_rule import TriggerRule

with DAG(
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_outlet_event_extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

from airflow.assets import Asset
from airflow.assets.metadata import Metadata
from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.providers.standard.decorators import task
from airflow.providers.standard.operators.bash import BashOperator

ds = Asset("s3://output/1.txt")
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_params_trigger_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import datetime
from pathlib import Path

from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.models.param import Param, ParamsDict
from airflow.providers.standard.decorators import task
from airflow.utils.trigger_rule import TriggerRule

# [START params_trigger]
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_params_ui_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import json
from pathlib import Path

from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.models.param import Param, ParamsDict
from airflow.providers.standard.decorators import task

with DAG(
dag_id=Path(__file__).stem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

import pendulum

from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.providers.standard.decorators import task
from airflow.providers.standard.operators.bash import BashOperator


Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_python_context_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import pendulum

from airflow.decorators import dag, task
from airflow.providers.standard.decorators import dag, task

SOME_EXTERNAL_PYTHON = sys.executable

Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_python_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import pendulum

from airflow.decorators import dag, task
from airflow.providers.standard.decorators import dag, task

log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_sensor_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# [START import_module]
import pendulum

from airflow.decorators import dag, task
from airflow.providers.standard.decorators import dag, task
from airflow.sensors.base import PokeReturnValue

# [END import_module]
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_setup_teardown_taskflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import pendulum

from airflow.decorators import setup, task, task_group, teardown
from airflow.models.dag import DAG
from airflow.providers.standard.decorators import setup, task, task_group, teardown

with DAG(
dag_id="example_setup_teardown_taskflow",
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_short_circuit_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

import pendulum

from airflow.decorators import dag, task
from airflow.models.baseoperator import chain
from airflow.operators.empty import EmptyOperator
from airflow.providers.standard.decorators import dag, task
from airflow.utils.trigger_rule import TriggerRule


Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_task_group_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import pendulum

from airflow.decorators import task, task_group
from airflow.models.dag import DAG
from airflow.providers.standard.decorators import task, task_group


# [START howto_task_group_decorator]
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_trigger_target_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

import pendulum

from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.providers.standard.decorators import task
from airflow.providers.standard.operators.bash import BashOperator


Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_xcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

import pendulum

from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.models.xcom_arg import XComArg
from airflow.providers.standard.decorators import task
from airflow.providers.standard.operators.bash import BashOperator

value_1 = [1, 2, 3]
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_xcomargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

import pendulum

from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.providers.standard.decorators import task
from airflow.providers.standard.operators.bash import BashOperator

log = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/tutorial_objectstorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import pendulum
import requests

from airflow.decorators import dag, task
from airflow.io.path import ObjectStoragePath
from airflow.providers.standard.decorators import dag, task

# [END import_module]

Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/tutorial_taskflow_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import pendulum

from airflow.decorators import dag, task
from airflow.providers.standard.decorators import dag, task

# [END import_module]

Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/tutorial_taskflow_api_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import logging
from datetime import datetime

from airflow.decorators import dag, task
from airflow.providers.standard.decorators import dag, task

log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/tutorial_taskflow_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# [START import_module]
import pendulum

from airflow.decorators import dag, task
from airflow.providers.standard.decorators import dag, task
from airflow.providers.standard.operators.python import get_current_context

# [END import_module]
Expand Down
2 changes: 1 addition & 1 deletion airflow/models/baseoperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class ExecutorSafeguard:
def decorator(cls, func):
@wraps(func)
def wrapper(self, *args, **kwargs):
from airflow.decorators.base import DecoratedOperator
from airflow.providers.standard.decorators.base import DecoratedOperator

sentinel_key = f"{self.__class__.__name__}__sentinel"
sentinel = kwargs.pop(sentinel_key, None)
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def ensure_prefix(field):
from urllib.parse import SplitResult

from airflow.assets import Asset
from airflow.decorators.base import TaskDecorator
from airflow.hooks.base import BaseHook
from airflow.providers.standard.decorators.base import TaskDecorator
from airflow.typing_compat import Literal


Expand Down
2 changes: 1 addition & 1 deletion dev/mypy/plugin/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}

TASK_CALL_FUNCTIONS = {
"airflow.decorators.base.Task.__call__",
"airflow.providers.standard.decorators.base.Task.__call__",
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Here is an example of a task with both features:
import pendulum

from airflow import DAG
from airflow.decorators import task
from airflow.providers.standard.decorators import task
from airflow.example_dags.libs.helper import print_stuff
from airflow.settings import AIRFLOW_HOME

Expand Down
32 changes: 32 additions & 0 deletions docs/apache-airflow-providers-standard/decorators/base.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.. Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

.. http://www.apache.org/licenses/LICENSE-2.0

.. Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

Decorators
----------
DAG authors can use decorators to author DAGs using the :doc:`TaskFlow <core-concepts/taskflow>` concept.
All Decorators derive from :class:`~airflow.providers.standard.decorators.base.TaskDecorator`.

Airflow has a set of Decorators that are considered public. You are free to extend their functionality
by extending them:

.. toctree::
:includehidden:
:maxdepth: 1

_api/airflow/decorators/index

You can read more about creating custom Decorators in :doc:`howto/create-custom-decorator`.
Loading