Skip to content

layer_management

OM's layer management.

This module contains classes and functions that mange OM's various data processing and extraction layers.

import_class_from_layer(*, layer_name, class_name)

Imports a class from an OM's layer.

This function imports a class, identified by the class_name argument, from a layer identified by the layer_name argument. The function looks for the python module containing the layer code in the current directory first. Specifically, it looks for a python file with the same name as the layer. If the function cannot fine the file in the current directory, it imports the layer from the OM's normal installation directories. It then proceeds to import the requested class from the layer module.

Parameters:

Name Type Description Default
layer_name str

The name of the layer from which the class should be imported.

required
class_name str

The name of the class to import.

required

Returns:

Type Description
Union[Type[OmParallelizationProtocol], Type[OmProcessingProtocol], Type[OmDataRetrievalProtocol], None]

The imported class.

Raises:

Type Description
OmMissingLayerClass

Raised when the requested class cannot be found in the specified Python module.

OmMissingLayerModuleFile

Raised when the requested python module cannot be found.

filter_data_sources(*, data_sources, required_data)

Filters a list Data Sources.

This function filters the list of all Data Sources associated with a Data Retrieval class, returning only the subset of Data Sources needed to retrieve the data requested by the user.

Parameters:

Name Type Description Default
data_sources Dict[str, OmDataSourceProtocol]

A list containing the names of all Data Sources available for a Data Retrieval class.

required
required_data List[str]

A list containing the names of the data items requested by the user.

required

Returns:

Type Description
List[str]

A list of Data Source names containing only the needed Data Sources.

Raises:

Type Description
OmMissingDataSourceClassError

Raised when one of the required Data Source class cannot be found in the list of Data Source available for the Data Retrieval.