smif.data_layer.model_loader module

ModelLoader reads python modules as specified at runtime, loading and instantiating objects.

Summary

Data:

ModelLoader Load Model from config

Reference

class smif.data_layer.model_loader.ModelLoader[source]

Bases: object

Load Model from config

Examples

Call ModelLoader.load() to create, load and return a Model object.

>>> loader = ModelLoader()
>>> sector_model = loader.load(sector_model_config)
>>> conversion_model = loader.load(conversion_model_config)
load(config)[source]

Loads the model class specified by the config, returns an instance of that class using the Model.from_dict method.

Parameters:config (dict) –
The model configuration data. Must include:
  • name (name for smif internal use)
  • path (absolute path to python module file)
  • classname (name of Model implementation class)
  • anything required by the Model.from_dict classmethod
Returns:
Return type:Model
load_model_class(model_name, model_path, classname)[source]

Dynamically load model class

Parameters:
  • model_name (str) – The name used internally to identify the SectorModel
  • model_path (str) – The path to the python module which contains the SectorModel implementation
  • classname (str) – The name of the class of the SectorModel implementation
Returns:

The SectorModel implementation

Return type:

class