envmodules
Python interface to EnvModules.
Better Python interface to EnvModules which doesn't pollute
the global environment with the module() function.
Examples:
em = EnvModules()
em.load("gcc", "cdo")
print(em.list_loaded())
Classes
EnvModules
EnvModules(modulehome: str | Path | None = None)
Modern interface to EnvModules.
This class encapsulate the module() function of EnvModules inside
a local environment.
Attributes:
-
envmodule–Reference to the
module()function of EnvModules.
Initialize EnvModules found on specified path (or default).
Parameters:
-
(modulehomestr or Path, default:None) –Path to the EnvModules installation directory.
Source code in ipsl_common/envmodules.py
30 31 32 33 34 35 36 37 38 39 40 41 | |
Attributes
envmodule
instance-attribute
envmodule = locals['module']
locals
instance-attribute
locals: dict = {}
Functions
get_available
get_available(
flatten=True,
) -> list[str] | dict[str, list[str]]
Return available EnvModules.
This method depends on the /usr/bin/modulecmd binary being present.
The classical module() function won't work here, because we need to
capture and then parse the output of the module avail function
which normally is directly passed onto stderr stream.
Parameters:
-
(flattenbool, default:True) –If true (default), the result will be a flat list of modules. Otherwise, a dictionary is returned with keys representing a named-group of modules.
Returns:
-
list[str] | dict[str, list[str]]–list[str] or dict: List or dictionary of available modules.
Source code in ipsl_common/envmodules.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
get_loaded
get_loaded() -> list[str]
Return loaded EnvModules.
Returns:
-
list[str]–list[str]: List of loaded EnvModules.
Source code in ipsl_common/envmodules.py
59 60 61 62 63 64 65 66 67 | |
load
load(*modules) -> bool
Load passed EnvModules.
Returns:
-
bool(bool) –True if loading was successful.
Source code in ipsl_common/envmodules.py
51 52 53 54 55 56 57 | |
purge
purge() -> bool
Purge all loaded EnvModules.
Returns:
-
bool(bool) –True if purging was successful.
Source code in ipsl_common/envmodules.py
43 44 45 46 47 48 49 | |