releso.base_model.BaseModel

class releso.base_model.BaseModel(*, save_location: Path, logger_name: str | None = None)

Bases: BaseModel

Base of all ReLeSO objects used for parsing.

Base class for all ReLeSO classes which are needed for the command line based application of this toolbox.

__init__(**data: Any) None

Constructor for the ReLeSO basemodel object.

Methods

convert_to_pathlib_add_datetime(v)

Add timestamp to save_location, of applicable.

get_logger()

Gets the currently defined environment logger.

set_logger_name_recursively(logger_name)

Set the logger_name variable for all child elements.

Attributes

save_location

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

logger_name

name of the logger.

classmethod convert_to_pathlib_add_datetime(v: str)

Add timestamp to save_location, of applicable.

Adds a datetime timestamp to the save_location if {} present and current slurm job id if available. Task arrays will be added to the same folder and each task gets its own subfolder. This is done to make it easier to differentiate different runs without the need to change the base name with every run and to easily group similar runs.

This function also ensures that the directory is/directories are created.

Parameters:

v ([type]) – Value to validate

Returns:

Path like object. If applicable with identifications.

Return type:

pathlib.Path

get_logger() Logger

Gets the currently defined environment logger.

If multiprocessing is part of the logger name the multiprocessing standard logger will be called.

Returns:

logger which is currently to be used.

Return type:

logging.Logger

logger_name: str | None

name of the logger. If this variable gives you trouble, the framework is at least a little bit buggy. Does not need to be set. And might be changed if set by user, if multi-environment training is utilized.

save_location: Path

Definition of the save location of the logs and validation results. Should be given as a standard string will be pre-converted into a pathlib.Path. If {} is present in the string the current timestamp is added if in a slurm job SLURM_JOB_ID are added.

set_logger_name_recursively(logger_name: str)

Set the logger_name variable for all child elements.

Sets the given logger_name for the current object and all attributes which have the set_logger_recursively method.

Note

Please note: It is the callings functions responsibility to ensure that the logger actually exists.

Parameters:

logger_name (str) – Name of the logger to set.