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 2020/08/06 21:27:07 UTC

[GitHub] [airflow] potiuk opened a new pull request #10207: Pylint checks should be way faster now

potiuk opened a new pull request #10207:
URL: https://github.com/apache/airflow/pull/10207


   Instead of running separate pylint checks for tests and main source
   we are running a single check now. This is possible thanks to a
   nice hack - we have pylint plugin that injects the right
   "# pylint: disable=" comment for all test files while reading
   the file content by astroid (just before tokenization)
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   


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



[GitHub] [airflow] potiuk commented on a change in pull request #10207: Pylint checks should be way faster now

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #10207:
URL: https://github.com/apache/airflow/pull/10207#discussion_r466883568



##########
File path: tests/airflow_pylint/disable_checks_for_tests.py
##########
@@ -0,0 +1,60 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+from astroid import MANAGER, scoped_nodes
+from pylint.lint import PyLinter
+
+DISABLED_CHECKS_FOR_TESTS = \
+    "missing-docstring, no-self-use, too-many-public-methods, protected-access, do-not-use-asserts"
+
+
+def register(_: PyLinter):
+    """
+    Skip registering any plugin. This is not a real plugin - we only need it to register transform before
+    running pylint.
+
+    :param _:
+    :return:
+    """
+
+
+def transform(mod):
+    """
+    It's a small hack but one that gives us a lot of speedup in pylint tests. We are replacing the first
+    line of the file with pylint-disable (or update existing one) when file name start with `test_` or
+    (for providers) when it is the full path of the package (both cases occur in pylint)
+
+    :param mod: astroid module
+    :return: None
+    """
+    if mod.name.startswith("test_") or \
+            mod.name.startswith("tests.") or \
+            mod.name.startswith("kubernetes_tests."):
+        decoded_lines = mod.stream().read().decode("utf-8").split("\n")
+        if decoded_lines[0].startswith("# pylint: disable="):
+            decoded_lines[0] = decoded_lines[0] + " " + DISABLED_CHECKS_FOR_TESTS
+        elif decoded_lines[0].startswith("#") or decoded_lines[0].strip() == "":
+            decoded_lines[0] = "# pylint: disable=" + DISABLED_CHECKS_FOR_TESTS
+        else:
+            raise Exception(f"The first line of module {mod.name} is not a comment or empty. "
+                            f"Please make sure it is!")
+        # pylint will read from `.file_bytes` attribute later when tokenization
+        mod.file_bytes = "\n".join(decoded_lines).encode("utf-8")
+
+
+MANAGER.register_transform(scoped_nodes.Module, transform)

Review comment:
       This is exactly what we did before and that was a pain.  It took almost 2 x time than this one.
   This is a huge optimization, that's why I did it.
   
   The problem is that when you run pylint for tests, it also pulls in all the tested code which means that basically a lot of the main airflow code was parsed and processed twice - once in the "pylint main" and once in the "pylint tests". This code was not verified by Pylint but it was parsed and analyzed so that the test code could be pylint-checked so it's not a full duplication, but I thin the savings are significant
   
   Some random stats:
   
   Before the change:
   
   pylint main: 6m 20s 
   pylint tests: 3:59s 
   
   Tota: 10m 20s
   
   After the change: 
   combined pylint: 8:20s
   
   
   So we save 20% of elapsed time by doing this.
   
   
   

##########
File path: tests/airflow_pylint/disable_checks_for_tests.py
##########
@@ -0,0 +1,60 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+from astroid import MANAGER, scoped_nodes
+from pylint.lint import PyLinter
+
+DISABLED_CHECKS_FOR_TESTS = \
+    "missing-docstring, no-self-use, too-many-public-methods, protected-access, do-not-use-asserts"
+
+
+def register(_: PyLinter):
+    """
+    Skip registering any plugin. This is not a real plugin - we only need it to register transform before
+    running pylint.
+
+    :param _:
+    :return:
+    """
+
+
+def transform(mod):
+    """
+    It's a small hack but one that gives us a lot of speedup in pylint tests. We are replacing the first
+    line of the file with pylint-disable (or update existing one) when file name start with `test_` or
+    (for providers) when it is the full path of the package (both cases occur in pylint)
+
+    :param mod: astroid module
+    :return: None
+    """
+    if mod.name.startswith("test_") or \
+            mod.name.startswith("tests.") or \
+            mod.name.startswith("kubernetes_tests."):
+        decoded_lines = mod.stream().read().decode("utf-8").split("\n")
+        if decoded_lines[0].startswith("# pylint: disable="):
+            decoded_lines[0] = decoded_lines[0] + " " + DISABLED_CHECKS_FOR_TESTS
+        elif decoded_lines[0].startswith("#") or decoded_lines[0].strip() == "":
+            decoded_lines[0] = "# pylint: disable=" + DISABLED_CHECKS_FOR_TESTS
+        else:
+            raise Exception(f"The first line of module {mod.name} is not a comment or empty. "
+                            f"Please make sure it is!")
+        # pylint will read from `.file_bytes` attribute later when tokenization
+        mod.file_bytes = "\n".join(decoded_lines).encode("utf-8")
+
+
+MANAGER.register_transform(scoped_nodes.Module, transform)

Review comment:
       This is exactly what we did before and that was a pain.  It took almost 2 x time than this one.
   This is a huge optimization, that's why I did it.
   
   The problem is that when you run pylint for tests, it also pulls in all the tested code which means that basically a lot of the main airflow code was parsed and processed twice - once in the "pylint main" and once in the "pylint tests". This code was not verified by Pylint but it was parsed and analyzed so that the test code could be pylint-checked so it's not a full duplication, but I think the savings are significant
   
   Some random stats:
   
   Before the change:
   
   pylint main: 6m 20s 
   pylint tests: 3:59s 
   
   Tota: 10m 20s
   
   After the change: 
   combined pylint: 8:20s
   
   
   So we save 20% of elapsed time by doing this.
   
   
   




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



[GitHub] [airflow] turbaszek commented on a change in pull request #10207: Pylint checks should be way faster now

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #10207:
URL: https://github.com/apache/airflow/pull/10207#discussion_r466826926



##########
File path: tests/airflow_pylint/disable_checks_for_tests.py
##########
@@ -0,0 +1,60 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+from astroid import MANAGER, scoped_nodes
+from pylint.lint import PyLinter
+
+DISABLED_CHECKS_FOR_TESTS = \
+    "missing-docstring, no-self-use, too-many-public-methods, protected-access, do-not-use-asserts"
+
+
+def register(_: PyLinter):
+    """
+    Skip registering any plugin. This is not a real plugin - we only need it to register transform before
+    running pylint.
+
+    :param _:
+    :return:
+    """
+
+
+def transform(mod):
+    """
+    It's a small hack but one that gives us a lot of speedup in pylint tests. We are replacing the first
+    line of the file with pylint-disable (or update existing one) when file name start with `test_` or
+    (for providers) when it is the full path of the package (both cases occur in pylint)
+
+    :param mod: astroid module
+    :return: None
+    """
+    if mod.name.startswith("test_") or \
+            mod.name.startswith("tests.") or \
+            mod.name.startswith("kubernetes_tests."):
+        decoded_lines = mod.stream().read().decode("utf-8").split("\n")
+        if decoded_lines[0].startswith("# pylint: disable="):
+            decoded_lines[0] = decoded_lines[0] + " " + DISABLED_CHECKS_FOR_TESTS
+        elif decoded_lines[0].startswith("#") or decoded_lines[0].strip() == "":
+            decoded_lines[0] = "# pylint: disable=" + DISABLED_CHECKS_FOR_TESTS
+        else:
+            raise Exception(f"The first line of module {mod.name} is not a comment or empty. "
+                            f"Please make sure it is!")
+        # pylint will read from `.file_bytes` attribute later when tokenization
+        mod.file_bytes = "\n".join(decoded_lines).encode("utf-8")
+
+
+MANAGER.register_transform(scoped_nodes.Module, transform)

Review comment:
       I'm just wondering if we can first run pylint for main sources and then, just add additional disables to `pylintrc`? Not sure if this will be simpler




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



[GitHub] [airflow] potiuk commented on a change in pull request #10207: Pylint checks should be way faster now

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #10207:
URL: https://github.com/apache/airflow/pull/10207#discussion_r466883568



##########
File path: tests/airflow_pylint/disable_checks_for_tests.py
##########
@@ -0,0 +1,60 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+from astroid import MANAGER, scoped_nodes
+from pylint.lint import PyLinter
+
+DISABLED_CHECKS_FOR_TESTS = \
+    "missing-docstring, no-self-use, too-many-public-methods, protected-access, do-not-use-asserts"
+
+
+def register(_: PyLinter):
+    """
+    Skip registering any plugin. This is not a real plugin - we only need it to register transform before
+    running pylint.
+
+    :param _:
+    :return:
+    """
+
+
+def transform(mod):
+    """
+    It's a small hack but one that gives us a lot of speedup in pylint tests. We are replacing the first
+    line of the file with pylint-disable (or update existing one) when file name start with `test_` or
+    (for providers) when it is the full path of the package (both cases occur in pylint)
+
+    :param mod: astroid module
+    :return: None
+    """
+    if mod.name.startswith("test_") or \
+            mod.name.startswith("tests.") or \
+            mod.name.startswith("kubernetes_tests."):
+        decoded_lines = mod.stream().read().decode("utf-8").split("\n")
+        if decoded_lines[0].startswith("# pylint: disable="):
+            decoded_lines[0] = decoded_lines[0] + " " + DISABLED_CHECKS_FOR_TESTS
+        elif decoded_lines[0].startswith("#") or decoded_lines[0].strip() == "":
+            decoded_lines[0] = "# pylint: disable=" + DISABLED_CHECKS_FOR_TESTS
+        else:
+            raise Exception(f"The first line of module {mod.name} is not a comment or empty. "
+                            f"Please make sure it is!")
+        # pylint will read from `.file_bytes` attribute later when tokenization
+        mod.file_bytes = "\n".join(decoded_lines).encode("utf-8")
+
+
+MANAGER.register_transform(scoped_nodes.Module, transform)

Review comment:
       This is exactly what we did before and that was a pain.  It took almost 2 x time than this one.
   This is a huge optimization, that's why I did it.
   
   The problem is that when you run pylint for tests, it also pulls in all the tested code which means that basically a lot of the main airflow code was parsed and processed twice - once in the "pylint main" and once in the "pylint tests". This code was not verified by Pylint but it was parsed and analyzed so that the test code could be pylint-checked so it's not a full duplication, but I think the savings are significant
   
   Some random stats:
   
   Before the change:
   
   pylint main: 6m 20s 
   pylint tests: 3:59s 
   
   Tota: 10m 20s
   
   After the change: 
   combined pylint: 8:20s
   
   
   So we save 20% (2 minutes) of elapsed time by doing this.
   
   
   




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



[GitHub] [airflow] codecov-commenter commented on pull request #10207: Pylint checks should be way faster now

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #10207:
URL: https://github.com/apache/airflow/pull/10207#issuecomment-670236880


   # [Codecov](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=h1) Report
   > Merging [#10207](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=desc) into [master](https://codecov.io/gh/apache/airflow/commit/d79e7221de76f01b5cd36c15224b59e8bb451c90&el=desc) will **decrease** coverage by `49.50%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/airflow/pull/10207/graphs/tree.svg?width=650&height=150&src=pr&token=WdLKlKHOAU)](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #10207       +/-   ##
   ===========================================
   - Coverage   89.41%   39.91%   -49.51%     
   ===========================================
     Files        1037     1037               
     Lines       50011    49724      -287     
   ===========================================
   - Hits        44717    19846    -24871     
   - Misses       5294    29878    +24584     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | #kubernetes-tests-3.6-9.6 | `39.91% <ø> (+<0.01%)` | :arrow_up: |
   | #kubernetes-tests-image-3.6-v1.16.9 | `?` | |
   | #kubernetes-tests-image-3.6-v1.17.5 | `?` | |
   | #kubernetes-tests-image-3.6-v1.18.6 | `?` | |
   | #kubernetes-tests-image-3.7-v1.16.9 | `?` | |
   | #kubernetes-tests-image-3.7-v1.17.5 | `?` | |
   | #kubernetes-tests-image-3.7-v1.18.6 | `?` | |
   | #mysql-tests-Core-3.7-5.7 | `?` | |
   | #mysql-tests-Core-3.8-5.7 | `?` | |
   | #mysql-tests-Integration-3.7-5.7 | `?` | |
   | #mysql-tests-Integration-3.8-5.7 | `?` | |
   | #postgres-tests-Core-3.6-10 | `?` | |
   | #postgres-tests-Core-3.6-9.6 | `?` | |
   | #postgres-tests-Core-3.7-10 | `?` | |
   | #postgres-tests-Core-3.7-9.6 | `?` | |
   | #postgres-tests-Integration-3.6-10 | `?` | |
   | #postgres-tests-Integration-3.6-9.6 | `?` | |
   | #postgres-tests-Integration-3.7-10 | `?` | |
   | #postgres-tests-Integration-3.7-9.6 | `?` | |
   | #sqlite-tests-Core-3.6 | `?` | |
   | #sqlite-tests-Core-3.8 | `?` | |
   | #sqlite-tests-Integration-3.6 | `?` | |
   | #sqlite-tests-Integration-3.8 | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [airflow/hooks/S3\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9TM19ob29rLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/pig\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9waWdfaG9vay5weQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/hdfs\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9oZGZzX2hvb2sucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/http\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9odHRwX2hvb2sucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/jdbc\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9qZGJjX2hvb2sucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/contrib/\_\_init\_\_.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL19faW5pdF9fLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/druid\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9kcnVpZF9ob29rLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/hive\_hooks.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9oaXZlX2hvb2tzLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/mssql\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9tc3NxbF9ob29rLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/mysql\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9teXNxbF9ob29rLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | ... and [911 more](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=footer). Last update [d79e722...f402c40](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


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



[GitHub] [airflow] potiuk commented on a change in pull request #10207: Pylint checks should be way faster now

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #10207:
URL: https://github.com/apache/airflow/pull/10207#discussion_r466883568



##########
File path: tests/airflow_pylint/disable_checks_for_tests.py
##########
@@ -0,0 +1,60 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+from astroid import MANAGER, scoped_nodes
+from pylint.lint import PyLinter
+
+DISABLED_CHECKS_FOR_TESTS = \
+    "missing-docstring, no-self-use, too-many-public-methods, protected-access, do-not-use-asserts"
+
+
+def register(_: PyLinter):
+    """
+    Skip registering any plugin. This is not a real plugin - we only need it to register transform before
+    running pylint.
+
+    :param _:
+    :return:
+    """
+
+
+def transform(mod):
+    """
+    It's a small hack but one that gives us a lot of speedup in pylint tests. We are replacing the first
+    line of the file with pylint-disable (or update existing one) when file name start with `test_` or
+    (for providers) when it is the full path of the package (both cases occur in pylint)
+
+    :param mod: astroid module
+    :return: None
+    """
+    if mod.name.startswith("test_") or \
+            mod.name.startswith("tests.") or \
+            mod.name.startswith("kubernetes_tests."):
+        decoded_lines = mod.stream().read().decode("utf-8").split("\n")
+        if decoded_lines[0].startswith("# pylint: disable="):
+            decoded_lines[0] = decoded_lines[0] + " " + DISABLED_CHECKS_FOR_TESTS
+        elif decoded_lines[0].startswith("#") or decoded_lines[0].strip() == "":
+            decoded_lines[0] = "# pylint: disable=" + DISABLED_CHECKS_FOR_TESTS
+        else:
+            raise Exception(f"The first line of module {mod.name} is not a comment or empty. "
+                            f"Please make sure it is!")
+        # pylint will read from `.file_bytes` attribute later when tokenization
+        mod.file_bytes = "\n".join(decoded_lines).encode("utf-8")
+
+
+MANAGER.register_transform(scoped_nodes.Module, transform)

Review comment:
       This is exactly what we did before and that was a pain.  It took almost 2 x time than this one.
   This is a huge optimization, that's why I did it.
   
   The problem is that when you run pylint for tests, it also pulls in all the tested code which means that basically a lot of the main airflow code was parsed and processed twice - once in the "pylint main" and once in the "pylint tests". This code was not verified by Pylint but it was parsed and analyzed so that the test code could be tested so it's not a full duplication, but I thin the savings are significant
   
   Some random stats:
   
   Before the change:
   
   pylint main: 6m 20s 
   pylint tests: 3:59s 
   
   Tota: 10m 20s
   
   After the change: 
   combined pylint: 8:20s
   
   
   So we save 20% of elapsed time by doing this.
   
   
   




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



[GitHub] [airflow] potiuk commented on a change in pull request #10207: Pylint checks should be way faster now

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #10207:
URL: https://github.com/apache/airflow/pull/10207#discussion_r466884962



##########
File path: tests/dags/test_logging_in_dag.py
##########
@@ -25,6 +25,11 @@
 
 
 def test_logging_fn(**kwargs):
+    """
+    Tests DAG logging.
+    :param kwargs:
+    :return:
+    """

Review comment:
       Yep. I had to fix it. Pylint is not 100% deterministic and if you analyze it all together it detects some errors that were not reported before. 




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



[GitHub] [airflow] potiuk merged pull request #10207: Pylint checks should be way faster now

Posted by GitBox <gi...@apache.org>.
potiuk merged pull request #10207:
URL: https://github.com/apache/airflow/pull/10207


   


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



[GitHub] [airflow] potiuk commented on a change in pull request #10207: Pylint checks should be way faster now

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #10207:
URL: https://github.com/apache/airflow/pull/10207#discussion_r466883568



##########
File path: tests/airflow_pylint/disable_checks_for_tests.py
##########
@@ -0,0 +1,60 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+from astroid import MANAGER, scoped_nodes
+from pylint.lint import PyLinter
+
+DISABLED_CHECKS_FOR_TESTS = \
+    "missing-docstring, no-self-use, too-many-public-methods, protected-access, do-not-use-asserts"
+
+
+def register(_: PyLinter):
+    """
+    Skip registering any plugin. This is not a real plugin - we only need it to register transform before
+    running pylint.
+
+    :param _:
+    :return:
+    """
+
+
+def transform(mod):
+    """
+    It's a small hack but one that gives us a lot of speedup in pylint tests. We are replacing the first
+    line of the file with pylint-disable (or update existing one) when file name start with `test_` or
+    (for providers) when it is the full path of the package (both cases occur in pylint)
+
+    :param mod: astroid module
+    :return: None
+    """
+    if mod.name.startswith("test_") or \
+            mod.name.startswith("tests.") or \
+            mod.name.startswith("kubernetes_tests."):
+        decoded_lines = mod.stream().read().decode("utf-8").split("\n")
+        if decoded_lines[0].startswith("# pylint: disable="):
+            decoded_lines[0] = decoded_lines[0] + " " + DISABLED_CHECKS_FOR_TESTS
+        elif decoded_lines[0].startswith("#") or decoded_lines[0].strip() == "":
+            decoded_lines[0] = "# pylint: disable=" + DISABLED_CHECKS_FOR_TESTS
+        else:
+            raise Exception(f"The first line of module {mod.name} is not a comment or empty. "
+                            f"Please make sure it is!")
+        # pylint will read from `.file_bytes` attribute later when tokenization
+        mod.file_bytes = "\n".join(decoded_lines).encode("utf-8")
+
+
+MANAGER.register_transform(scoped_nodes.Module, transform)

Review comment:
       This is exactly what we did before and that was a pain.  It took much more  time than this one.
   This is a huge optimization, that's why I did it.
   
   The problem is that when you run pylint for tests, it also pulls in all the tested code which means that basically a lot of the main airflow code was parsed and processed twice - once in the "pylint main" and once in the "pylint tests". This code was not verified by Pylint but it was parsed and analyzed so that the test code could be pylint-checked so it's not a full duplication, but I think the savings are significant
   
   Some random stats:
   
   Before the change:
   
   pylint main: 6:20s 
   pylint tests: 3:59s 
   
   Tota: 10m 20s
   
   After the change: 
   combined pylint: 8:20s
   
   
   So we save 20% (2 minutes) of elapsed time by doing this.
   
   
   




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



[GitHub] [airflow] turbaszek commented on a change in pull request #10207: Pylint checks should be way faster now

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #10207:
URL: https://github.com/apache/airflow/pull/10207#discussion_r466826723



##########
File path: tests/dags/test_logging_in_dag.py
##########
@@ -25,6 +25,11 @@
 
 
 def test_logging_fn(**kwargs):
+    """
+    Tests DAG logging.
+    :param kwargs:
+    :return:
+    """

Review comment:
       Is this related?




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



[GitHub] [airflow] codecov-commenter edited a comment on pull request #10207: Pylint checks should be way faster now

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #10207:
URL: https://github.com/apache/airflow/pull/10207#issuecomment-670236880


   # [Codecov](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=h1) Report
   > Merging [#10207](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=desc) into [master](https://codecov.io/gh/apache/airflow/commit/d79e7221de76f01b5cd36c15224b59e8bb451c90&el=desc) will **decrease** coverage by `54.30%`.
   > The diff coverage is `100.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/airflow/pull/10207/graphs/tree.svg?width=650&height=150&src=pr&token=WdLKlKHOAU)](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #10207       +/-   ##
   ===========================================
   - Coverage   89.41%   35.10%   -54.31%     
   ===========================================
     Files        1037     1037               
     Lines       50011    50013        +2     
   ===========================================
   - Hits        44717    17558    -27159     
   - Misses       5294    32455    +27161     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | #kubernetes-tests-3.6-9.6 | `?` | |
   | #kubernetes-tests-image-3.6-v1.16.9 | `?` | |
   | #kubernetes-tests-image-3.6-v1.17.5 | `?` | |
   | #kubernetes-tests-image-3.6-v1.18.6 | `?` | |
   | #kubernetes-tests-image-3.7-v1.16.9 | `?` | |
   | #kubernetes-tests-image-3.7-v1.17.5 | `?` | |
   | #kubernetes-tests-image-3.7-v1.18.6 | `?` | |
   | #mysql-tests-Core-3.7-5.7 | `?` | |
   | #mysql-tests-Core-3.8-5.7 | `?` | |
   | #mysql-tests-Integration-3.7-5.7 | `34.75% <100.00%> (+<0.01%)` | :arrow_up: |
   | #mysql-tests-Integration-3.8-5.7 | `35.01% <100.00%> (+<0.01%)` | :arrow_up: |
   | #postgres-tests-Core-3.6-10 | `?` | |
   | #postgres-tests-Core-3.6-9.6 | `?` | |
   | #postgres-tests-Core-3.7-10 | `?` | |
   | #postgres-tests-Core-3.7-9.6 | `?` | |
   | #postgres-tests-Integration-3.6-10 | `?` | |
   | #postgres-tests-Integration-3.6-9.6 | `34.73% <100.00%> (+<0.01%)` | :arrow_up: |
   | #postgres-tests-Integration-3.7-10 | `?` | |
   | #postgres-tests-Integration-3.7-9.6 | `?` | |
   | #sqlite-tests-Core-3.6 | `?` | |
   | #sqlite-tests-Core-3.8 | `?` | |
   | #sqlite-tests-Integration-3.6 | `?` | |
   | #sqlite-tests-Integration-3.8 | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [airflow/jobs/scheduler\_job.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9qb2JzL3NjaGVkdWxlcl9qb2IucHk=) | `16.39% <100.00%> (-74.25%)` | :arrow_down: |
   | [airflow/hooks/S3\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9TM19ob29rLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/pig\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9waWdfaG9vay5weQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/hdfs\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9oZGZzX2hvb2sucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/http\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9odHRwX2hvb2sucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/jdbc\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9qZGJjX2hvb2sucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/contrib/\_\_init\_\_.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL19faW5pdF9fLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/druid\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9kcnVpZF9ob29rLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/hive\_hooks.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9oaXZlX2hvb2tzLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/mssql\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9tc3NxbF9ob29rLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | ... and [906 more](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=footer). Last update [d79e722...2b57575](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


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



[GitHub] [airflow] codecov-commenter edited a comment on pull request #10207: Pylint checks should be way faster now

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #10207:
URL: https://github.com/apache/airflow/pull/10207#issuecomment-670236880


   # [Codecov](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=h1) Report
   > Merging [#10207](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=desc) into [master](https://codecov.io/gh/apache/airflow/commit/d79e7221de76f01b5cd36c15224b59e8bb451c90&el=desc) will **decrease** coverage by `54.39%`.
   > The diff coverage is `100.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/airflow/pull/10207/graphs/tree.svg?width=650&height=150&src=pr&token=WdLKlKHOAU)](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #10207       +/-   ##
   ===========================================
   - Coverage   89.41%   35.01%   -54.40%     
   ===========================================
     Files        1037     1037               
     Lines       50011    49961       -50     
   ===========================================
   - Hits        44717    17494    -27223     
   - Misses       5294    32467    +27173     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | #kubernetes-tests-3.6-9.6 | `?` | |
   | #kubernetes-tests-image-3.6-v1.16.9 | `?` | |
   | #kubernetes-tests-image-3.6-v1.17.5 | `?` | |
   | #kubernetes-tests-image-3.6-v1.18.6 | `?` | |
   | #kubernetes-tests-image-3.7-v1.16.9 | `?` | |
   | #kubernetes-tests-image-3.7-v1.17.5 | `?` | |
   | #kubernetes-tests-image-3.7-v1.18.6 | `?` | |
   | #mysql-tests-Core-3.7-5.7 | `?` | |
   | #mysql-tests-Core-3.8-5.7 | `?` | |
   | #mysql-tests-Integration-3.7-5.7 | `?` | |
   | #mysql-tests-Integration-3.8-5.7 | `35.01% <100.00%> (+<0.01%)` | :arrow_up: |
   | #postgres-tests-Core-3.6-10 | `?` | |
   | #postgres-tests-Core-3.6-9.6 | `?` | |
   | #postgres-tests-Core-3.7-10 | `?` | |
   | #postgres-tests-Core-3.7-9.6 | `?` | |
   | #postgres-tests-Integration-3.6-10 | `?` | |
   | #postgres-tests-Integration-3.6-9.6 | `?` | |
   | #postgres-tests-Integration-3.7-10 | `?` | |
   | #postgres-tests-Integration-3.7-9.6 | `?` | |
   | #sqlite-tests-Core-3.6 | `?` | |
   | #sqlite-tests-Core-3.8 | `?` | |
   | #sqlite-tests-Integration-3.6 | `?` | |
   | #sqlite-tests-Integration-3.8 | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [airflow/jobs/scheduler\_job.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9qb2JzL3NjaGVkdWxlcl9qb2IucHk=) | `16.41% <100.00%> (-74.22%)` | :arrow_down: |
   | [airflow/hooks/S3\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9TM19ob29rLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/pig\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9waWdfaG9vay5weQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/hdfs\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9oZGZzX2hvb2sucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/http\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9odHRwX2hvb2sucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/jdbc\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9qZGJjX2hvb2sucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/contrib/\_\_init\_\_.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL19faW5pdF9fLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/druid\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9kcnVpZF9ob29rLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/hive\_hooks.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9oaXZlX2hvb2tzLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/mssql\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9tc3NxbF9ob29rLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | ... and [912 more](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=footer). Last update [d79e722...2b57575](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


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



[GitHub] [airflow] codecov-commenter edited a comment on pull request #10207: Pylint checks should be way faster now

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #10207:
URL: https://github.com/apache/airflow/pull/10207#issuecomment-670236880


   # [Codecov](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=h1) Report
   > Merging [#10207](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=desc) into [master](https://codecov.io/gh/apache/airflow/commit/d79e7221de76f01b5cd36c15224b59e8bb451c90&el=desc) will **decrease** coverage by `54.29%`.
   > The diff coverage is `100.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/airflow/pull/10207/graphs/tree.svg?width=650&height=150&src=pr&token=WdLKlKHOAU)](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #10207       +/-   ##
   ===========================================
   - Coverage   89.41%   35.11%   -54.30%     
   ===========================================
     Files        1037     1037               
     Lines       50011    50013        +2     
   ===========================================
   - Hits        44717    17562    -27155     
   - Misses       5294    32451    +27157     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | #kubernetes-tests-3.6-9.6 | `?` | |
   | #kubernetes-tests-image-3.6-v1.16.9 | `?` | |
   | #kubernetes-tests-image-3.6-v1.17.5 | `?` | |
   | #kubernetes-tests-image-3.6-v1.18.6 | `?` | |
   | #kubernetes-tests-image-3.7-v1.16.9 | `?` | |
   | #kubernetes-tests-image-3.7-v1.17.5 | `?` | |
   | #kubernetes-tests-image-3.7-v1.18.6 | `?` | |
   | #mysql-tests-Core-3.7-5.7 | `?` | |
   | #mysql-tests-Core-3.8-5.7 | `?` | |
   | #mysql-tests-Integration-3.7-5.7 | `34.75% <100.00%> (+<0.01%)` | :arrow_up: |
   | #mysql-tests-Integration-3.8-5.7 | `35.01% <100.00%> (+<0.01%)` | :arrow_up: |
   | #postgres-tests-Core-3.6-10 | `?` | |
   | #postgres-tests-Core-3.6-9.6 | `?` | |
   | #postgres-tests-Core-3.7-10 | `?` | |
   | #postgres-tests-Core-3.7-9.6 | `?` | |
   | #postgres-tests-Integration-3.6-10 | `?` | |
   | #postgres-tests-Integration-3.6-9.6 | `34.73% <100.00%> (+<0.01%)` | :arrow_up: |
   | #postgres-tests-Integration-3.7-10 | `?` | |
   | #postgres-tests-Integration-3.7-9.6 | `?` | |
   | #sqlite-tests-Core-3.6 | `?` | |
   | #sqlite-tests-Core-3.8 | `?` | |
   | #sqlite-tests-Integration-3.6 | `34.18% <100.00%> (+<0.01%)` | :arrow_up: |
   | #sqlite-tests-Integration-3.8 | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [airflow/jobs/scheduler\_job.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9qb2JzL3NjaGVkdWxlcl9qb2IucHk=) | `16.39% <100.00%> (-74.25%)` | :arrow_down: |
   | [airflow/hooks/S3\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9TM19ob29rLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/pig\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9waWdfaG9vay5weQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/hdfs\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9oZGZzX2hvb2sucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/http\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9odHRwX2hvb2sucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/jdbc\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9qZGJjX2hvb2sucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/contrib/\_\_init\_\_.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL19faW5pdF9fLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/druid\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9kcnVpZF9ob29rLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/hive\_hooks.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9oaXZlX2hvb2tzLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/mssql\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9tc3NxbF9ob29rLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | ... and [906 more](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=footer). Last update [d79e722...2b57575](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


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



[GitHub] [airflow] potiuk commented on a change in pull request #10207: Pylint checks should be way faster now

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #10207:
URL: https://github.com/apache/airflow/pull/10207#discussion_r466883568



##########
File path: tests/airflow_pylint/disable_checks_for_tests.py
##########
@@ -0,0 +1,60 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+from astroid import MANAGER, scoped_nodes
+from pylint.lint import PyLinter
+
+DISABLED_CHECKS_FOR_TESTS = \
+    "missing-docstring, no-self-use, too-many-public-methods, protected-access, do-not-use-asserts"
+
+
+def register(_: PyLinter):
+    """
+    Skip registering any plugin. This is not a real plugin - we only need it to register transform before
+    running pylint.
+
+    :param _:
+    :return:
+    """
+
+
+def transform(mod):
+    """
+    It's a small hack but one that gives us a lot of speedup in pylint tests. We are replacing the first
+    line of the file with pylint-disable (or update existing one) when file name start with `test_` or
+    (for providers) when it is the full path of the package (both cases occur in pylint)
+
+    :param mod: astroid module
+    :return: None
+    """
+    if mod.name.startswith("test_") or \
+            mod.name.startswith("tests.") or \
+            mod.name.startswith("kubernetes_tests."):
+        decoded_lines = mod.stream().read().decode("utf-8").split("\n")
+        if decoded_lines[0].startswith("# pylint: disable="):
+            decoded_lines[0] = decoded_lines[0] + " " + DISABLED_CHECKS_FOR_TESTS
+        elif decoded_lines[0].startswith("#") or decoded_lines[0].strip() == "":
+            decoded_lines[0] = "# pylint: disable=" + DISABLED_CHECKS_FOR_TESTS
+        else:
+            raise Exception(f"The first line of module {mod.name} is not a comment or empty. "
+                            f"Please make sure it is!")
+        # pylint will read from `.file_bytes` attribute later when tokenization
+        mod.file_bytes = "\n".join(decoded_lines).encode("utf-8")
+
+
+MANAGER.register_transform(scoped_nodes.Module, transform)

Review comment:
       This is exactly what we did before and that was a pain.  It took almost 2 x time than this one.
   This is a huge optimization, that's why I did it.
   
   The problem is that when you run pylint for tests, it also pulls in all the tested code which means that basically a lot of the main airflow code was parsed and processed twice - once in the "pylint main" and once in the "pylint tests". This code was not verified by Pylint but it was parsed and analyzed so that the test code could be pylint-checked so it's not a full duplication, but I think the savings are significant
   
   Some random stats:
   
   Before the change:
   
   pylint main: 6:20s 
   pylint tests: 3:59s 
   
   Tota: 10m 20s
   
   After the change: 
   combined pylint: 8:20s
   
   
   So we save 20% (2 minutes) of elapsed time by doing this.
   
   
   




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



[GitHub] [airflow] codecov-commenter edited a comment on pull request #10207: Pylint checks should be way faster now

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #10207:
URL: https://github.com/apache/airflow/pull/10207#issuecomment-670236880


   # [Codecov](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=h1) Report
   > Merging [#10207](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=desc) into [master](https://codecov.io/gh/apache/airflow/commit/d79e7221de76f01b5cd36c15224b59e8bb451c90&el=desc) will **decrease** coverage by `54.31%`.
   > The diff coverage is `100.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/airflow/pull/10207/graphs/tree.svg?width=650&height=150&src=pr&token=WdLKlKHOAU)](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #10207       +/-   ##
   ===========================================
   - Coverage   89.41%   35.10%   -54.32%     
   ===========================================
     Files        1037     1037               
     Lines       50011    50013        +2     
   ===========================================
   - Hits        44717    17555    -27162     
   - Misses       5294    32458    +27164     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | #kubernetes-tests-3.6-9.6 | `?` | |
   | #kubernetes-tests-image-3.6-v1.16.9 | `?` | |
   | #kubernetes-tests-image-3.6-v1.17.5 | `?` | |
   | #kubernetes-tests-image-3.6-v1.18.6 | `?` | |
   | #kubernetes-tests-image-3.7-v1.16.9 | `?` | |
   | #kubernetes-tests-image-3.7-v1.17.5 | `?` | |
   | #kubernetes-tests-image-3.7-v1.18.6 | `?` | |
   | #mysql-tests-Core-3.7-5.7 | `?` | |
   | #mysql-tests-Core-3.8-5.7 | `?` | |
   | #mysql-tests-Integration-3.7-5.7 | `34.75% <100.00%> (+<0.01%)` | :arrow_up: |
   | #mysql-tests-Integration-3.8-5.7 | `35.01% <100.00%> (+<0.01%)` | :arrow_up: |
   | #postgres-tests-Core-3.6-10 | `?` | |
   | #postgres-tests-Core-3.6-9.6 | `?` | |
   | #postgres-tests-Core-3.7-10 | `?` | |
   | #postgres-tests-Core-3.7-9.6 | `?` | |
   | #postgres-tests-Integration-3.6-10 | `?` | |
   | #postgres-tests-Integration-3.6-9.6 | `?` | |
   | #postgres-tests-Integration-3.7-10 | `?` | |
   | #postgres-tests-Integration-3.7-9.6 | `?` | |
   | #sqlite-tests-Core-3.6 | `?` | |
   | #sqlite-tests-Core-3.8 | `?` | |
   | #sqlite-tests-Integration-3.6 | `?` | |
   | #sqlite-tests-Integration-3.8 | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [airflow/jobs/scheduler\_job.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9qb2JzL3NjaGVkdWxlcl9qb2IucHk=) | `16.39% <100.00%> (-74.25%)` | :arrow_down: |
   | [airflow/hooks/S3\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9TM19ob29rLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/pig\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9waWdfaG9vay5weQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/hdfs\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9oZGZzX2hvb2sucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/http\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9odHRwX2hvb2sucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/jdbc\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9qZGJjX2hvb2sucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/contrib/\_\_init\_\_.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL19faW5pdF9fLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/druid\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9kcnVpZF9ob29rLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/hive\_hooks.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9oaXZlX2hvb2tzLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [airflow/hooks/mssql\_hook.py](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree#diff-YWlyZmxvdy9ob29rcy9tc3NxbF9ob29rLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | ... and [908 more](https://codecov.io/gh/apache/airflow/pull/10207/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=footer). Last update [d79e722...2b57575](https://codecov.io/gh/apache/airflow/pull/10207?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


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



[GitHub] [airflow] potiuk commented on pull request #10207: Pylint checks should be way faster now

Posted by GitBox <gi...@apache.org>.
potiuk commented on pull request #10207:
URL: https://github.com/apache/airflow/pull/10207#issuecomment-670388361


   I also added yet another small speedup - I realised that when we split pre-commits we should have two separate pre-comit virtualenv caches - that should give another 30-40 seconds boost overall.


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