Source code for pycif.utils.classes.modes

from types import MethodType

from ...utils.check.errclass import PluginError
from .baseclass import Plugin


[docs] class Mode(Plugin): """Plugin type for execution modes. Defines what pyCIF does with the loaded plugins: e.g. a forward run, a 4D-Var inversion, an ensemble, or a diagnostic. The :meth:`execute` method is the entry point called by :class:`~pycif.utils.classes.setup.Setup`. Concrete implementations live in ``pycif/plugins/modes/``. """
[docs] def initiate_template(self): """Initialise the Mode plugin template. Loads the registered mode module and attaches ``execute`` as a bound method on this instance. """ super(Mode, self).initiate_template( plg_type="mode", default_functions={"execute": True} )
[docs] def execute(self, *args, **kwargs): """Default empty execute method""" raise PluginError("This is the default empty execute method")
[docs] @classmethod def register_plugin(cls, name, version, module, subtype="", **kwargs): """Register a module for a plugin and version with possibly options Args: name (str): name of the plugin version (str): version of the plugin module (types.ModuleType): module defining the interface between pyCIF and the plugin plugin_type (str): type of plugin **kwargs (dictionary): default options for module """ super(Mode, cls).register_plugin( name, version, module, plugin_type="mode", subtype=subtype )