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

Document and improve load_plugins #2447

Open
astrofrog opened this issue Oct 18, 2023 · 0 comments
Open

Document and improve load_plugins #2447

astrofrog opened this issue Oct 18, 2023 · 0 comments

Comments

@astrofrog
Copy link
Member

astrofrog commented Oct 18, 2023

As described in glue-viz/glue-astronomy#76 we should:

  • Document that applications relying on glue should execute load_plugins to have access to plugins - perhaps we can add a new page in this section: http://docs.glueviz.org/en/stable/index.html#advanced-customization called 'Writing glue applications' that would just have one section for now called 'Loading glue plugins' that would then state that applications using glue-core should call load_plugins to make sure any installed plugins become active.

  • Modify load_plugins to allow a list of plugin names to be passed to limit which plugins are loaded. We could also have a boolean toggle for whether to require the plugins or whether to load them but only if available. Once this is done we could remove the require_qt_plugins flag and instead in glue-qt we can adjust the load_plugins call to use the new API to require the Qt plugins. We can then do:

load_plugins([<the required Qt plugins>], allow_missing=False)  # will make sure we require the Qt plugins
load_plugins()  # will load all available plugins (won't reload already loaded Qt plugins)
  • Add a new list_plugins function that can print out the list of available plugins that can be selected in load_plugins

  • Make it so that load_plugins can be used as a context manager, e.g.:

with load_plugins(['ccddata_translator']):
    ...

when the context manager exits, the plugins should be unloaded if they were not loaded beforehand. If it's difficult to make load_plugins into a context manager and preserve backward-compatibility, it might be easier to define a new name e.g. ensure_plugins_loaded() for the context manager.

We should add a keyword argument to also say whether to temporarily disable any other loaded plugins, so that e.g.:

with ensure_plugins_loaded(['ccddata_translator'], ignore_already_loaded=True):
   ...

would make sure that only that one plugin is loaded inside the block (this will be useful especially for testing).

  • Have a way of loading plugins by package/module name instead of entry point name. For instance, I could load all glue-astronomy plugins with:
load_plugins(module='glue_astronomy')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants