Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add list plugins method and tests #2496

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

CyclingNinja
Copy link
Contributor

No description provided.

@CyclingNinja CyclingNinja force-pushed the add_listplugins branch 4 times, most recently from 22e7a92 to c632393 Compare May 24, 2024 13:51
@astrofrog
Copy link
Member

@CyclingNinja - could you try rebasing on upstream/main to get rid of the merge commit?

"""
load_plugins(require_qt_plugins=False)
plugins = list_plugins()
assert isinstance(plugins, list)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can check that certain plugins are in the list

glue/main.py Outdated
@@ -115,3 +114,10 @@ def load_plugins(splash=None, require_qt_plugins=False, plugins_to_load=None):
# that were previously read.
from glue._settings_helpers import load_settings
load_settings()


def list_plugins():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this, I think we might want to actually have list_available_plugins and list_loaded_plugins as there are use cases for both. Could you implement both here?

@CyclingNinja CyclingNinja force-pushed the add_listplugins branch 5 times, most recently from cc44b8e to fe34214 Compare May 30, 2024 12:48
load_plugins(require_qt_plugins=False)
plugins = list_plugins()
assert isinstance(plugins, list)
assert len(plugins) == 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I didn't get back to you sooner about this - rather than checking the absolute number of plugins, you might want to just check that a specific set of them are inside the returned list (but there could be others present)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above comment still stands, can you check one of the plugins in the list?

@CyclingNinja CyclingNinja force-pushed the add_listplugins branch 4 times, most recently from 0e397fa to 6404d9d Compare June 3, 2024 16:50
glue/main.py Outdated
@@ -3,7 +3,7 @@
from importlib import import_module

from glue.logger import logger
from glue._plugin_helpers import REQUIRED_PLUGINS, REQUIRED_PLUGINS_QT
from glue._plugin_helpers import REQUIRED_PLUGINS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change and the one below should be reverted here

return sorted(_loaded_plugins)


def list_available_plugins():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you import these two functions into the top-level of the package? See:

from .main import load_plugins # noqa


def test_list_loaded_plugins():
"""
Regression test for retrieving the list of currently loaded plugins
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change 'regression' to 'unit'

load_plugins(require_qt_plugins=False)
plugins = list_plugins()
assert isinstance(plugins, list)
assert len(plugins) == 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above comment still stands, can you check one of the plugins in the list?

available_plugins = list_available_plugins()
assert isinstance(available_plugins, list)
assert len(available_plugins) == 7
assert 'casa_formats_io.glue_factory' in available_plugins
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove this one, it is only available if glue-astronomy is installed. For checking the absolute number above, maybe first filter it down to just the ones starting with 'glue.' and then you can check how many there are (as otherwise the test will fail if plugin packages are installed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants