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/01/15 15:08:39 UTC

[GitHub] [airflow] kaxil commented on a change in pull request #13678: Created CustomExecutorsRequireFullPathRule class

kaxil commented on a change in pull request #13678:
URL: https://github.com/apache/airflow/pull/13678#discussion_r558368526



##########
File path: airflow/upgrade/rules/custom_executors_require_full_path_rule.py
##########
@@ -0,0 +1,40 @@
+# 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.configuration import conf
+from airflow.upgrade.rules.base_rule import BaseRule
+
+
+class CustomExecutorsRequireFullPathRule(BaseRule):
+    """
+    CustomExecutorsRequireFullPathRule class to ease upgrade to Airflow 2.0
+    """
+    title = "Custom Executors now require full path"
+    description = """\
+In Airflow-2.0, loading custom executors via plugins is no longer required.
+To load a custom executor, you have to provide a full path to the the custom executor module.
+                  """
+
+    def check(self):
+        executor = conf.get(section="core", key="executor")
+        if executor.count(".") <= 1:

Review comment:
       Also, I think this will not catch the case where a user has imported an Executor via Pluings but no set it in `[core] executor`.
   
   I think a better solution would be to get the executor imported via plugin list: 
   
   ```python
   from airflow.plugins_manager import executors_modules
   if executors_modules:    
       print(executors_modules)
   ```
   
   This should give you that list that should not be imported




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