ipsl_common
Modules
cli
Functions
existing_dir
existing_dir(path: str | Path)
Check if path points to an existing directory
Source code in ipsl_common/cli.py
15 16 17 18 19 20 21 22 | |
existing_file
existing_file(path: str | Path)
Check if path points to an existing file
Source code in ipsl_common/cli.py
5 6 7 8 9 10 11 12 | |
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 | |
machine
Functions
is_espri_spirit
is_espri_spirit() -> bool
Check if this is ESPRI/Spirit machine (1 or 2)
Source code in ipsl_common/machine.py
17 18 19 | |
is_espri_spiritx
is_espri_spiritx() -> bool
Check if this is ESPRI/SpiritX machine (1 or 2)
Source code in ipsl_common/machine.py
22 23 24 | |
is_idris_jean_zay
is_idris_jean_zay() -> bool
Check if this is IDRIS/JeanZay machine (also pp, visu)
Source code in ipsl_common/machine.py
7 8 9 | |
is_idris_jean_zay_pp
is_idris_jean_zay_pp() -> bool
Check if this is IDRIS/JeanZay post-processing machine
Source code in ipsl_common/machine.py
12 13 14 | |
is_tgcc_irene
is_tgcc_irene() -> bool
Check if this is TGCC/Irene machine
Source code in ipsl_common/machine.py
27 28 29 | |
modipsl
Modules
mod_file
Read mod.def file from the IPSL/modipsl project.
The mod.def file contains definitions of coupled model configurations. A single configuration consists of one or more components (e.g. athmospheric model, dynamics, I/O system, experiments).
Examples:
from ipsl_common.modipsl.mod_file import load
with open("mod.def", "r") as f:
configs = load(f)
The loaded dictionary has a fixed schema. Typically, it looks as follows:
{
'configuration': {
'GRISLI': {
'description': ['GRISLI stand-alone for Antarctica icesheets (prototype)']
'components': [
{
'modipsl_dir': '.',
'name': 'libIGCM',
'repository': 10,
'revision': 'HEAD',
'variant': 'trunk/libIGCM'
},
{
'modipsl_dir': 'modeles',
'name': 'GRISLI',
'repository': 26,
'revision': 'HEAD',
'variant': 'branches/xios'
},
(...)
],
},
(...)
},
'repository': {
7: {
'clone_url': 'https://gitlab.in2p3.fr/ipsl/projets/nemogcm/nemo.git',
'type': 'git'
},
8: {
'clone_url': '--username icmc_users https://forge.ipsl.fr/igcmg/svn',
'type': 'svn'
},
(...)
}
}
Warning
Because this module uses iterative matching to patterns (with re.finditer), it doesn't have a capability to tell, when the *.mod file is not well formatted, nor invalid. It will siliently skip non-matched lines and move on!
Functions
load
load(buffer: TextIOBase) -> dict
Load mod.def file from a text/file buffer.
Parameters:
-
(bufferTextIOBase) –text or file buffer with the mod.def file
Returns:
-
dict(dict) –Loaded mod.def file
Source code in ipsl_common/modipsl/mod_file.py
139 140 141 142 143 144 145 146 147 148 | |
loads
loads(content: str) -> dict
Load mod.def file from a string.
Parameters:
-
(contentstr) –content of the mod.def file
Returns:
-
dict(dict) –Loaded mod.def file
Source code in ipsl_common/modipsl/mod_file.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
python
Python-related functions, such as: checking Python version.
Functions
check_minimal_version
check_minimal_version(
major: int,
minor: int,
reason: str = "",
exit_on_fail: bool = False,
) -> None
Check if minimal Python version is present. If not, print warning (default) or exit program entirely. The passed major.minor version is not validated and it can have any value, e.g. even non-existing Python versions like 4.24.
Source code in ipsl_common/python.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |