lisa.conf.Configurable#
- class lisa.conf.Configurable[source]#
Bases:
ABCPair a regular class with a configuration class.
The pairing is achieved by inheriting from
Configurableand settingCONF_CLASSattribute. The benefits are:The docstring of the class is processed as a string template and
{configurable_params}is replaced with a Sphinx-compliant list of parameters. The help and type of each parameter is extracted from the configuration class.The
DEFAULT_SRCattribute of the configuration class is updated with non-Nonedefault values of the class__init__parameters.The
conf_to_init_kwargs()method allows turning a configuration object into a dictionary suitable for passing to__init__as**kwargs.The
check_init_param()method allows checking types of__init__parameters according to what is specified in the configuration class.
Most of the time, the configuration keys and
__init__parameters have the same name (modulo underscore/dashes which are handled automatically). In that case, the mapping between config keys and__init__parameters is done without user intervention. When that is not the case, theINIT_KWARGS_KEY_MAPclass attribute can be used.Note
A given configuration class must be paired to only one class. Otherwise, the
DEFAULT_SRCconf class attribute will be updated multiple times, leading to unexpected results.Note
Some services offered by
Configurableare not extended to subclasses of a class using it. For example, it would not make sense to updateDEFAULT_SRCusing a subclass__init__parameters.Attributes
Configuration class associated with the current class.
Dictionary of
__init__parameter names to configuration key path.Methods
Take the same parameters as
__init__, and check their types according to what is specified in the configuration class.Turn a configuration object into a dictionary suitable for passing to
__init__as**kwargs.
Attributes#
- Configurable.CONF_CLASS = None#
Configuration class associated with the current class.
- Configurable.INIT_KWARGS_KEY_MAP = {}#
Dictionary of
__init__parameter names to configuration key path.That path is a list of strings to take into account sublevels like
['level-key', 'sublevel', 'foo'].