caelus.config – Caelus Configuration Infrastructure¶
caelus.config
performs the following tasks:
Configure the behavior of the Caelus python library using YAML based configuration files.
Provide an interface to Caelus CML installations and also aid in automated discovery of installed Caelus versions.
Get the configuration object |
|
Reset the configuration object |
|
Reset to default configuration |
|
Get the CML environment for the version requested |
|
Get the CML environment for the latest version available. |
|
CML Environment Interface. |
Caelus Python Configuration¶
The config
module provides functions and classes for
loading user configuration via YAML files and a central location to configure
the behavior of the Caelus python library. The user configuration is stored in
a dictionary format within the CaelusCfg
and can
be modified during runtime by user scripts. Access to the configuration object
is by calling the get_config()
method defined within this module which
returns a fully populated instance of the configuration dictionary. This module
also sets up logging (to both console as well as log files) during the
initialization phase.
- class caelus.config.config.CaelusCfg[source]¶
Bases:
Struct
Caelus Configuration Object
A (key, value) dictionary containing all the configuration data parsed from the user configuration files. It is recommended that users obtain an instance of this class via the
get_config()
function instead of directly instantiating this class.- yaml_decoder¶
alias of
StructYAMLLoader
- yaml_encoder¶
alias of
StructYAMLDumper
- caelus.config.config.configure_logging(log_cfg=None)[source]¶
Configure python logging.
If
log_cfg
is None, then the basic configuration of python logging module is used.See Python Logging Documentation for more information.
- Parameters:
log_cfg – Instance of
CaelusCfg
- caelus.config.config.get_caelus_root()[source]¶
Get Caelus root directory
In Unix-y systems this returns
${HOME}/Caelus
and on Windows it returnsC:\Caelus
.- Returns:
Path to Caelus root directory
- Return type:
path
- caelus.config.config.get_config(base_cfg=None, init_logging=False)¶
Get the configuration object
On the first call, initializes the configuration object by parsing all available configuration files. Successive invocations return the same object that can be mutated by the user. The config dictionary can be reset by invoking
reload_config()
.
- caelus.config.config.get_default_config()[source]¶
Return a fresh instance of the default configuration
This function does not read the
caelus.yaml
files on the system, and returns the configurations shipped with CPL.- Returns:
The default configuration
- Return type:
- caelus.config.config.rcfiles_loaded()¶
Return a list of the configuration files that were loaded
- caelus.config.config.reload_config(base_cfg=None)¶
Reset the configuration object
Forces reloading of all the available configuration files and resets the modifications made by user scripts.
See also:
reset_default_config()
- Parameters:
base_cfg – A CMLEnv object to use instead of default
- Returns:
The configuration dictionary
- Return type:
- caelus.config.config.reset_default_config()¶
Reset to default configuration
Resets to library default configuration. Unlike
reload_config()
, this function does not load the configuration files.- Returns:
The configuration dictionary
- Return type:
- caelus.config.config.search_cfg_files()[source]¶
Search locations and return all possible configuration files.
The following locations are searched:
The path pointed by
CAELUSRC_SYSTEM
The user’s home directory
~/.caelus/caelus.yaml
on Unix-like systems, and%APPDATA%/caelus/caelus.yaml
on Windows systems.The path pointed by
CAELUSRC
, if defined.The file
caelus.yaml
in the current working directory
- Returns:
List of configuration files available
Caelus CML Environment Manager¶
cmlenv
serves as a replacement for Caelus/OpenFOAM bashrc
files, providing ways to discover installed versions as well as interact with
the installed Caelus CML versions. By default, cmlenv
attempts to locate
installed Caelus versions in standard locations:
~/Caelus/caelus-VERSION
on Unix-like systems, and in C:Caelus
in Windows systems. Users can override the default behavior and point to
non-standard locations by customizing their Caelus Python configuration file.
- class caelus.config.cmlenv.CMLEnv(cfg)[source]¶
Bases:
object
CML Environment Interface.
This class provides an interface to an installed Caelus CML version.
- Parameters:
cfg (CaelusCfg) – The CML configuration object
- property bin_dir¶
Return the bin directory for executable
- property build_dir¶
Return the build platform directory
- property environ¶
Return an environment for running Caelus CML binaries
- property etc_dirs¶
Return list of etc directories
- property lib_dir¶
Return the bin directory for executable
- property module_list¶
Return list of modules
- property mpi_bindir¶
Return the MPI executables path for this installation
- property mpi_dir¶
Return the MPI directory for this installation
- property mpi_libdir¶
Return the MPI library path for this installation
- property project_dir¶
Return the project directory path
Typically
~/Caelus/caelus-VERSION
- property root¶
Return the root path for the Caelus install
Typically on Linux/OSX this is the
~/Caelus
directory.
- property user_bindir¶
Return path to user bin directory
- property user_dir¶
Return the user directory
- property user_libdir¶
Return path to user lib directory
- property version¶
Return the Caelus version
- class caelus.config.cmlenv.FOAMEnv(cfg)[source]¶
Bases:
object
OpenFOAM environment interface
- Parameters:
cfg (CaleusCfg) – The CML configuration object
- property bin_dir¶
Return the bin directory for executables
- property build_dir¶
Return the build platform directory
- property build_option¶
Return the build option
- property environ¶
Return the environment
- property etc_dirs¶
Return list of etc directories
- property foam_api_info¶
Get API information
- property foam_bashrc¶
Return the path to the bashrc file
- property foam_version¶
Return the OpenFOAM version
Unlike
version
this reports the version fromWM_PROJECT_VERSION
- property lib_dir¶
Return the lib directory for executables
- property module_list¶
Return modules to be activated
- property mpi_bindir¶
Return the path to MPI binraries
- property mpi_dir¶
Return the path to MPI dir
- property mpi_libdir¶
Return the path to MPI libraries
- property project_dir¶
Return the project directory path
Typically
~/Caelus/caelus-VERSION
- property root¶
Return the root path for the OpenFOAM install
Typically on Linux/OSX this is the
~/OpenFOAM
directory.
- property site_dir¶
Return site directory
- property site_libdir¶
Return the site lib directory
- property user_bindir¶
Return the user binary directory
- property user_dir¶
Return the user directory
- property user_libdir¶
Return the user lib directory
- property version¶
Return the project version
This is the project version as defined in the Caelus configuration file. For the exact version reported in OpenFOAM WMake use
foam_version()
- class caelus.config.cmlenv.HelyxEnv(cfg)[source]¶
Bases:
object
Engys Helyx environment
- Parameters:
cfg (CaelusCfg) – The CML configuration object
- property bin_dir¶
Return the bin directory for executables
- property build_dir¶
Return the build platform directory
- property build_option¶
Return the build option
- property environ¶
Return the environment
- property etc_dirs¶
Return list of etc directories
- property foam_bashrc¶
Return the path to the bashrc file
- property lib_dir¶
Return the lib directory for executables
- property module_list¶
Return modules to be activated
- property mpi_bindir¶
Return the path to MPI binraries
- property mpi_dir¶
Return the path to MPI dir
- property mpi_libdir¶
Return the path to MPI libraries
- property project_dir¶
Return the project directory path
- property site_dir¶
Return site directory
- property site_libdir¶
Return the site lib directory
- property user_bindir¶
Return the user binary directory
- property user_dir¶
Return the user directory
- property user_libdir¶
Return the user lib directory
- property version¶
Return the helyxcore project version
- caelus.config.cmlenv.cml_get_latest_version()¶
Get the CML environment for the latest version available.
- Returns:
The environment object
- Return type:
- caelus.config.cmlenv.cml_get_version(version=None)¶
Get the CML environment for the version requested
If version is None, then it returns the version set as default in the configuration file.
- Parameters:
version (str) – Version string
- Returns:
The environment object
- Return type:
- caelus.config.cmlenv.discover_versions(root=None)[source]¶
Discover Caelus versions if no configuration is provided.
If no root directory is provided, then the function attempts to search in path provided by
get_caelus_root()
.- Parameters:
root (path) – Absolute path to root directory to be searched