uranusjr commented on code in PR #23181:
URL: https://github.com/apache/airflow/pull/23181#discussion_r857270983


##########
airflow/models/dag.py:
##########
@@ -1984,15 +1987,18 @@ def partial_subset(
                 also_include.extend(t.get_flat_relatives(upstream=False))
             if include_upstream:
                 also_include.extend(t.get_flat_relatives(upstream=True))
-            elif include_direct_upstream:
+
+        direct_upstream: List[Operator] = []
+        if include_direct_upstream:
+            for t in matched_tasks + also_include:
                 upstream = (u for u in t.upstream_list if isinstance(u, 
(BaseOperator, MappedOperator)))
-                also_include.extend(upstream)
+                direct_upstream.extend(upstream)
 
         # Compiling the unique list of tasks that made the cut
         # Make sure to not recursively deepcopy the dag while copying the task
         dag.task_dict = {
             t.task_id: copy.deepcopy(t, {id(t.dag): dag})  # type: ignore
-            for t in matched_tasks + also_include
+            for t in matched_tasks + also_include + direct_upstream

Review Comment:
   We should use `itertools.chain` here.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to