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/02/23 20:23:07 UTC

[GitHub] [airflow] digitalsimboja opened a new pull request #14400: Fix conf import from airflow #13945

digitalsimboja opened a new pull request #14400:
URL: https://github.com/apache/airflow/pull/14400


   This rule checks to ensure user properly imports "conf" to be compatible with Airflow 2.0
   
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   **^ 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] boring-cyborg[bot] commented on pull request #14400: Add conf not importable from airflow rule

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on pull request #14400:
URL: https://github.com/apache/airflow/pull/14400#issuecomment-798885481


   Awesome work, congrats on your first merged pull request!
   


----------------------------------------------------------------
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 #14400: Fix conf import from airflow #13945

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



##########
File path: airflow/upgrade/rules/fix_conf_not_importable_from_airflow.py
##########
@@ -0,0 +1,29 @@
+
+from airflow.upgrade.rules.base_rule import BaseRule
+
+print(BaseRule)
+
+<<<<<<< HEAD
+
+class ConfImportFromAirflow(BaseRule):
+    """
+      ConfImportFromAirflow class to ensure proper import of conf from to work in Airflow 2.0
+      """
+    title = "Properly import conf from Airflow"
+    description = """\
+    In Airflow-2.0, it's not possible to import conf from airflow by using \'import conf from airflow\'
+    To ensure your code works in Airflow 2.0, you should use \'from airflow.Configuration import conf \'

Review comment:
       ```suggestion
       In Airflow-2.0, it's not possible to import `conf` from airflow by using `import conf from airflow`
       To ensure your code works in Airflow 2.0, you should use `from airflow.configuration import conf`.
   ```




----------------------------------------------------------------
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] digitalsimboja commented on a change in pull request #14400: Fix conf import from airflow #13945

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



##########
File path: airflow/upgrade/rules/fix_conf_not_importable_from_airflow.py
##########
@@ -0,0 +1,29 @@
+
+from airflow.upgrade.rules.base_rule import BaseRule
+
+print(BaseRule)
+
+<<<<<<< HEAD
+
+class ConfImportFromAirflow(BaseRule):
+    """
+      ConfImportFromAirflow class to ensure proper import of conf from to work in Airflow 2.0
+      """
+    title = "Properly import conf from Airflow"
+    description = """\
+    In Airflow-2.0, it's not possible to import conf from airflow by using \'import conf from airflow\'
+    To ensure your code works in Airflow 2.0, you should use \'from airflow.Configuration import conf \'
+                      """
+
+    def check(self):
+        from airflow import conf
+        if conf:
+            return (
+                "Warning: Properly import conf to ensure your code works in AIrflow 2.0"
+                "From Airflow 2.0, you should use from airflow.Configuration import conf."
+            )

Review comment:
       Got it. Thanks




----------------------------------------------------------------
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 pull request #14400: Add conf not importable from airflow rule

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


   > > Looks good to me, only one comment about the message.
   > 
   > Hi Turbaszek,
   > Do you still want me to remove the lines you mentioned or it's okay to go?
   
   Yes, it would be nice to simplify the final output 


----------------------------------------------------------------
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] github-actions[bot] commented on pull request #14400: Add conf not importable from airflow rule

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #14400:
URL: https://github.com/apache/airflow/pull/14400#issuecomment-791991204


   The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest master at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.


----------------------------------------------------------------
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] digitalsimboja commented on a change in pull request #14400: Add conf not importable from airflow rule

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



##########
File path: airflow/upgrade/rules/fix_conf_not_importable_from_airflow.py
##########
@@ -0,0 +1,64 @@
+
+# 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 airflow.upgrade.rules.base_rule import BaseRule
+from airflow import conf
+from airflow.utils.dag_processing import list_py_file_paths
+
+
+class ProperlyImportConfFromAirflow(BaseRule):
+    """
+      ProperlyImportConfFromAirflow class to ensure proper import of conf to work in Airflow 2.0
+      """
+    title = "Ensure Users Properly Import conf from Airflow"
+    description = """\
+    In Airflow-2.0, it's not possible to import `conf` from airflow by using `import conf from airflow`
+    To ensure your code works in Airflow 2.0, you should use `from airflow.configuration import conf`.
+                      """
+
+    wrong_conf_import = "from airflow import conf"
+    proper_conf_import = "from airflow.configuration import conf"
+
+    def _conf_import_info(self, file_path, line_number):
+        return "Warning: In Airflow 2.0, it's not possible to import `conf` by using `{}`. " \
+               "To ensure your code works in Airflow 2.0, you should use `{}`." \
+               " Affected file: {} (line {})".format(
+                self.wrong_conf_import, self.proper_conf_import, file_path, line_number
+                )

Review comment:
       Yes that is correct. I will go ahead and return only the affected file and line in this section. Thanks




----------------------------------------------------------------
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 #14400: Fix conf import from airflow #13945

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



##########
File path: airflow/upgrade/rules/fix_conf_not_importable_from_airflow.py
##########
@@ -0,0 +1,29 @@
+
+from airflow.upgrade.rules.base_rule import BaseRule
+
+print(BaseRule)
+
+<<<<<<< HEAD

Review comment:
       ```suggestion
   
   ```

##########
File path: airflow/upgrade/rules/fix_conf_not_importable_from_airflow.py
##########
@@ -0,0 +1,29 @@
+
+from airflow.upgrade.rules.base_rule import BaseRule
+
+print(BaseRule)
+
+<<<<<<< HEAD
+
+class ConfImportFromAirflow(BaseRule):
+    """
+      ConfImportFromAirflow class to ensure proper import of conf from to work in Airflow 2.0
+      """
+    title = "Properly import conf from Airflow"
+    description = """\
+    In Airflow-2.0, it's not possible to import conf from airflow by using \'import conf from airflow\'
+    To ensure your code works in Airflow 2.0, you should use \'from airflow.Configuration import conf \'
+                      """
+
+    def check(self):
+        from airflow import conf
+        if conf:
+            return (
+                "Warning: Properly import conf to ensure your code works in AIrflow 2.0"
+                "From Airflow 2.0, you should use from airflow.Configuration import conf."
+            )
+
+
+=======
+class CustomExecutorsRequireFullPathRule(BaseRule):
+>>>>>>> 1caae81f64e7cb5307a43b218b836f7d7854f5db

Review comment:
       ```suggestion
   
   ```

##########
File path: airflow/upgrade/rules/fix_conf_not_importable_from_airflow.py
##########
@@ -0,0 +1,29 @@
+
+from airflow.upgrade.rules.base_rule import BaseRule
+
+print(BaseRule)

Review comment:
       ```suggestion
   
   ```




----------------------------------------------------------------
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 #14400: Fix conf import from airflow #13945

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



##########
File path: airflow/upgrade/rules/fix_conf_not_importable_from_airflow.py
##########
@@ -0,0 +1,29 @@
+
+from airflow.upgrade.rules.base_rule import BaseRule
+
+print(BaseRule)
+
+<<<<<<< HEAD
+
+class ConfImportFromAirflow(BaseRule):
+    """
+      ConfImportFromAirflow class to ensure proper import of conf from to work in Airflow 2.0
+      """
+    title = "Properly import conf from Airflow"
+    description = """\
+    In Airflow-2.0, it's not possible to import conf from airflow by using \'import conf from airflow\'
+    To ensure your code works in Airflow 2.0, you should use \'from airflow.Configuration import conf \'
+                      """
+
+    def check(self):
+        from airflow import conf
+        if conf:
+            return (
+                "Warning: Properly import conf to ensure your code works in AIrflow 2.0"
+                "From Airflow 2.0, you should use from airflow.Configuration import conf."
+            )

Review comment:
       What this rule should do is to scan all users DAGs and plugins and verify if they use `from airflow import conf` in their code. If yes, we should raise a warning for each file that is impacted by this issue. 
   
   Here's an example how can we iterate through DAG files:
   https://github.com/apache/airflow/blob/dbf2e302313580b6eaa85e9fcbcace8b6260c85a/airflow/upgrade/rules/import_changes.py#L138-L146
   
   Same can be done for plugins using ` plugins_folder = conf.get("core", "plugins_folder")`.




----------------------------------------------------------------
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 #14400: Fix conf import from airflow #13945

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



##########
File path: airflow/upgrade/rules/fix_conf_not_importable_from_airflow.py
##########
@@ -0,0 +1,29 @@
+
+from airflow.upgrade.rules.base_rule import BaseRule
+
+print(BaseRule)
+
+<<<<<<< HEAD
+
+class ConfImportFromAirflow(BaseRule):
+    """
+      ConfImportFromAirflow class to ensure proper import of conf from to work in Airflow 2.0
+      """
+    title = "Properly import conf from Airflow"
+    description = """\
+    In Airflow-2.0, it's not possible to import conf from airflow by using \'import conf from airflow\'
+    To ensure your code works in Airflow 2.0, you should use \'from airflow.Configuration import conf \'
+                      """
+
+    def check(self):
+        from airflow import conf
+        if conf:
+            return (
+                "Warning: Properly import conf to ensure your code works in AIrflow 2.0"
+                "From Airflow 2.0, you should use from airflow.Configuration import conf."
+            )

Review comment:
       What this rule should do is to scan all users DAGs and plugins and verify if they use `from airflow import conf` in their code. If yes, we should raise a warning for each file that is impacted by this issue. 




----------------------------------------------------------------
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 #14400: Add conf not importable from airflow rule

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



##########
File path: airflow/upgrade/rules/fix_conf_not_importable_from_airflow.py
##########
@@ -0,0 +1,64 @@
+
+# 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 airflow.upgrade.rules.base_rule import BaseRule
+from airflow import conf
+from airflow.utils.dag_processing import list_py_file_paths
+
+
+class ProperlyImportConfFromAirflow(BaseRule):
+    """
+      ProperlyImportConfFromAirflow class to ensure proper import of conf to work in Airflow 2.0
+      """
+    title = "Ensure Users Properly Import conf from Airflow"
+    description = """\
+    In Airflow-2.0, it's not possible to import `conf` from airflow by using `import conf from airflow`
+    To ensure your code works in Airflow 2.0, you should use `from airflow.configuration import conf`.
+                      """
+
+    wrong_conf_import = "from airflow import conf"
+    proper_conf_import = "from airflow.configuration import conf"
+
+    def _conf_import_info(self, file_path, line_number):
+        return "Warning: In Airflow 2.0, it's not possible to import `conf` by using `{}`. " \
+               "To ensure your code works in Airflow 2.0, you should use `{}`." \
+               " Affected file: {} (line {})".format(
+                self.wrong_conf_import, self.proper_conf_import, file_path, line_number
+                )

Review comment:
       ```suggestion
           return "Affected file: {} (line {})".format(
                   self.wrong_conf_import, self.proper_conf_import, file_path, line_number
                   )
   ```
   All else will be displayed anyway as it is in rule description, right?




----------------------------------------------------------------
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] ephraimbuddy commented on pull request #14400: Add conf not importable from airflow rule

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


   You have static check errors, please install pre-commit and run it. `pre-commit run --all-files`. Commit the result and push


----------------------------------------------------------------
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] digitalsimboja commented on pull request #14400: Add conf not importable from airflow rule

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


   > Thanks @digitalsimboja for the PR! tada
   
   Thanks for all the wonderful reviews. Looking forward on my next PR


----------------------------------------------------------------
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] digitalsimboja commented on pull request #14400: Add conf not importable from airflow rule

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


   > Looks good to me, only one comment about the message.
   
   Hi Turbaszek, 
   Do you still want me to remove the lines you mentioned or it's okay to go?


----------------------------------------------------------------
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] github-actions[bot] commented on pull request #14400: Add conf not importable from airflow rule

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #14400:
URL: https://github.com/apache/airflow/pull/14400#issuecomment-791839169


   [The Workflow run](https://github.com/apache/airflow/actions/runs/626256077) is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Backport packages$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.


----------------------------------------------------------------
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 pull request #14400: Add conf not importable from airflow rule

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


   Thanks @digitalsimboja for the PR! 🎉 


----------------------------------------------------------------
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] github-actions[bot] commented on pull request #14400: Fix conf import from airflow #13945

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #14400:
URL: https://github.com/apache/airflow/pull/14400#issuecomment-784519087


   [The Workflow run](https://github.com/apache/airflow/actions/runs/593913873) is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Backport packages$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.


----------------------------------------------------------------
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] github-actions[bot] commented on pull request #14400: Add conf not importable from airflow rule

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #14400:
URL: https://github.com/apache/airflow/pull/14400#issuecomment-791913790


   [The Workflow run](https://github.com/apache/airflow/actions/runs/627104621) is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Backport packages$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.


----------------------------------------------------------------
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] digitalsimboja commented on a change in pull request #14400: Add conf not importable from airflow rule

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



##########
File path: airflow/upgrade/rules/fix_conf_not_importable_from_airflow.py
##########
@@ -0,0 +1,29 @@
+
+from airflow.upgrade.rules.base_rule import BaseRule
+
+print(BaseRule)
+
+<<<<<<< HEAD
+
+class ConfImportFromAirflow(BaseRule):
+    """
+      ConfImportFromAirflow class to ensure proper import of conf from to work in Airflow 2.0
+      """
+    title = "Properly import conf from Airflow"
+    description = """\
+    In Airflow-2.0, it's not possible to import conf from airflow by using \'import conf from airflow\'
+    To ensure your code works in Airflow 2.0, you should use \'from airflow.Configuration import conf \'
+                      """
+
+    def check(self):
+        from airflow import conf
+        if conf:
+            return (
+                "Warning: Properly import conf to ensure your code works in AIrflow 2.0"
+                "From Airflow 2.0, you should use from airflow.Configuration import conf."
+            )

Review comment:
       Hi Turbaszek, I have updated the patch. Kindly review. Thanks




----------------------------------------------------------------
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 merged pull request #14400: Add conf not importable from airflow rule

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


   


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