toil.lib.plugins

Generic plugin system for Toil plugins.

Plugins come in Python packages named:

toil_{PLUGIN_TYPE}_{WHATEVER}

When looking for plugins, Toil will list all the Python packages with the right name prefix for the given type of plugin, and load them. The plugin modules then have an opportunity to import register_plugin() and register themselves.

Attributes

PluginType

plugin_types

Functions

register_plugin(plugin_type, plugin_name, ...)

Adds a plugin to the registry for the given type of plugin.

remove_plugin(plugin_type, plugin_name)

Removes a plugin from the registry for the given type of plugin.

get_plugin_names(plugin_type)

Get the names of all the available plugins of the given type.

get_plugin(plugin_type, plugin_name)

Get a plugin class factory function by name.

Module Contents

toil.lib.plugins.PluginType
toil.lib.plugins.plugin_types: list[PluginType] = ['batch_system', 'url_access']
toil.lib.plugins.register_plugin(plugin_type, plugin_name, plugin_being_registered)[source]

Adds a plugin to the registry for the given type of plugin.

Parameters:
  • plugin_name (str) – For batch systems, this is the string the user will use to select the batch system on the command line with --batchSystem. For URL access plugins, this is the URL scheme that the plugin implements.

  • plugin_being_registered (Any) – This is a function that, when called, imports and returns a plugin-provided class type. For batch systems, the resulting type must extend toil.batchSystems.abstractBatchSystem.AbstractBatchSystem. For URL access plugins, it must extend toil.lib.url.URLAccess. Note that the function used here should return the class itslef; it should not construct an instance of the class.

  • plugin_type (PluginType)

Return type:

None

toil.lib.plugins.remove_plugin(plugin_type, plugin_name)[source]

Removes a plugin from the registry for the given type of plugin.

Parameters:
  • plugin_type (PluginType)

  • plugin_name (str)

Return type:

None

toil.lib.plugins.get_plugin_names(plugin_type)[source]

Get the names of all the available plugins of the given type.

Parameters:

plugin_type (PluginType)

Return type:

list[str]

toil.lib.plugins.get_plugin(plugin_type, plugin_name)[source]

Get a plugin class factory function by name.

Raises:

KeyError if plugin_name is not the name of a plugin of the given type.

Parameters:
  • plugin_type (PluginType)

  • plugin_name (str)

Return type:

Any