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/05/24 22:04:05 UTC

[GitHub] [airflow] mik-laj opened a new pull request #9001: Add airflow plugin command

mik-laj opened a new pull request #9001:
URL: https://github.com/apache/airflow/pull/9001


   A small command that makes it easier to troubleshoot plugins.
   ```
   [2020-05-24 22:02:21,845] {plugins_manager.py:224} DEBUG - Loading plugins
   [2020-05-24 22:02:21,845] {plugins_manager.py:164} DEBUG - Loading plugins from directory: /opt/airflow/airflow/contrib/plugins
   [2020-05-24 22:02:21,857] {plugins_manager.py:178} DEBUG - Importing plugin module /opt/airflow/airflow/contrib/plugins/metastore_browser/main.py
   /opt/airflow/airflow/contrib/plugins/metastore_browser/main.py:45: FutureWarning: Passing a negative integer is deprecated in version 1.0 and will not be supported in future version. Instead, use None to not limit the column width.
     pd.set_option('display.max_colwidth', -1)
   [2020-05-24 22:02:22,476] {plugins_manager.py:143} DEBUG - Loading plugins from entrypoints
   [2020-05-24 22:02:22,508] {plugins_manager.py:218} DEBUG - Plugins are already loaded. Skipping.
   [2020-05-24 22:02:22,508] {plugins_manager.py:362} DEBUG - Integrate DAG plugins
   [2020-05-24 22:02:22,510] {plugins_manager.py:199} DEBUG - Creating module airflow.operators.metastore_browser
   [2020-05-24 22:02:22,513] {plugins_manager.py:199} DEBUG - Creating module airflow.sensors.metastore_browser
   [2020-05-24 22:02:22,513] {plugins_manager.py:199} DEBUG - Creating module airflow.hooks.metastore_browser
   [2020-05-24 22:02:22,514] {plugins_manager.py:199} DEBUG - Creating module airflow.macros.metastore_browser
   [2020-05-24 22:02:22,514] {plugins_manager.py:218} DEBUG - Plugins are already loaded. Skipping.
   [2020-05-24 22:02:22,515] {plugins_manager.py:325} DEBUG - Integrate executor plugins
   [2020-05-24 22:02:22,516] {plugins_manager.py:199} DEBUG - Creating module airflow.executors.metastore_browser
   [2020-05-24 22:02:22,517] {plugins_manager.py:218} DEBUG - Plugins are already loaded. Skipping.
   [2020-05-24 22:02:22,518] {plugins_manager.py:293} DEBUG - Initialize extra operators links plugins
   [2020-05-24 22:02:22,518] {plugins_manager.py:218} DEBUG - Plugins are already loaded. Skipping.
   [2020-05-24 22:02:22,519] {plugins_manager.py:256} DEBUG - Initialize Web UI plugin
   ########################################## PLUGINS MANGER: ##########################################
   plugins = [<class 'main.MetastoreBrowserPlugin'>]
   import_errors = {}
   operators_modules = [<module 'airflow.operators.metastore_browser'>]
   sensors_modules = [<module 'airflow.sensors.metastore_browser'>]
   hooks_modules = [<module 'airflow.hooks.metastore_browser'>]
   macros_modules = [<module 'airflow.macros.metastore_browser'>]
   executors_modules = [<module 'airflow.executors.metastore_browser'>]
   admin_views = []
   flask_blueprints = [{'blueprint': <flask.blueprints.Blueprint object at 0x7f2c9b7f70f0>,
     'name': 'metastore_browser'}]
   menu_links = []
   flask_appbuilder_views = [{'category': 'Plugins',
     'name': 'Hive Metadata Browser',
     'view': <main.MetastoreBrowserView object at 0x7f2c888620b8>}]
   flask_appbuilder_menu_links = []
   global_operator_extra_links = []
   operator_extra_links = []
   registered_operator_link_classes = {}
   
   ############################################## PLUGINS: #############################################
   Loaded 1 plugins
   ======================================== 0 metastore_browser ========================================
   operators = []
   sensors = []
   hooks = []
   executors = []
   macros = []
   admin_views = []
   flask_blueprints = [<flask.blueprints.Blueprint object at 0x7f2c9b7f70f0>]
   menu_links = []
   appbuilder_views = [{'category': 'Plugins',
     'name': 'Hive Metadata Browser',
     'view': <main.MetastoreBrowserView object at 0x7f2c888620b8>}]
   appbuilder_menu_items = []
   global_operator_extra_links = []
   operator_extra_links = []
   ```
   ---
   Make sure to mark the boxes below before creating PR: [x]
   
   - [ ] Description above provides context of the change
   - [ ] Unit tests coverage for changes (not needed for documentation changes)
   - [ ] Target Github ISSUE in description if exists
   - [ ] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
   - [ ] Relevant documentation is updated including usage instructions.
   - [ ] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   ---
   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).
   Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
   


----------------------------------------------------------------
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] kaxil commented on a change in pull request #9001: Add airflow plugin command

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



##########
File path: docs/plugins.rst
##########
@@ -28,6 +28,9 @@ The python modules in the ``plugins`` folder get imported,
 and **hooks**, **operators**, **sensors**, **macros** and web **views**
 get integrated to Airflow's main collections and become available for use.
 
+To troubleshoot issue with plugins, you can use ``airflow plugins`` command.
+This command dumps information about loaded plugins.
+

Review comment:
       Ignore it for now then




----------------------------------------------------------------
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] kaxil merged pull request #9001: Add airflow plugin command

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


   


----------------------------------------------------------------
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] mik-laj commented on pull request #9001: Add airflow plugin command

Posted by GitBox <gi...@apache.org>.
mik-laj commented on pull request #9001:
URL: https://github.com/apache/airflow/pull/9001#issuecomment-638990350


   @kaxil Can you look at it again?


----------------------------------------------------------------
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] kaxil commented on a change in pull request #9001: Add airflow plugin command

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



##########
File path: docs/plugins.rst
##########
@@ -28,6 +28,9 @@ The python modules in the ``plugins`` folder get imported,
 and **hooks**, **operators**, **sensors**, **macros** and web **views**
 get integrated to Airflow's main collections and become available for use.
 
+To troubleshoot plugins issue, you can use ``airflow plugins`` command.

Review comment:
       ```suggestion
   To troubleshoot issues with plugins you can use ``airflow plugins`` command.
   ```




----------------------------------------------------------------
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] mik-laj commented on a change in pull request #9001: Add airflow plugin command

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9001:
URL: https://github.com/apache/airflow/pull/9001#discussion_r435597592



##########
File path: docs/plugins.rst
##########
@@ -28,6 +28,9 @@ The python modules in the ``plugins`` folder get imported,
 and **hooks**, **operators**, **sensors**, **macros** and web **views**
 get integrated to Airflow's main collections and become available for use.
 
+To troubleshoot issue with plugins, you can use ``airflow plugins`` command.
+This command dumps information about loaded plugins.
+

Review comment:
       I can add, but I'm not sure it will be useful.  This tool displays a lot of information  When I had one plug-in installed, 56 lines of text were displayed.  We don't have an example in the documentation for the airflow info command either. This is a similar type of command. It displays a lot of information, but it doesn't matter how it looks. On the other hand, we have a description of the `airflow dag show`  command, where the example gives a better understanding of the command.




----------------------------------------------------------------
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] kaxil commented on a change in pull request #9001: Add airflow plugin command

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



##########
File path: tests/cli/commands/test_plugins_command.py
##########
@@ -0,0 +1,96 @@
+# 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.
+
+import io
+import unittest
+from contextlib import ExitStack, contextmanager, redirect_stdout
+from unittest import mock
+
+from airflow.cli import cli_parser
+from airflow.cli.commands import plugins_command
+from airflow.models.baseoperator import BaseOperator
+from airflow.plugins_manager import AirflowPlugin
+
+
+class PluginOperator(BaseOperator):
+    pass
+
+
+class TestPlugin(AirflowPlugin):
+    name = "test-plugin-cli"
+
+    operators = [PluginOperator]
+
+
+PLUGINS_MANAGER_NULLABLE_ATTRIBUTES = [
+    "plugins",
+    "operators_modules",
+    "sensors_modules",
+    "hooks_modules",
+    "macros_modules",
+    "executors_modules",
+    "admin_views",
+    "flask_blueprints",
+    "menu_links",
+    "flask_appbuilder_views",
+    "flask_appbuilder_menu_links",
+    "global_operator_extra_links",
+    "operator_extra_links",
+    "registered_operator_link_classes",
+]
+
+
+@contextmanager
+def keep_plugin_manager_state():
+    with ExitStack() as exit_stack:

Review comment:
       Can you add some docs on what it does and when it should be used in tests




----------------------------------------------------------------
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] kaxil commented on a change in pull request #9001: Add airflow plugin command

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



##########
File path: docs/plugins.rst
##########
@@ -28,6 +28,9 @@ The python modules in the ``plugins`` folder get imported,
 and **hooks**, **operators**, **sensors**, **macros** and web **views**
 get integrated to Airflow's main collections and become available for use.
 
+To troubleshoot issue with plugins, you can use ``airflow plugins`` command.
+This command dumps information about loaded plugins.
+

Review comment:
       Can we add an example here?




----------------------------------------------------------------
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] mik-laj commented on a change in pull request #9001: Add airflow plugin command

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9001:
URL: https://github.com/apache/airflow/pull/9001#discussion_r433603683



##########
File path: docs/plugins.rst
##########
@@ -28,6 +28,9 @@ The python modules in the ``plugins`` folder get imported,
 and **hooks**, **operators**, **sensors**, **macros** and web **views**
 get integrated to Airflow's main collections and become available for use.
 
+To troubleshoot plugins issue, you can use ``airflow plugins`` command.

Review comment:
       I applied your 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] mik-laj commented on a change in pull request #9001: Add airflow plugin command

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9001:
URL: https://github.com/apache/airflow/pull/9001#discussion_r433603520



##########
File path: tests/cli/commands/test_plugins_command.py
##########
@@ -0,0 +1,96 @@
+# 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.
+
+import io
+import unittest
+from contextlib import ExitStack, contextmanager, redirect_stdout
+from unittest import mock
+
+from airflow.cli import cli_parser
+from airflow.cli.commands import plugins_command
+from airflow.models.baseoperator import BaseOperator
+from airflow.plugins_manager import AirflowPlugin
+
+
+class PluginOperator(BaseOperator):
+    pass
+
+
+class TestPlugin(AirflowPlugin):
+    name = "test-plugin-cli"
+
+    operators = [PluginOperator]
+
+
+PLUGINS_MANAGER_NULLABLE_ATTRIBUTES = [
+    "plugins",
+    "operators_modules",
+    "sensors_modules",
+    "hooks_modules",
+    "macros_modules",
+    "executors_modules",
+    "admin_views",
+    "flask_blueprints",
+    "menu_links",
+    "flask_appbuilder_views",
+    "flask_appbuilder_menu_links",
+    "global_operator_extra_links",
+    "operator_extra_links",
+    "registered_operator_link_classes",
+]
+
+
+@contextmanager
+def keep_plugin_manager_state():
+    with ExitStack() as exit_stack:

Review comment:
       Thanks. I added the description.




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