You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/04/02 02:56:37 UTC
[GitHub] [airflow] casassg opened a new issue #8057: [AIP-31] Create @task
decorator for functionally defined operators
casassg opened a new issue #8057: [AIP-31] Create @task decorator for functionally defined operators
URL: https://github.com/apache/airflow/issues/8057
**Description**
Add simple way to wrap a function into a PythonFunctionalOperator.
- Should be used without args or with args/kwargs for the underlying operator:
```
@task
def simple_task(...):
@task(dag=dag)
def simple_task(...):
```
- Task ID should be the function name by default.
- Should wrap the function so that autocomplete can still suggest parameters correctly.
Ways to use it:
- `@airflow.task:` [Lazy imported from main Airflow module](https://github.com/apache/airflow/pull/7517) (real location airflow.decorators.task). Makes function an operator, but does not automatically assign it to a DAG (unless declared inside a DAG context)
- `@dag.task:` As a partial function from DAG class. Task automatically assigned to DAG.
**Use case / motivation**
- Enable easy transformation of python functions into PythonFunctionalOperators by making a decorator that takes a function and converts it into a PythonFunctionalOperator.
**Related Issues**
Blocked by: #8056
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services