kaxil commented on a change in pull request #14709:
URL: https://github.com/apache/airflow/pull/14709#discussion_r593263170
##########
File path: airflow/operators/python.py
##########
@@ -15,32 +15,59 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-import functools
import inspect
import os
import pickle
-import re
import sys
import types
import warnings
-from inspect import signature
from tempfile import TemporaryDirectory
from textwrap import dedent
-from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple,
TypeVar, Union, cast
+from typing import Any, Callable, Dict, Iterable, List, Optional, Union
import dill
+# To maintain backwards compatibility, we import the task object into this file
+# This prevents breakages in dags that use `from airflow.operators.python
import task`
+from airflow.decorators.python import ( # noqa # pylint: disable=unused-import
+ PYTHON_OPERATOR_UI_COLOR,
+ python_task,
+)
from airflow.exceptions import AirflowException
from airflow.models import BaseOperator
-from airflow.models.dag import DAG, DagContext
from airflow.models.skipmixin import SkipMixin
from airflow.models.taskinstance import _CURRENT_CONTEXT
-from airflow.models.xcom_arg import XComArg
from airflow.utils.decorators import apply_defaults
from airflow.utils.operator_helpers import determine_kwargs
from airflow.utils.process_utils import execute_in_subprocess
from airflow.utils.python_virtualenv import prepare_virtualenv,
write_python_script
-from airflow.utils.task_group import TaskGroup, TaskGroupContext
+
+
+def task(python_callable: Optional[Callable] = None, multiple_outputs:
Optional[bool] = None, **kwargs):
+ """
+ Deprecated function that calls @task.python and allows users to turn a
python function into
+ an Airflow task. Please use the following instead:
+
+ from airflow.decorators import task
+
+ @task
+ def my_task()
+
+ @param python_callable:
+ @param multiple_outputs:
+ @param kwargs:
+ @return:
Review comment:
and please add description to them
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]