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 2021/01/26 11:39:49 UTC

[GitHub] [airflow] VBhojawala commented on pull request #13912: PythonOperator decorator @python_task

VBhojawala commented on pull request #13912:
URL: https://github.com/apache/airflow/pull/13912#issuecomment-767487249


   @task decorator currently does not support task ordering and does not returns PythonOperator instance.
   
   For example following dag will give
   
   ``` python
   from airflow.models import DAG
   import os
   
   from airflow.operators.python import PythonOperator, task
   from airflow.utils.dates import days_ago
   
   default_args = {'start_date': days_ago(1)}
   dag_name = os.path.splitext(os.path.basename(__file__))[0]
   
   
   @task
   def some_py_task(name):
       """ some py task """
       print(f'Inside Python Task name: {name}')
   
   
   def some_other_task(name):
       """ some other task"""
       print(f'Inside {name} Task')
   
   
   with DAG(dag_name, default_args=default_args) as dag:
   
       t1 = some_other_task('task1')
       t2 = some_other_task('task2')
   
       t3 = PythonOperator(python_callable=some_other_task, task_id='task3', op_args=['task3'])
   
       t1 >> t2 >> t3
   ```
   
   
   ![Screenshot from 2021-01-26 17-07-34](https://user-images.githubusercontent.com/11897651/105840504-20fed880-5ff9-11eb-8106-092fb8563610.png)
   


----------------------------------------------------------------
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