Module Wrapper Plugins

pavilion.module_wrapper module

class pavilion.module_wrapper.ModuleWrapper(name, description, version=None, priority=10)

Bases: yapsy.IPlugin.IPlugin

The base class for all module wrapper plugins.

EMOD = 'emod'
LMOD = 'lmod'
NAME_VERS_RE = re.compile('^[a-zA-Z0-9_.-]+$')
NONE = 'none'
PRIO_COMMON = 10
PRIO_CORE = 0
PRIO_USER = 20
activate()

Add this module to the wrapped module list.

deactivate()

Remove this module from the wrapped module list.

get_version(requested_version)

Get the version of the module to load, given the requested version and the version set in the instance. This should always be used to figure out what version to load.

Parameters:None) requested_version (Union(str,) – The version requested by the user.
Return type:str
Returns:The version that should be loaded.
load(var_man, requested_version=None)

Generate the list of module actions and environment changes to load this module.

Parameters:
  • var_man (dict) – The system info dictionary of variables, from the system plugins.
  • requested_version (str) – The version requested to load.
Returns:

A list of actions (or bash command strings), and a dict of environment changes.

Return type:

(Union(str, ModuleAction), dict)

Raises:

ModuleWrapperError – If the requested version does not work with this instance.

path

The location of this module wrapper plugin.

swap(var_man, out_name, out_version, requested_version=None)

Swap out the ‘out’ module and swap in the new module.

Parameters:
  • var_man – The test’s variable manager. Module wrappers can use this to lookup any non-deferred test variable.
  • out_name (str) – The name of the module to swap out.
  • out_version (str) – The version of the module to swap out.
  • requested_version (str) – The version requested to load.
Returns:

A list of actions (or bash command strings), and a dict of environment changes.

Return type:

(Union(str, ModuleAction), dict)

Raises:

ModuleWrapperError – If the requested version does not work with this instance.

unload(var_man, requested_version=None)

Remove this module from the environment.

Parameters:
  • var_man – The test’s variable manager. Module wrappers can use this to lookup any non-deferred test variable.
  • requested_version (str) – The version requested to remove.
Returns:

A list of actions (or bash command strings), and a dict of environment changes.

Return type:

(Union(str, ModuleAction), dict)

Raises:

ModuleWrapperError – If the requested version does not work with this instance.

exception pavilion.module_wrapper.ModuleWrapperError

Bases: RuntimeError

Raised when any module wrapping related errors occur.

pavilion.module_wrapper.add_wrapped_module(module_wrapper, version)

Add the module wrapper to the set of wrapped modules.

Parameters:
  • module_wrapper (ModuleWrapper) – The module_wrapper class for the module.
  • None) version (Union(str,) – The version to add it under.
Returns:

None

Raises:

KeyError – On module version conflict.

pavilion.module_wrapper.get_module_wrapper(name, version=None)

Finds and returns a module wrapper to match the specified module name and version. The default module wrapper is returned if a match isn’t found.

Parameters:
  • name (str) – The name of the module.
  • None) version (Union(str,) – The version requested. If None is specified, this will look for the version-generic module wrapper for this module.
Return type:

ModuleWrapper

pavilion.module_wrapper.list_module_wrappers()

Returns a list of all loaded module wrapper plugins.

Return type:list
pavilion.module_wrapper.remove_wrapped_module(module_wrapper, version)

Remove the indicated module_wrapper from the set of wrapped module.

Parameters:
  • module_wrapper (ModuleWrapper) – The module_wrapper to remove, if it exists.
  • None) version (Union(str,) – The specific version to remove.
Returns:

None

pavilion.module_actions module

Defines the how to perform module loads, swaps and unloads.

class pavilion.module_actions.ModuleAction(module_name, version=None)

Bases: object

The base module action class.

action()

Returns a list of bash commands that should perform the action for the given module.

Return type:list(str)
module

A properly formatted module name for the given module and version.

verify()

Returns a list of bash commands that should verify that the module action has been performed successfully. These should set the test status to ENV_FAILED, and exit the bash script with a non-zero return code.

class pavilion.module_actions.ModuleLoad(module_name, version=None)

Bases: pavilion.module_actions.ModuleAction

Provides module loading commands and verification.

action()

Returns a list of bash commands that should perform the action for the given module.

Return type:list(str)
verify()

Returns a list of bash commands that should verify that the module action has been performed successfully. These should set the test status to ENV_FAILED, and exit the bash script with a non-zero return code.

class pavilion.module_actions.ModuleSwap(module_name, version, old_module_name, old_version)

Bases: pavilion.module_actions.ModuleAction

Provides module swapping commands and verification.

action()

Returns a list of bash commands that should perform the action for the given module.

Return type:list(str)
old_module
verify()

Returns a list of bash commands that should verify that the module action has been performed successfully. These should set the test status to ENV_FAILED, and exit the bash script with a non-zero return code.

class pavilion.module_actions.ModuleUnload(module_name, version=None)

Bases: pavilion.module_actions.ModuleAction

Provides module unloading commands and verification.

action()

Returns a list of bash commands that should perform the action for the given module.

Return type:list(str)
verify()

Returns a list of bash commands that should verify that the module action has been performed successfully. These should set the test status to ENV_FAILED, and exit the bash script with a non-zero return code.