mik-laj commented on a change in pull request #4779: [AIRFLOW-3958] Support 
list tasks as upstream in chain
URL: https://github.com/apache/airflow/pull/4779#discussion_r264079684
 
 

 ##########
 File path: airflow/utils/helpers.py
 ##########
 @@ -154,19 +154,32 @@ def as_flattened_list(iterable):
 
 
 def chain(*tasks):
-    """
-    Given a number of tasks, builds a dependency chain.
+    r"""
+    Given a number of tasks or list of tasks, builds a dependency chain.
 
-    chain(task_1, task_2, task_3, task_4)
+    chain(task_1, [task_2, task_3], task_4, task_5)
 
     is equivalent to
 
+           / --> task_2 \
+    task_1               --> task_4 --> task_5
+           \ --> task_3 /
+
     task_1.set_downstream(task_2)
-    task_2.set_downstream(task_3)
+    task_1.set_downstream(task_3)
+    task_2.set_downstream(task_4)
     task_3.set_downstream(task_4)
+    task_4.set_downstream(task_5)
+
+    :param tasks: tasks or list of tasks
+    :type tasks: airflow.models.BaseOperator
     """
     for up_task, down_task in zip(tasks[:-1], tasks[1:]):
-        up_task.set_downstream(down_task)
+        if isinstance(up_task, list):
 
 Review comment:
   Is this necessary? According to the documentation for the `set_downstream` 
method, the parameter can be both one task and a task list.
   
http://airflow.apache.org/code.html#airflow.models.BaseOperator.set_downstream
   
   

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


With regards,
Apache Git Services

Reply via email to