4.7.2 pde.tools.config module
Handles configuration variables of the package.
Class representing a single parameter. |
|
Class handling general (nested) configurations. |
|
Tries to load certain python packages and returns their version. |
|
Helper function converting a version string into a list of integers. |
|
Checks whether a package has a sufficient version. |
|
Read package names from a requirements file. |
|
Read version number of ffmpeg program. |
|
Check whether the code is running in a high-performance computing environment. |
|
Obtain information about the compute environment. |
- exception AccessError[source]
Bases:
RuntimeErrorRaised when a configuration change violates the active access mode.
- class Config(items=None, *, mode='update')[source]
Bases:
NestedDict[Parameter]Class handling general (nested) configurations.
Configurations are basically (nested) dictionaries with string keys that hold
Parametervalues, which contain a value with some extra information. Moreover, configurations have a mode that controls whether the configuration is writeable or not.- Parameters:
items (dict, optional) – Configuration values that should be added or overwritten to initialize the configuration.
mode (str) –
Defines the mode in which the configuration is used. Possible values are
insert: any new configuration key can be inserted
update: only the values of pre-existing items can be updated
locked: no values can be changed
Note that the items specified by items will always be inserted, independent of the mode.
- changed_mode(**kwargs)[source]
Temporarily switch to mode and restore the previous mode afterwards.
- Parameters:
**kwargs – Keyword arguments forwarded to
ConfigMode._setstate(), such as node, leaf, and delete.- Yields:
ConfigMode – The mode controller with the temporary mode applied.
- copy()[source]
Creates a structural copy with copied nested mappings.
Child dictionaries and child NestedDict instances are copied, while non-mapping leaf values are reused by reference.
- Returns:
New instance containing copied nested structure.
- Return type:
- property mode: ConfigMode
Current mutable mode descriptor shared across the whole config tree.
- replace_recursive(other, delete_extra=False)[source]
Recursively replaces data of the current instance by another mapping.
- class ConfigMode(node=Modes.UPDATE, leaf=Modes.INSERT, delete=False)[source]
Bases:
objectMutable object storing the current configuration mode.
- Parameters:
- classmethod from_str(value)[source]
Create a mode descriptor from a textual mode name.
- Parameters:
value (str) – Mode name. Supported values are
"insert","update", and"locked".- Returns:
Newly created mode descriptor.
- Return type:
- Raises:
ValueError – If value is not one of the supported mode names.
- class Modes(value)[source]
Bases:
EnumAccess modes controlling how configuration entries can be modified.
- INSERT = 'insert'
- READONLY = 'readonly'
- UPDATE = 'update'
- class Parameter(value, *, default_value=<_OMITTED_TYPE object>, cls=<_OMITTED_TYPE object>, description='', hidden=False, extra=None)[source]
Bases:
objectClass representing a single parameter.
- Parameters:
value (str | float | int | bool | None) – The current value of the parameter.
default_value (str | float | int | bool | None | _OMITTED_TYPE) – The fallback value used when the parameter is reset. If omitted, the current value is used.
cls (object | _OMITTED_TYPE) – Type used to convert assigned values.
description (str) – Human-readable explanation of the parameter.
hidden (bool) – Flag indicating whether the parameter should be hidden in summaries.
extra (dict[str, Any] | None) – Optional metadata stored alongside the parameter.
- convert(value=<_OMITTED_TYPE object>)[source]
Converts a value into the correct type for this parameter. If value is not given, the current value is converted.
Note that this does not make a copy of the values, which could lead to unexpected effects where the default value is changed by an instance.
- default_value: str | float | int | bool | None | _OMITTED_TYPE = <pde.tools.config._OMITTED_TYPE object>
- check_package_version(package_name, min_version)[source]
Checks whether a package has a sufficient version.
- environment()[source]
Obtain information about the compute environment.
- Returns:
information about the python installation and packages
- Return type:
- get_ffmpeg_version()[source]
Read version number of ffmpeg program.
- Returns:
Detected version string, or None if ffmpeg is unavailable or the version could not be parsed.
- Return type:
str | None
- get_package_versions(packages, *, na_str='not available')[source]
Tries to load certain python packages and returns their version.
- is_hpc_environment()[source]
Check whether the code is running in a high-performance computing environment.
- Returns:
True if running in an HPC environment, False otherwise.
- Return type: