1. Plugin Management

Todo

Intro to the RADICAL PluginManager

1.1. PluginManager – radical.utils.plugin_manager

class radical.utils.plugin_manager.PluginBase(descr: dict)[source]

Bases: object

This class serves as base class for any plugin managed by the plugin handler

plugin_type
plugin_name
plugin_class
plugin_version
plugin_description
class radical.utils.plugin_manager.PluginManager(namespaces)[source]

Bases: object

The PluginManager manages plugins of specific types: the manager can search for installed plugins, list and describe plugins found, load plugins, and instantiate the plugin for further use.

Example:

# try to load the ‘echo’ plugin from the ‘radical’ namespace plugin_type = ‘echo’

pm = radical.utils.PluginManager(‘radical’)

for plugin_name in pm.list(plugin_type):
print plugin_name print pm.describe(plugin_type, plugin_name)

default_plugin = pm.load(‘echo’, ‘default’)

default_plugin.init_plugin(‘world’) default_plugin.run() # prints ‘hello default world’

The plugins are expected to follow a specific naming and coding schema to be recognized by the plugin manager. The naming schema is:

[namespace].plugins.[ptype].plugin_[ptype]_[pname].py

i.e. for the example above: radical.plugins.echo.plugin_echo_default.py

The plugin code consists of two parts: a plugin description, and a plugin class. The description is a module level dictionary named PLUGIN_DESCRIPTION, the plugin class must have a class constructor __init__(*args, **kwargs) to create plugin instances for further use.

At this point, we leave the definition of the exact plugin signatures open, but expect that to be more strictly defined per plugin type in the future.

Note that the PluginManager construction is, at this point, not considered thread safe.

seen(pfile)[source]
register(ptype, pname, pinfo)[source]
retrieve(ptype, pname)[source]
load_plugins(namespace, log)[source]

Load all plugins for the given namespace. Previously loaded plugins are overloaded.

list_types()[source]

return a list of loaded plugin types

list(ptype)[source]

return a list of loaded plugins for a given plugin type

describe(ptype, pname)[source]

return a plugin details for a given plugin type / name pair

load(ptype, pname, *args, **kwargs)[source]

check if a plugin with given type and name was loaded, if so, instantiate its plugin class and return it.

dump()[source]
dump_str()[source]