• Docs >
  • rectorch.configuration

rectorch.configuration

Class list

rectorch.configuration.DataConfig(file_path)

Class containing the configurations for reading/writing the data set.

rectorch.configuration.ModelConfig(file_path)

Class containing the configurations for creating, training and testing the model.

rectorch.configuration.ConfigManager(…)

Wrapper class for both the data and model configurations.

The module contains useful classes to manage the configuration files.

Configuration files are useful to correctly initialize the data processing and the recommendation engines. Configuration files must be .json files with a specific format. Details about the file formats are described in Configuration files format.

class rectorch.configuration.DataConfig(file_path)[source]

Class containing the configurations for reading/writing the data set.

Parameters
  • file_pathstr
    • The path to the data configuration .json file.

    Note

    The data configuration file must have the structure described in Configuration files format.

    class rectorch.configuration.ModelConfig(file_path)[source]

    Class containing the configurations for creating, training and testing the model.

    Parameters
  • file_pathstr
    • The path to the model configuration .json file.

    Note

    The data configuration file must have the structure described in Configuration files format.

    Attributes
  • modelDefaultMunch
    • Munch object containing the model’s configurations according to the model key in the file_path json file.

  • trainDefaultMunch
    • Munch object containing the model training’s configurations according to the train key in the file_path json file.

  • testDefaultMunch
    • Munch object containing the test configurations according to the test key in the file_path json file.

  • samplerDefaultMunch
    • Munch object containing the sampler configurations according to the model key in the file_path json file.

    class rectorch.configuration.ConfigManager(data_config_path, model_config_path)[source]

    Wrapper class for both the data and model configurations.

    Parameters
  • data_config_pathstr
    • The path to the data configuration .json file.

  • model_config_pathstr
    • The path to the model configuration .json file.

    Examples

    Initializing the ConfigManager singleton:

    >>> from rectorch.configuration import ConfigManager
    >>> ConfigManager("path/to/the/dataconfig/file", "path/to/the/modelconfig/file")
    ConfigManager(data_config=DataConfig(...), model_config=ModelConfig(...))
    
    Attributes
  • data_configDataConfig
    • Object containing the configurations for reading/writing the data set.

  • model_configModelConfig
    • Object containing the configurations for creating, training and testing the model.

    classmethod get()[source]

    Return the singleton ConfigManager instance.

    Returns
  • ConfigManager
  • Raises
  • Exception
    • Raised when the singleton ConfigManager object has not been previously created. To initialize the ConfigManager simply call its constructor. Please, see Examples.

    Examples

    >>> from rectorch.configuration import ConfigManager
    >>> man = ConfigManager.get()
    Exception: Singleton object not instantiated!
    

    The ConfigManager singleton object must be initialized to get it.

    >>> ConfigManager("path/to/the/dataconfig/file", "path/to/the/modelconfig/file")
    ConfigManager(data_config=DataConfig(...), model_config=ModelConfig(...))
    >>> man = ConfigManager.get()
    >>> man
    ConfigManager(data_config=DataConfig(...), model_config=ModelConfig(...))
    

    Getting the configuration objects is as easy as getting an attribute

    >>> man.data_config
    DataConfig(...)
    >>> man.model_config
    ModelConfig(...)