ska_sdp_batchlet.plugins.utils module

ska_sdp_batchlet.plugins.utils.load_plugin(plugin_base_class, name, path=None, **_)[source]

Validates and returns a plugin class.

Parameters:
  • plugin_base_class (type[TypeVar(BasePlugin)]) -- The base class type that the plugin must inherit from.

  • name (str) -- The name of the plugin class to validate.

  • path (str | None, default: None) -- The module path of the plugin. If None, it will fallback to plugin_base_class.DEFAULT_PACKAGE_PATH.

Return type:

type[TypeVar(BasePlugin)]

Returns:

The validated plugin class.

Raises:
  • ImportError -- If the specified class is not found in the module.

  • TypeError -- If the class is not a subclass of plugin_base_class.

ska_sdp_batchlet.plugins.utils.instantiate_plugins(plugin_base_class, plugin_configs)[source]

Instantiate plugins based on the configuration.

Parameters:
  • plugin_base_class (type[TypeVar(BasePlugin)]) -- The base class type that the plugins must inherit from.

  • plugin_configs (list[dict]) --

    List of plugin configurations. Each configuration is a dictionary with following keys:

    • name: Name of the plugin class to load

    • path: (optional) Path to the python module which contains the

      plugin class

    • kwargs: (optional) Extra key-word argumments passed to the

      plugin class while instantiating.

Return type:

list[TypeVar(BasePlugin)]

Returns:

List of fully initialized plugin objects

Raises:
  • ImportError -- If the specified class is not found in the module.

  • TypeError -- If the class is not a subclass of plugin_base_class.