Skip to content

parameters

OM's configuration parameter management.

This module contains classes and functions that can be used to manage and validate a set of OM's configuration parameters from a configuration file.

MonitorParameters

See documentation for the __init__ function.

__init__(*, config, source=None, node_pool_size=None)

Storage, retrieval and validation of OM's configuration parameters.

This class stores a set of OM's configuration parameters, subdivided in groups. It is initialized with a set of parameters read from a configuration file written in YAML format. It then allows single parameters or group of parameters to be retrieved, and optionally validated.

In addition to the set of parameters read from the file, this class stores the path to the configuration file itself, in a parameter named configuration_file within the om parameter group.

Parameters:

Name Type Description Default
config str

The absolute or relative path to a YAML-format configuration file.

required

Raises:

Type Description
OMConfigurationFileSyntaxError

Raised if there is a syntax error in OM's configuration file.

get_parameter_group(*, group)

Retrieves an OM's configuration parameter group.

This function retrieves a configuration parameter group from the full set of OM's configuration parameters.

Parameters:

Name Type Description Default
group str

The name of the parameter group to retrieve.

required

Returns:

Type Description
Any

The parameter group.

Raises:

Type Description
OmMissingParameterGroupError

Raised if the requested parameter group is not present in the full set of OM's configuration parameters.

get_parameter(*, group, parameter, parameter_type=None, required=False, default=None)

Retrieves an OM's configuration parameter.

This function retrieves a single parameter from the full set of OM's configuration parameters. Optionally, it also validates the type of the parameter, according to the following rules:

  • If the value of the required argument is True and the parameter cannot be found in OM's configuration file, this function raises an exception.

  • If the value of the required argument is False and the parameter cannot be found in OM's configuration file, this function returns None, or the value of the default argument, if it is provided.

  • If a type is specified for the parameter (the parameter_type argument is not None) and the type of the retrieved parameter does not match the specified one, this function raises an exception.

Parameters:

Name Type Description Default
group str

The name of the parameter group from which the parameter must be retrieved.

required
parameter str

The name of the parameter to retrieve.

required
parameter_type Any

The type of the parameter to retrieve. If a type is specified in this argument, the type of the retrieved parameter will be validated. Defaults to None.

None
required bool

True if the parameter is strictly required and must be present in OM's configuration file, False otherwise. Defaults to False.

False
default Any

The default value that this function should return if the requested parameter cannot be found and the parameter is not strictly required.

None

Returns:

Type Description
Any

The value of the requested parameter, or None, if the parameter was not

Any

found in OM's configuration file, it is not required, and a default value

Any

has not been provided.

Raises:

Type Description
OmMissingParameterGroupError

Raised if the requested parameter group is not present in the full set of OM's configuration parameters.

OmMissingParameterError

Raised if the parameter is required but cannot be found in the full set of OM's configuration parameters.

OmWrongParameterTypeError

Raised if the requested parameter type does not match the type of the retrieved configuration parameter.

add_source_and_node_pool_size_information(*, source=None, node_pool_size=None)

Adds source and node pool size information to the parameter set.

If the name of a data source is provided as an input parameter, this function adds it to the parameter set stored by this class, and makes it available as a parameter with the name source within the om group. If the total number of nodes in OM's node pool is also provided, the information will added to the parameter set and made available as a parameter named node_pool_size within the om group.

Parameters:

Name Type Description Default
source Union[str, None]

A string describing the data event source.

None
node_pool_size Union[int, None]

The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

None

get_parameter_from_parameter_group(*, group, parameter, parameter_type=None, required=False, default=None)

Retrieves the value of an OM's configuration parameter from a parameter group.

This function retrieves the value of a single configuration parameter from a provided group of configuration parameters. Optionally, it validates the type of the parameter according to the following rules:

  • If the value of the required argument is True and the parameter cannot be found in OM's configuration file, this function raises an exception.

  • If the value of the required argument is False and the parameter cannot be found in OM's configuration file, this function returns None, or the value of the default argument, if it is provided.

  • If a type is specified for the parameter (the parameter_type argument is not None) and the type of the retrieved parameter does not match the specified one, this function raises an exception.

Parameters:

Name Type Description Default
group Dict[str, Any]

The parameter group containing the parameter to retrieve.

required
parameter str

The name of the parameter to retrieve.

required
parameter_type Any

The type of the parameter to retrieve. If a type is specified in this argument, the type of the retrieved parameter will be validated. Defaults to None.

None
required bool

True if the parameter is strictly required and must be present in OM's configuration file, False otherwise. Defaults to False.

False
default Any

The default value that this function should return if the requested parameter cannot be found and the parameter is not strictly required.

None

Returns:

Type Description
Any

The value of the requested parameter, or None, if the parameter was not

Any

found in OM's configuration file, it is not required, and a default value

Any

has not been provided.

Raises:

Type Description
OmMissingParameterError

Raised if the parameter is required but cannot be found in the parameter group.

OmWrongParameterTypeError

Raised if the requested parameter type does not match the type of the retrieved configuration parameter.