ml_grid.util.logger_setup

Functions

setup_logger(→ logging.Logger)

Sets up a logger that writes to a file and the console.

Module Contents

ml_grid.util.logger_setup.setup_logger(experiment_dir: str, param_space_index: int, verbose: int = 1, redirect_stdout: bool = True) logging.Logger[source]

Sets up a logger that writes to a file and the console.

This function creates a timestamped main experiment folder and a sub-folder for the specific run (e.g., ‘run_0’). It configures a logger to save all messages to ‘run.log’ inside the sub-folder and also redirects stdout/stderr to this logger.

Parameters:
  • experiment_dir (str) – The path to the parent directory for this group of experimental runs.

  • param_space_index (int) – The index of the parameter space run.

  • verbose (int) – The verbosity level. Higher numbers mean more logs to the console.

  • redirect_stdout (bool) – If True, redirects stdout and stderr to the logger. Defaults to True.

Returns:

The configured logger instance.

Return type:

logging.Logger