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/05/13 14:21:10 UTC

[GitHub] [airflow] ashb commented on a change in pull request #15822: Ensure that task preceeding a PythonVirtualenvOperator doesn't fail

ashb commented on a change in pull request #15822:
URL: https://github.com/apache/airflow/pull/15822#discussion_r631846609



##########
File path: airflow/models/dag.py
##########
@@ -1463,13 +1463,8 @@ def partial_subset(
         """
         # deep-copying self.task_dict and self._task_group takes a long time, and we don't want all
         # the tasks anyway, so we copy the tasks manually later
-        task_dict = self.task_dict
-        task_group = self._task_group
-        self.task_dict = {}
-        self._task_group = None  # type: ignore
-        dag = copy.deepcopy(self)
-        self.task_dict = task_dict
-        self._task_group = task_group
+        memo = {id(self.task_dict): None, id(self._task_group): None}
+        dag = copy.deepcopy(self, memo)  # type: ignore

Review comment:
       > Just for my sake of understanding, the args passed to memo are copied as it is instead of creating new copy of that object?
   
   Yes. `memo` is used so deepcopy can keep track of what it's already copied (mostly in the case of reference loops in objects etc)
   
   > Should we remove the comments on L1464 & L1465 now or update it to reflect the change?
   
   No, the comment is still appropriate and the copying is done on L1485 and L1513 (unchanged)




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