apache-airflow-providers-standard 0.3.0rc1__py3-none-any.whl → 0.3.0rc2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of apache-airflow-providers-standard might be problematic. Click here for more details.

@@ -0,0 +1,16 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
@@ -0,0 +1,111 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ from __future__ import annotations
19
+
20
+ import warnings
21
+ from collections.abc import Collection, Mapping, Sequence
22
+ from typing import TYPE_CHECKING, Any, Callable, ClassVar
23
+
24
+ from airflow.decorators.base import DecoratedOperator, TaskDecorator, task_decorator_factory
25
+ from airflow.providers.standard.operators.bash import BashOperator
26
+ from airflow.sdk.definitions._internal.types import SET_DURING_EXECUTION
27
+ from airflow.utils.context import context_merge
28
+ from airflow.utils.operator_helpers import determine_kwargs
29
+
30
+ if TYPE_CHECKING:
31
+ from airflow.sdk.definitions.context import Context
32
+
33
+
34
+ class _BashDecoratedOperator(DecoratedOperator, BashOperator):
35
+ """
36
+ Wraps a Python callable and uses the callable return value as the Bash command to be executed.
37
+
38
+ :param python_callable: A reference to an object that is callable.
39
+ :param op_kwargs: A dictionary of keyword arguments that will get unpacked
40
+ in your function (templated).
41
+ :param op_args: A list of positional arguments that will get unpacked when
42
+ calling your callable (templated).
43
+ """
44
+
45
+ template_fields: Sequence[str] = (*DecoratedOperator.template_fields, *BashOperator.template_fields)
46
+ template_fields_renderers: ClassVar[dict[str, str]] = {
47
+ **DecoratedOperator.template_fields_renderers,
48
+ **BashOperator.template_fields_renderers,
49
+ }
50
+
51
+ custom_operator_name: str = "@task.bash"
52
+ overwrite_rtif_after_execution: bool = True
53
+
54
+ def __init__(
55
+ self,
56
+ *,
57
+ python_callable: Callable,
58
+ op_args: Collection[Any] | None = None,
59
+ op_kwargs: Mapping[str, Any] | None = None,
60
+ **kwargs,
61
+ ) -> None:
62
+ if kwargs.pop("multiple_outputs", None):
63
+ warnings.warn(
64
+ f"`multiple_outputs=True` is not supported in {self.custom_operator_name} tasks. Ignoring.",
65
+ UserWarning,
66
+ stacklevel=3,
67
+ )
68
+
69
+ super().__init__(
70
+ python_callable=python_callable,
71
+ op_args=op_args,
72
+ op_kwargs=op_kwargs,
73
+ bash_command=SET_DURING_EXECUTION,
74
+ multiple_outputs=False,
75
+ **kwargs,
76
+ )
77
+
78
+ def execute(self, context: Context) -> Any:
79
+ context_merge(context, self.op_kwargs)
80
+ kwargs = determine_kwargs(self.python_callable, self.op_args, context)
81
+
82
+ self.bash_command = self.python_callable(*self.op_args, **kwargs)
83
+
84
+ if not isinstance(self.bash_command, str) or self.bash_command.strip() == "":
85
+ raise TypeError("The returned value from the TaskFlow callable must be a non-empty string.")
86
+
87
+ self._is_inline_cmd = self._is_inline_command(bash_command=self.bash_command)
88
+ context["ti"].render_templates() # type: ignore[attr-defined]
89
+
90
+ return super().execute(context)
91
+
92
+
93
+ def bash_task(
94
+ python_callable: Callable | None = None,
95
+ **kwargs,
96
+ ) -> TaskDecorator:
97
+ """
98
+ Wrap a function into a BashOperator.
99
+
100
+ Accepts kwargs for operator kwargs. Can be reused in a single DAG. This function is only used only used
101
+ during type checking or auto-completion.
102
+
103
+ :param python_callable: Function to decorate.
104
+
105
+ :meta private:
106
+ """
107
+ return task_decorator_factory(
108
+ python_callable=python_callable,
109
+ decorated_operator_class=_BashDecoratedOperator,
110
+ **kwargs,
111
+ )
@@ -0,0 +1,57 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ from __future__ import annotations
18
+
19
+ from typing import TYPE_CHECKING, Callable
20
+
21
+ from airflow.decorators.base import task_decorator_factory
22
+ from airflow.providers.standard.decorators.python import _PythonDecoratedOperator
23
+ from airflow.providers.standard.operators.python import BranchExternalPythonOperator
24
+
25
+ if TYPE_CHECKING:
26
+ from airflow.decorators.base import TaskDecorator
27
+
28
+
29
+ class _BranchExternalPythonDecoratedOperator(_PythonDecoratedOperator, BranchExternalPythonOperator):
30
+ """Wraps a Python callable and captures args/kwargs when called for execution."""
31
+
32
+ template_fields = BranchExternalPythonOperator.template_fields
33
+ custom_operator_name: str = "@task.branch_external_python"
34
+
35
+
36
+ def branch_external_python_task(
37
+ python_callable: Callable | None = None, multiple_outputs: bool | None = None, **kwargs
38
+ ) -> TaskDecorator:
39
+ """
40
+ Wrap a python function into a BranchExternalPythonOperator.
41
+
42
+ For more information on how to use this operator, take a look at the guide:
43
+ :ref:`concepts:branching`
44
+
45
+ Accepts kwargs for operator kwarg. Can be reused in a single DAG.
46
+
47
+ :param python_callable: Function to decorate
48
+ :param multiple_outputs: if set, function return value will be
49
+ unrolled to multiple XCom values. Dict will unroll to xcom values with keys as XCom keys.
50
+ Defaults to False.
51
+ """
52
+ return task_decorator_factory(
53
+ python_callable=python_callable,
54
+ multiple_outputs=multiple_outputs,
55
+ decorated_operator_class=_BranchExternalPythonDecoratedOperator,
56
+ **kwargs,
57
+ )
@@ -0,0 +1,57 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ from __future__ import annotations
18
+
19
+ from typing import TYPE_CHECKING, Callable
20
+
21
+ from airflow.decorators.base import task_decorator_factory
22
+ from airflow.providers.standard.decorators.python import _PythonDecoratedOperator
23
+ from airflow.providers.standard.operators.python import BranchPythonOperator
24
+
25
+ if TYPE_CHECKING:
26
+ from airflow.decorators.base import TaskDecorator
27
+
28
+
29
+ class _BranchPythonDecoratedOperator(_PythonDecoratedOperator, BranchPythonOperator):
30
+ """Wraps a Python callable and captures args/kwargs when called for execution."""
31
+
32
+ template_fields = BranchPythonOperator.template_fields
33
+ custom_operator_name: str = "@task.branch"
34
+
35
+
36
+ def branch_task(
37
+ python_callable: Callable | None = None, multiple_outputs: bool | None = None, **kwargs
38
+ ) -> TaskDecorator:
39
+ """
40
+ Wrap a python function into a BranchPythonOperator.
41
+
42
+ For more information on how to use this operator, take a look at the guide:
43
+ :ref:`concepts:branching`
44
+
45
+ Accepts kwargs for operator kwarg. Can be reused in a single DAG.
46
+
47
+ :param python_callable: Function to decorate
48
+ :param multiple_outputs: if set, function return value will be
49
+ unrolled to multiple XCom values. Dict will unroll to xcom values with keys as XCom keys.
50
+ Defaults to False.
51
+ """
52
+ return task_decorator_factory(
53
+ python_callable=python_callable,
54
+ multiple_outputs=multiple_outputs,
55
+ decorated_operator_class=_BranchPythonDecoratedOperator,
56
+ **kwargs,
57
+ )
@@ -0,0 +1,57 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ from __future__ import annotations
18
+
19
+ from typing import TYPE_CHECKING, Callable
20
+
21
+ from airflow.decorators.base import task_decorator_factory
22
+ from airflow.providers.standard.decorators.python import _PythonDecoratedOperator
23
+ from airflow.providers.standard.operators.python import BranchPythonVirtualenvOperator
24
+
25
+ if TYPE_CHECKING:
26
+ from airflow.decorators.base import TaskDecorator
27
+
28
+
29
+ class _BranchPythonVirtualenvDecoratedOperator(_PythonDecoratedOperator, BranchPythonVirtualenvOperator):
30
+ """Wraps a Python callable and captures args/kwargs when called for execution."""
31
+
32
+ template_fields = BranchPythonVirtualenvOperator.template_fields
33
+ custom_operator_name: str = "@task.branch_virtualenv"
34
+
35
+
36
+ def branch_virtualenv_task(
37
+ python_callable: Callable | None = None, multiple_outputs: bool | None = None, **kwargs
38
+ ) -> TaskDecorator:
39
+ """
40
+ Wrap a python function into a BranchPythonVirtualenvOperator.
41
+
42
+ For more information on how to use this operator, take a look at the guide:
43
+ :ref:`concepts:branching`
44
+
45
+ Accepts kwargs for operator kwarg. Can be reused in a single DAG.
46
+
47
+ :param python_callable: Function to decorate
48
+ :param multiple_outputs: if set, function return value will be
49
+ unrolled to multiple XCom values. Dict will unroll to xcom values with keys as XCom keys.
50
+ Defaults to False.
51
+ """
52
+ return task_decorator_factory(
53
+ python_callable=python_callable,
54
+ multiple_outputs=multiple_outputs,
55
+ decorated_operator_class=_BranchPythonVirtualenvDecoratedOperator,
56
+ **kwargs,
57
+ )
@@ -0,0 +1,65 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ from __future__ import annotations
18
+
19
+ from typing import TYPE_CHECKING, Callable
20
+
21
+ from airflow.decorators.base import task_decorator_factory
22
+ from airflow.providers.standard.decorators.python import _PythonDecoratedOperator
23
+ from airflow.providers.standard.operators.python import ExternalPythonOperator
24
+
25
+ if TYPE_CHECKING:
26
+ from airflow.decorators.base import TaskDecorator
27
+
28
+
29
+ class _PythonExternalDecoratedOperator(_PythonDecoratedOperator, ExternalPythonOperator):
30
+ """Wraps a Python callable and captures args/kwargs when called for execution."""
31
+
32
+ template_fields = ExternalPythonOperator.template_fields
33
+ custom_operator_name: str = "@task.external_python"
34
+
35
+
36
+ def external_python_task(
37
+ python: str | None = None,
38
+ python_callable: Callable | None = None,
39
+ multiple_outputs: bool | None = None,
40
+ **kwargs,
41
+ ) -> TaskDecorator:
42
+ """
43
+ Wrap a callable into an Airflow operator to run via a Python virtual environment.
44
+
45
+ Accepts kwargs for operator kwarg. Can be reused in a single DAG.
46
+
47
+ This function is only used during type checking or auto-completion.
48
+
49
+ :meta private:
50
+
51
+ :param python: Full path string (file-system specific) that points to a Python binary inside
52
+ a virtualenv that should be used (in ``VENV/bin`` folder). Should be absolute path
53
+ (so usually start with "/" or "X:/" depending on the filesystem/os used).
54
+ :param python_callable: Function to decorate
55
+ :param multiple_outputs: If set to True, the decorated function's return value will be unrolled to
56
+ multiple XCom values. Dict will unroll to XCom values with its keys as XCom keys.
57
+ Defaults to False.
58
+ """
59
+ return task_decorator_factory(
60
+ python=python,
61
+ python_callable=python_callable,
62
+ multiple_outputs=multiple_outputs,
63
+ decorated_operator_class=_PythonExternalDecoratedOperator,
64
+ **kwargs,
65
+ )
@@ -0,0 +1,81 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ from __future__ import annotations
18
+
19
+ from collections.abc import Sequence
20
+ from typing import TYPE_CHECKING, Callable
21
+
22
+ from airflow.decorators.base import DecoratedOperator, task_decorator_factory
23
+ from airflow.providers.standard.operators.python import PythonOperator
24
+
25
+ if TYPE_CHECKING:
26
+ from airflow.decorators.base import TaskDecorator
27
+
28
+
29
+ class _PythonDecoratedOperator(DecoratedOperator, PythonOperator):
30
+ """
31
+ Wraps a Python callable and captures args/kwargs when called for execution.
32
+
33
+ :param python_callable: A reference to an object that is callable
34
+ :param op_kwargs: a dictionary of keyword arguments that will get unpacked
35
+ in your function (templated)
36
+ :param op_args: a list of positional arguments that will get unpacked when
37
+ calling your callable (templated)
38
+ :param multiple_outputs: If set to True, the decorated function's return value will be unrolled to
39
+ multiple XCom values. Dict will unroll to XCom values with its keys as XCom keys. Defaults to False.
40
+ """
41
+
42
+ template_fields: Sequence[str] = ("templates_dict", "op_args", "op_kwargs")
43
+ template_fields_renderers = {"templates_dict": "json", "op_args": "py", "op_kwargs": "py"}
44
+
45
+ custom_operator_name: str = "@task"
46
+
47
+ def __init__(self, *, python_callable, op_args, op_kwargs, **kwargs) -> None:
48
+ kwargs_to_upstream = {
49
+ "python_callable": python_callable,
50
+ "op_args": op_args,
51
+ "op_kwargs": op_kwargs,
52
+ }
53
+ super().__init__(
54
+ kwargs_to_upstream=kwargs_to_upstream,
55
+ python_callable=python_callable,
56
+ op_args=op_args,
57
+ op_kwargs=op_kwargs,
58
+ **kwargs,
59
+ )
60
+
61
+
62
+ def python_task(
63
+ python_callable: Callable | None = None,
64
+ multiple_outputs: bool | None = None,
65
+ **kwargs,
66
+ ) -> TaskDecorator:
67
+ """
68
+ Wrap a function into an Airflow operator.
69
+
70
+ Accepts kwargs for operator kwarg. Can be reused in a single DAG.
71
+
72
+ :param python_callable: Function to decorate
73
+ :param multiple_outputs: If set to True, the decorated function's return value will be unrolled to
74
+ multiple XCom values. Dict will unroll to XCom values with its keys as XCom keys. Defaults to False.
75
+ """
76
+ return task_decorator_factory(
77
+ python_callable=python_callable,
78
+ multiple_outputs=multiple_outputs,
79
+ decorated_operator_class=_PythonDecoratedOperator,
80
+ **kwargs,
81
+ )
@@ -0,0 +1,60 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ from __future__ import annotations
18
+
19
+ from typing import TYPE_CHECKING, Callable
20
+
21
+ from airflow.decorators.base import task_decorator_factory
22
+ from airflow.providers.standard.decorators.python import _PythonDecoratedOperator
23
+ from airflow.providers.standard.operators.python import PythonVirtualenvOperator
24
+
25
+ if TYPE_CHECKING:
26
+ from airflow.decorators.base import TaskDecorator
27
+
28
+
29
+ class _PythonVirtualenvDecoratedOperator(_PythonDecoratedOperator, PythonVirtualenvOperator):
30
+ """Wraps a Python callable and captures args/kwargs when called for execution."""
31
+
32
+ template_fields = PythonVirtualenvOperator.template_fields
33
+ custom_operator_name: str = "@task.virtualenv"
34
+
35
+
36
+ def virtualenv_task(
37
+ python_callable: Callable | None = None,
38
+ multiple_outputs: bool | None = None,
39
+ **kwargs,
40
+ ) -> TaskDecorator:
41
+ """
42
+ Wrap a callable into an Airflow operator to run via a Python virtual environment.
43
+
44
+ Accepts kwargs for operator kwarg. Can be reused in a single DAG.
45
+
46
+ This function is only used only used during type checking or auto-completion.
47
+
48
+ :meta private:
49
+
50
+ :param python_callable: Function to decorate
51
+ :param multiple_outputs: If set to True, the decorated function's return value will be unrolled to
52
+ multiple XCom values. Dict will unroll to XCom values with its keys as XCom keys.
53
+ Defaults to False.
54
+ """
55
+ return task_decorator_factory(
56
+ python_callable=python_callable,
57
+ multiple_outputs=multiple_outputs,
58
+ decorated_operator_class=_PythonVirtualenvDecoratedOperator,
59
+ **kwargs,
60
+ )
@@ -0,0 +1,76 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ from __future__ import annotations
19
+
20
+ from collections.abc import Sequence
21
+ from typing import TYPE_CHECKING, Callable, ClassVar
22
+
23
+ from airflow.decorators.base import get_unique_task_id, task_decorator_factory
24
+ from airflow.providers.standard.sensors.python import PythonSensor
25
+
26
+ if TYPE_CHECKING:
27
+ from airflow.decorators.base import TaskDecorator
28
+
29
+
30
+ class DecoratedSensorOperator(PythonSensor):
31
+ """
32
+ Wraps a Python callable and captures args/kwargs when called for execution.
33
+
34
+ :param python_callable: A reference to an object that is callable
35
+ :param task_id: task Id
36
+ :param op_args: a list of positional arguments that will get unpacked when
37
+ calling your callable (templated)
38
+ :param op_kwargs: a dictionary of keyword arguments that will get unpacked
39
+ in your function (templated)
40
+ :param kwargs_to_upstream: For certain operators, we might need to upstream certain arguments
41
+ that would otherwise be absorbed by the DecoratedOperator (for example python_callable for the
42
+ PythonOperator). This gives a user the option to upstream kwargs as needed.
43
+ """
44
+
45
+ template_fields: Sequence[str] = ("op_args", "op_kwargs")
46
+ template_fields_renderers: ClassVar[dict[str, str]] = {"op_args": "py", "op_kwargs": "py"}
47
+
48
+ custom_operator_name = "@task.sensor"
49
+
50
+ # since we won't mutate the arguments, we should just do the shallow copy
51
+ # there are some cases we can't deepcopy the objects (e.g protobuf).
52
+ shallow_copy_attrs: Sequence[str] = ("python_callable",)
53
+
54
+ def __init__(
55
+ self,
56
+ *,
57
+ task_id: str,
58
+ **kwargs,
59
+ ) -> None:
60
+ kwargs["task_id"] = get_unique_task_id(task_id, kwargs.get("dag"), kwargs.get("task_group"))
61
+ super().__init__(**kwargs)
62
+
63
+
64
+ def sensor_task(python_callable: Callable | None = None, **kwargs) -> TaskDecorator:
65
+ """
66
+ Wrap a function into an Airflow operator.
67
+
68
+ Accepts kwargs for operator kwarg. Can be reused in a single DAG.
69
+ :param python_callable: Function to decorate
70
+ """
71
+ return task_decorator_factory(
72
+ python_callable=python_callable,
73
+ multiple_outputs=False,
74
+ decorated_operator_class=DecoratedSensorOperator,
75
+ **kwargs,
76
+ )
@@ -0,0 +1,59 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ from __future__ import annotations
18
+
19
+ from typing import TYPE_CHECKING, Callable
20
+
21
+ from airflow.decorators.base import task_decorator_factory
22
+ from airflow.providers.standard.decorators.python import _PythonDecoratedOperator
23
+ from airflow.providers.standard.operators.python import ShortCircuitOperator
24
+
25
+ if TYPE_CHECKING:
26
+ from airflow.decorators.base import TaskDecorator
27
+
28
+
29
+ class _ShortCircuitDecoratedOperator(_PythonDecoratedOperator, ShortCircuitOperator):
30
+ """Wraps a Python callable and captures args/kwargs when called for execution."""
31
+
32
+ template_fields = ShortCircuitOperator.template_fields
33
+ custom_operator_name: str = "@task.short_circuit"
34
+
35
+
36
+ def short_circuit_task(
37
+ python_callable: Callable | None = None,
38
+ multiple_outputs: bool | None = None,
39
+ **kwargs,
40
+ ) -> TaskDecorator:
41
+ """
42
+ Wrap a function into an ShortCircuitOperator.
43
+
44
+ Accepts kwargs for operator kwarg. Can be reused in a single DAG.
45
+
46
+ This function is only used only used during type checking or auto-completion.
47
+
48
+ :param python_callable: Function to decorate
49
+ :param multiple_outputs: If set to True, the decorated function's return value will be unrolled to
50
+ multiple XCom values. Dict will unroll to XCom values with its keys as XCom keys. Defaults to False.
51
+
52
+ :meta private:
53
+ """
54
+ return task_decorator_factory(
55
+ python_callable=python_callable,
56
+ multiple_outputs=multiple_outputs,
57
+ decorated_operator_class=_ShortCircuitDecoratedOperator,
58
+ **kwargs,
59
+ )
@@ -106,6 +106,35 @@ def get_provider_info():
106
106
  },
107
107
  }
108
108
  },
109
+ "task-decorators": [
110
+ {"class-name": "airflow.providers.standard.decorators.python.python_task", "name": "python"},
111
+ {"class-name": "airflow.providers.standard.decorators.bash.bash_task", "name": "bash"},
112
+ {
113
+ "class-name": "airflow.providers.standard.decorators.branch_external_python.branch_external_python_task",
114
+ "name": "branch_external_python",
115
+ },
116
+ {
117
+ "class-name": "airflow.providers.standard.decorators.branch_python.branch_task",
118
+ "name": "branch",
119
+ },
120
+ {
121
+ "class-name": "airflow.providers.standard.decorators.branch_virtualenv.branch_virtualenv_task",
122
+ "name": "branch_virtualenv",
123
+ },
124
+ {
125
+ "class-name": "airflow.providers.standard.decorators.external_python.external_python_task",
126
+ "name": "external_python",
127
+ },
128
+ {
129
+ "class-name": "airflow.providers.standard.decorators.python_virtualenv.virtualenv_task",
130
+ "name": "virtualenv",
131
+ },
132
+ {"class-name": "airflow.providers.standard.decorators.sensor.sensor_task", "name": "sensor"},
133
+ {
134
+ "class-name": "airflow.providers.standard.decorators.short_circuit.short_circuit_task",
135
+ "name": "short_circuit",
136
+ },
137
+ ],
109
138
  "dependencies": ["apache-airflow>=2.9.0"],
110
139
  "devel-dependencies": [],
111
140
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apache-airflow-providers-standard
3
- Version: 0.3.0rc1
3
+ Version: 0.3.0rc2
4
4
  Summary: Provider package apache-airflow-providers-standard for Apache Airflow
5
5
  Keywords: airflow-provider,standard,airflow,integration
6
6
  Author-email: Apache Software Foundation <dev@airflow.apache.org>
@@ -1,7 +1,17 @@
1
1
  airflow/providers/standard/LICENSE,sha256=gXPVwptPlW1TJ4HSuG5OMPg-a3h43OGMkZRR1rpwfJA,10850
2
2
  airflow/providers/standard/__init__.py,sha256=84Hgrj5AurK3EjrkTXn2CChxmmQY0FCSNo6nzNwAxT0,1495
3
- airflow/providers/standard/get_provider_info.py,sha256=aq0vO2Gw7CjHS9d3pgBWN_Vb10JYU996DianpWgetQ0,5010
3
+ airflow/providers/standard/get_provider_info.py,sha256=L-tNd8ZwiC77cY0mDXdUyp29VQu0h5ChdXy-fdwBxnQ,6435
4
4
  airflow/providers/standard/version_compat.py,sha256=aHg90_DtgoSnQvILFICexMyNlHlALBdaeWqkX3dFDug,1605
5
+ airflow/providers/standard/decorators/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
6
+ airflow/providers/standard/decorators/bash.py,sha256=dknHzPFfVwiCrcC0FzMlGKoOMi66EaA9uKR3JSsitno,4128
7
+ airflow/providers/standard/decorators/branch_external_python.py,sha256=-z6JmLQrTzqQg2yqsdA91VPip52JeWp0Wnd9JDX_DeI,2352
8
+ airflow/providers/standard/decorators/branch_python.py,sha256=ornGzksOiTSbvAiCgthkZw4iJaMsNCnKBasWdOS8wfA,2272
9
+ airflow/providers/standard/decorators/branch_virtualenv.py,sha256=jcpxyoX86zXvzEJ8eIIf177EZZrt5TxoZbEum8blxI0,2354
10
+ airflow/providers/standard/decorators/external_python.py,sha256=6_K9kjLQJQFwcxqfW51BP9BwMZDrI9ihomsR4xftavk,2673
11
+ airflow/providers/standard/decorators/python.py,sha256=f-pl62ilgX45zvW6seCXKI0FoV3nypbWmjOIQauo6Y0,3219
12
+ airflow/providers/standard/decorators/python_virtualenv.py,sha256=CKzMtaQr9nK-e9APm7jtXmIdc-Qc-xIV13PymdbEJAM,2359
13
+ airflow/providers/standard/decorators/sensor.py,sha256=N2sKQl6xPop0gKnYWhtqnjl5yzSZa_56MQ7I5HrnG4Y,3004
14
+ airflow/providers/standard/decorators/short_circuit.py,sha256=xo4h8eoZ9UXJ_8IhEhvlWat_Q_w1Y6bJmEXcAvsKZlY,2301
5
15
  airflow/providers/standard/hooks/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
6
16
  airflow/providers/standard/hooks/filesystem.py,sha256=fDZwW_EYD8z1QXnReqI7gIwSbDPZNTKtqQvgktiP02o,2870
7
17
  airflow/providers/standard/hooks/package_index.py,sha256=U7_s_02-wwz9kTkzKr3JAhVQj2spuntWd_GmjfpV-y4,3769
@@ -35,7 +45,7 @@ airflow/providers/standard/utils/python_virtualenv_script.jinja2,sha256=3Z334hVq
35
45
  airflow/providers/standard/utils/sensor_helper.py,sha256=vrCdz4lY3Iy8Mom5KuyNidg-IAyngMRqWhStEXVsyT0,4692
36
46
  airflow/providers/standard/utils/skipmixin.py,sha256=XkhDozcXUHZ7C6AxzEW8ZYrqbra1oJGGR3ZieNQ-N0M,7791
37
47
  airflow/providers/standard/utils/weekday.py,sha256=ySDrIkWv-lqqxURo9E98IGInDqERec2O4y9o2hQTGiQ,2685
38
- apache_airflow_providers_standard-0.3.0rc1.dist-info/entry_points.txt,sha256=mW2YRh3mVdZdaP5-iGSNgmcCh3YYdALIn28BCLBZZ40,104
39
- apache_airflow_providers_standard-0.3.0rc1.dist-info/WHEEL,sha256=_2ozNFCLWc93bK4WKHCO-eDUENDlo-dgc9cU3qokYO4,82
40
- apache_airflow_providers_standard-0.3.0rc1.dist-info/METADATA,sha256=ZZOZzM_ekFj74kGaVoSnctN_TAJaBkRT3vKhdUYlFD8,3792
41
- apache_airflow_providers_standard-0.3.0rc1.dist-info/RECORD,,
48
+ apache_airflow_providers_standard-0.3.0rc2.dist-info/entry_points.txt,sha256=mW2YRh3mVdZdaP5-iGSNgmcCh3YYdALIn28BCLBZZ40,104
49
+ apache_airflow_providers_standard-0.3.0rc2.dist-info/WHEEL,sha256=_2ozNFCLWc93bK4WKHCO-eDUENDlo-dgc9cU3qokYO4,82
50
+ apache_airflow_providers_standard-0.3.0rc2.dist-info/METADATA,sha256=Nkhhr0r7FcXIMtjVOpZIYFUHH2NBrM8h8siVojyP398,3792
51
+ apache_airflow_providers_standard-0.3.0rc2.dist-info/RECORD,,