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_config |
Get the configuration object |
reload_config |
Reset the configuration object |
reset_default_config |
Reset to default configuration |
cml_get_version |
Get the CML environment for the version requested |
cml_get_latest_version |
Get the CML environment for the latest version available. |
CMLEnv |
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:
caelus.utils.struct.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
caelus.utils.struct.gen_yaml_decoder.<locals>.StructYAMLLoader
-
yaml_encoder
¶ alias of
caelus.utils.struct.gen_yaml_encoder.<locals>.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()
.Parameters: Returns: The configuration dictionary
Return type:
-
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: CaelusCfg
-
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: CaelusCfg
-
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: CaelusCfg
-
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 - The path pointed by
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 -
bin_dir
¶ Return the bin directory for executable
-
build_dir
¶ Return the build platform directory
-
environ
¶ Return an environment for running Caelus CML binaries
-
etc_dirs
¶ Return list of etc directories
-
lib_dir
¶ Return the bin directory for executable
-
module_list
¶ Return list of modules
-
mpi_bindir
¶ Return the MPI executables path for this installation
-
mpi_dir
¶ Return the MPI directory for this installation
-
mpi_libdir
¶ Return the MPI library path for this installation
-
project_dir
¶ Return the project directory path
Typically
~/Caelus/caelus-VERSION
-
root
¶ Return the root path for the Caelus install
Typically on Linux/OSX this is the
~/Caelus
directory.
-
user_bindir
¶ Return path to user bin directory
-
user_dir
¶ Return the user directory
-
user_libdir
¶ Return path to user lib directory
-
version
¶ Return the Caelus version
-
-
class
caelus.config.cmlenv.
FOAMEnv
(cfg)[source]¶ Bases:
object
OpenFOAM environment interface
Parameters: cfg (CaleusCfg) – The CML configuration object -
bin_dir
¶ Return the bin directory for executables
-
build_dir
¶ Return the build platform directory
-
build_option
¶ Return the build option
-
environ
¶ Return the environment
-
etc_dirs
¶ Return list of etc directories
-
foam_api_info
¶ Get API information
-
foam_bashrc
¶ Return the path to the bashrc file
-
foam_version
¶ Return the OpenFOAM version
Unlike
version
this reports the version fromWM_PROJECT_VERSION
-
lib_dir
¶ Return the lib directory for executables
-
module_list
¶ Return modules to be activated
-
mpi_bindir
¶ Return the path to MPI binraries
-
mpi_dir
¶ Return the path to MPI dir
-
mpi_libdir
¶ Return the path to MPI libraries
-
project_dir
¶ Return the project directory path
Typically
~/Caelus/caelus-VERSION
-
root
¶ Return the root path for the OpenFOAM install
Typically on Linux/OSX this is the
~/OpenFOAM
directory.
-
site_dir
¶ Return site directory
-
site_libdir
¶ Return the site lib directory
-
user_bindir
¶ Return the user binary directory
-
user_dir
¶ Return the user directory
-
user_libdir
¶ Return the user lib directory
-
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()
-
-
caelus.config.cmlenv.
cml_get_latest_version
()¶ Get the CML environment for the latest version available.
Returns: The environment object Return type: CMLEnv
-
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: CMLEnv
-
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