glue-viz / glue

Linked Data Visualizations Across Multiple Files
http://glueviz.org
Other
721 stars 152 forks source link

Document and improve load_plugins #2447

Open astrofrog opened 9 months ago

astrofrog commented 9 months ago

As described in https://github.com/glue-viz/glue-astronomy/pull/76 we should:

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

load_plugins(module='glue_astronomy')