skeltorch.Configuration

class skeltorch.Configuration(logger)

Skeltorch configuration class.

Configuration parameters given in the configuration file are stored as class attributes dynamically. The class provides an easy-to-use interface to get them without having to handle file parsing.

Read our tutorial “Dealing with configuration files” to get details about how to manage configuration files inside your project.

logger

Logger object.

Type:logging.Logger
create(self, config_path, config_schema_path=None)

Loads (and validates) a raw configuration file.

Uses the arguments --config-path and --config-schema-path of the init pipeline to load a raw configuration file and, if provided, validate it with the schema. Only called during the creation of a new experiment.

Parameters:
  • config_path (str) – --config-path command argument.
  • config_schema_path (str or None) – --config-schema-path command argument.
Raises:
  • json.decoder.JSONDecodeError – Raised when the format of one of the .json files is not valid.
  • jsonschema.exceptions.ValidationError – Raised when the configuration file does not match the schema.
get(self, config_cat, config_param)

Gets the parameter named config_param of the category config_cat.

Parameters:
  • config_cat (str) – Category of the configuration parameter.
  • config_param (str) – Identifier of the configuration parameter.
Returns:

Retrieved configuration value.

Return type:

any

load(self, config_file_path)

Loads class attributes from the binary file stored in config_file_path.

Parameters:config_file_path (str) – Path where the binary file is stored.
save(self, config_file_path)

Saves class attributes inside a binary file stored in config_file_path.

Parameters:config_file_path (str) – Path where the binary file will be stored.
set(self, config_cat, config_param, config_value)

Sets the parameter named config_param inside the category config_cat with the value config_value.

Parameters:
  • config_cat (str) – Category of the configuration parameter.
  • config_param (str) – Identifier of the configuration parameter.
  • config_value (any) – Configuration value to set.