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/08/31 07:02:21 UTC

[GitHub] [airflow] ephraimbuddy commented on a change in pull request #17927: Add example of TaskFlow to declare task dependencies

ephraimbuddy commented on a change in pull request #17927:
URL: https://github.com/apache/airflow/pull/17927#discussion_r699040163



##########
File path: docs/apache-airflow/concepts/tasks.rst
##########
@@ -36,16 +36,30 @@ Relationships
 
 The key part of using Tasks is defining how they relate to each other - their *dependencies*, or as we say in Airflow, their *upstream* and *downstream* tasks. You declare your Tasks first, and then you declare their dependencies second.
 
-There are two ways of declaring dependencies - using the ``>>`` and ``<<`` (bitshift) operators::
+There are three ways of declaring dependencies:
+
+Option 1: using the ``>>`` and ``<<`` (bitshift) operators::
 
     first_task >> second_task >> [third_task, fourth_task]
 
-Or the more explicit ``set_upstream`` and ``set_downstream`` methods::
+Option 2: The more explicit ``set_upstream`` and ``set_downstream`` methods::
 
     first_task.set_downstream(second_task)
     third_task.set_upstream(second_task)
-
-These both do exactly the same thing, but in general we recommend you use the bitshift operators, as they are easier to read in most cases.
+    
+Option 3: The @task decorator provided by TaskFlow API, see :ref:`concepts:taskflow`::
+
+    @task
+    def second_task(some_parameter):
+        ...
+    @task 
+    def first_task():
+        ...
+        
+    second_task(first_task()))
+    
+
+The former two do exactly the same thing and work on any type of Operator, but in general we recommend you use the bitshift operators, as they are easier to read in most cases. The TaskFlow API likewise connects dependencies between tasks, but is tailored to python functions written with the @task-decorator, note that the functions here are not executed inline, rather they are converted to tasks to be scheduled and sent to Executors, for more information see see :ref:`concepts:taskflow`.

Review comment:
       ```suggestion
   The former two do exactly the same thing and work on any type of Operator, but in general we recommend you use the bitshift operators, as they are easier to read in most cases. The TaskFlow API likewise connects dependencies between tasks, but is tailored to python functions written with the @task-decorator, note that the functions here are not executed inline, rather they are converted to tasks to be scheduled and sent to Executors, for more information see see :ref:`TaskFlow <concepts:taskflow>`.
   ```

##########
File path: docs/apache-airflow/concepts/tasks.rst
##########
@@ -36,16 +36,30 @@ Relationships
 
 The key part of using Tasks is defining how they relate to each other - their *dependencies*, or as we say in Airflow, their *upstream* and *downstream* tasks. You declare your Tasks first, and then you declare their dependencies second.
 
-There are two ways of declaring dependencies - using the ``>>`` and ``<<`` (bitshift) operators::
+There are three ways of declaring dependencies:
+
+Option 1: using the ``>>`` and ``<<`` (bitshift) operators::
 
     first_task >> second_task >> [third_task, fourth_task]
 
-Or the more explicit ``set_upstream`` and ``set_downstream`` methods::
+Option 2: The more explicit ``set_upstream`` and ``set_downstream`` methods::
 
     first_task.set_downstream(second_task)
     third_task.set_upstream(second_task)
-
-These both do exactly the same thing, but in general we recommend you use the bitshift operators, as they are easier to read in most cases.
+    
+Option 3: The @task decorator provided by TaskFlow API, see :ref:`concepts:taskflow`::
+
+    @task
+    def second_task(some_parameter):
+        ...
+    @task 
+    def first_task():
+        ...
+        
+    second_task(first_task()))

Review comment:
       ```suggestion
       second_task(first_task())
   ```




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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org