libmuscle.settings_manager module¶
- class libmuscle.settings_manager.SettingsManager[source]¶
Bases:
object
Manages the current settings for a component instance.
Create a SettingsManager.
Initialises the base and overlay layers to an empty Settings object.
A SettingsManager has two layers of settings, a base layer that contains an immutable collection of settings set in the simulation’s yMMSL description, and an overlay layer that holds settings that have been set at run-time.
- base¶
The base layer.
- overlay¶
The overlay layer.
- get_setting(instance: ymmsl.identity.Reference, setting_name: ymmsl.identity.Reference, typ: Optional[str] = None) Union[str, int, float, List[float], List[List[float]], yatiml.util.bool_union_fix] [source]¶
Returns the value of a setting.
- Parameters
instance – The instance that this value is for.
setting_name – The name of the setting to get the value of.
typ – An optional type designation; if specified the type is checked for a match before returning. Valid values are ‘str’, ‘int’, ‘float’, ‘bool’, ‘[float]’ and ‘[[float]]’.
- Raises
KeyError – If the setting has not been set.
TypeError – If the setting was set to a value that does not match typ.
ValueError – If an invalid value was specified for typ
- libmuscle.settings_manager.has_setting_type(value: Union[str, int, float, List[float], List[List[float]], yatiml.util.bool_union_fix], typ: str) bool [source]¶
Checks whether the value has the given type.
- Parameters
value – A setting value.
typ – A setting type. Valid values are ‘str’, ‘int’, ‘float’, ‘bool’, ‘[float]’, and ‘[[float]]’.
- Returns
True if the type of value matches typ.
- Raises
ValueError – If the type specified is not valid.