releso.verbosity.Verbosity

class releso.verbosity.Verbosity(*, save_location: Path, logger_name: str | None = None, parser: Literal['ERROR', 'WARNING', 'DEBUG', 'INFO'] = 'INFO', environment: Literal['ERROR', 'WARNING', 'DEBUG', 'INFO'] = 'INFO', logfile_location: str = 'logging/', console_logging: bool = False, base_logger_name: str = 'ReLeSO', environment_extension: str = 'environment')

Bases: BaseModel

Verbosity class.

Defines the settings for the different loggers used in the current experiment. This class is the only class which is copied to all children. (this happens outside of the the standard channels and will hopefully not break with multiprocessing)

Please note, the parser logger only ever can have the following name ReLeSO_parser

__init__(**data: Any) None

Constructor verbosity parser.

Methods

add_environment_logger_with_name_extension(...)

Initializes a logger with the settings for the environment logger.

convert_literal_str_to_verbosity_level(v)

Validator for parser and environment variable.

convert_to_pathlib_add_datetime(v)

Add timestamp to save_location, of applicable.

get_logger()

Gets the currently defined environment logger.

make_logfile_location_absolute(v, values)

Validation function resolves and makes the log path absolute.

set_logger_name_recursively(logger_name)

Set the logger_name variable for all child elements.

Attributes

parser

VerbosityLevel of the parser logger.

environment

VerbosityLevel of the environment parsers.

logfile_location

Path where the log files should be saved to.

console_logging

Whether or not to also print the log messages to the console.

base_logger_name

Base name of all logger.

environment_extension

Name extensions for all environment logger.

save_location

Definition of the save location of the logs and validation results.

logger_name

name of the logger.

add_environment_logger_with_name_extension(extension: str) Logger

Initializes a logger with the settings for the environment logger.

The name of the base environment logger is extended by the extension. The name if the created logger is found by joining the strings of the following variables by an underscore. Verbosity.base_logger_name, Verbosity.environment_extension, extension Any empty strings are ignored.

Parameters:

extension (str) – Used to differentiate between different environment loggers. If empty the base logger is created/returned.

Returns:

Logger of the name defined name. The name definition is explained in the main documentation of the function.

Return type:

logging.Logger

base_logger_name: str

Base name of all logger. Defaults to “ReLeSO”

console_logging: bool

Whether or not to also print the log messages to the console.

classmethod convert_literal_str_to_verbosity_level(v)

Validator for parser and environment variable.

Validation function converting the string representation of the enum to the correct enum item.

Parameters:

v (str)) – String representation of the VerbosityLevel

Returns:

Enum object of the wanted value

Return type:

VerbosityLevel

environment: Literal['ERROR', 'WARNING', 'DEBUG', 'INFO']

VerbosityLevel of the environment parsers. These loggers will generate messages during the execution of the experiments. (Training and Validation)

environment_extension: str

Name extensions for all environment logger. Defaults to “environment”

logfile_location: str

Path where the log files should be saved to. Will be inside the base_save_location.

classmethod make_logfile_location_absolute(v, values)

Validation function resolves and makes the log path absolute.

Also adds the current timestamp to the log path if a {} is present in the given path.

Parameters:
  • v (str) – [description]

  • values ([type]) – [description]

Returns:

pathlib representation of the path with if applicable the current timestamp

Return type:

pathlib.Path

parser: Literal['ERROR', 'WARNING', 'DEBUG', 'INFO']

VerbosityLevel of the parser logger. This logger should only generate messages during the setup of the experiment.