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/06/23 11:46:53 UTC

[GitHub] [airflow] buxizhizhoum commented on a change in pull request #16584: Modify models/dag.py to let it pass pylint check

buxizhizhoum commented on a change in pull request #16584:
URL: https://github.com/apache/airflow/pull/16584#discussion_r657015836



##########
File path: airflow/models/dag.py
##########
@@ -267,9 +266,10 @@ def __init__(
         jinja_environment_kwargs: Optional[Dict] = None,
         render_template_as_native_obj: bool = False,
         tags: Optional[List[str]] = None,
-    ):
+    ):  # pylint: disable=too-many-arguments,too-many-locals,too-many-statements
         from airflow.utils.task_group import TaskGroup
 
+        super().__init__()

Review comment:
       This is to suppress `super-init-not-called` error of pylint,  I think it might be better than disable pylint check?

##########
File path: airflow/models/dag.py
##########
@@ -1564,72 +1600,78 @@ def filter_task_group(group, parent_group):
             group.upstream_task_ids = group.upstream_task_ids.intersection(dag.task_dict.keys())
             group.downstream_task_ids = group.downstream_task_ids.intersection(dag.task_dict.keys())
 
-        for t in dag.tasks:
+        for task in dag.tasks:
             # Removing upstream/downstream references to tasks that did not
             # make the cut
-            t._upstream_task_ids = t.upstream_task_ids.intersection(dag.task_dict.keys())
-            t._downstream_task_ids = t.downstream_task_ids.intersection(dag.task_dict.keys())
+            task._upstream_task_ids = task.upstream_task_ids.intersection(dag.task_dict.keys())  # pylint: disable=protected-access
+            task._downstream_task_ids = task.downstream_task_ids.intersection(dag.task_dict.keys())  # pylint: disable=protected-access
 
         if len(dag.tasks) < len(self.tasks):
             dag.partial = True
 
         return dag
 
     def has_task(self, task_id: str):
+        """check whether task specified by task_id belongs to this dag"""
         return task_id in (t.task_id for t in self.tasks)
 
     def get_task(self, task_id: str, include_subdags: bool = False) -> BaseOperator:
+        """get task from dag"""
         if task_id in self.task_dict:
             return self.task_dict[task_id]
         if include_subdags:
-            for dag in self.subdags:
+            for dag in self.subdags:  # pylint: disable=redefined-outer-name
                 if task_id in dag.task_dict:
                     return dag.task_dict[task_id]
         raise TaskNotFound(f"Task {task_id} not found")
 
-    def pickle_info(self):
-        d = {}
-        d['is_picklable'] = True
-        try:
-            dttm = timezone.utcnow()
-            pickled = pickle.dumps(self)
-            d['pickle_len'] = len(pickled)
-            d['pickling_duration'] = str(timezone.utcnow() - dttm)
-        except Exception as e:
-            self.log.debug(e)
-            d['is_picklable'] = False
-            d['stacktrace'] = traceback.format_exc()
-        return d
+    # def pickle_info(self):
+    #     d = {}
+    #     d['is_picklable'] = True
+    #     try:
+    #         dttm = timezone.utcnow()
+    #         pickled = pickle.dumps(self)
+    #         d['pickle_len'] = len(pickled)
+    #         d['pickling_duration'] = str(timezone.utcnow() - dttm)
+    #     except Exception as e:
+    #         self.log.debug(e)
+    #         d['is_picklable'] = False
+    #         d['stacktrace'] = traceback.format_exc()
+    #     return d

Review comment:
       I searched the project, it seems that this method is not used already, Or may be I am wrong?




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