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: A reference to an object that is callable :param op_kwargs: a dictionary of keyword arguments that will get unpacked in your function (templated) :param op_args: a list of positional arguments that will get unpacked when calling your callable (templated) :param multiple_outputs: if set, function return value will be unrolled to multiple XCom values. Dict will unroll to xcom values with keys as keys. Defaults to False. :return: """ # 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 python_task warnings.warn( """airflow.operators.python.task is deprecated. Please use the following instead from airflow.decorators import task @task def my_task()""", DeprecationWarning, stacklevel=2, ) return python_task(python_callable=python_callable, multiple_outputs=multiple_outputs, **kwargs)
def python(python_callable: Optional[Callable] = None, multiple_outputs: Optional[bool] = None, **kwargs): """ Python operator decorator. Wraps a function into an Airflow operator. Accepts kwargs for operator kwarg. This decorator can be reused in a single DAG. :param python_callable: Function to decorate :type python_callable: Optional[Callable] :param multiple_outputs: if set, function return value will be unrolled to multiple XCom values. List/Tuples will unroll to xcom values with index as key. Dict will unroll to xcom values with keys as XCom keys. Defaults to False. :type multiple_outputs: bool """ return python_task(python_callable=python_callable, multiple_outputs=multiple_outputs, **kwargs)