Plugin mechanism

CliMetLab plugins rely on the python plugins system using entry_points.

climetlab.core.plugins.directories(owner: bool = False) list

Return a list of directories that are used in the project .

If owner = False, return a list of directories where to search for plugins.

If owner = True, return a list of 2-uples to include the owner in the return value.

Parameters

owner (bool, optional) –

climetlab.core.plugins.find_plugin(directories: Union[str, List[str]], name: str, loader)

Find a plugin by name .

Parameters
  • directories (list or str) – List of directories to be searched to find the plugin.

  • name (str) – Name of the plugin

  • loader (class) – Class implementing load_yaml() and load_module()

Returns

Return type

Return what the loader will returns when applied to the plugin with the right name name, found in one of the directories of the directories list.

Raises

NameError – If plugin is not found.

climetlab.core.plugins.load_plugins(kind)

Loads the plugins for a given kind. The plugin needs to have registered itself with entry_point.

Parameters

kind (str) – Plugin type such as “dataset” or “source”.

climetlab.core.plugins.register(kind, name_or_module, module_or_none=None)

Register a plugin manually.

When installing a plugin (for instance with !pip install in a notebook), the pip package with register the plugin with the entry_points mechanism, but the currently runnning kernel will need to be restarted to take the change into account. Using register() alleviates this issue.

Parameters
  • kind (str) – Type of plugind.

  • name_or_module (str or module) – Name of the installed plugin to registed.

  • module_or_none (module, optional) – Module recently installed to be registered.