helios.core.loggers.root

Classes

RootLogger

Logger used to log while training, optionally to a file.

Module Contents

class helios.core.loggers.root.RootLogger(capture_warnings: bool)[source]

Bases: helios.core.loggers.base.Logger

Logger used to log while training, optionally to a file.

The log file will be placed under log_root. When resuming, the original file is loaded and new output is appended to the file.

Parameters:

capture_warnings – if True, output of warnings.warn is captured in the log.

setup(run_name: str, log_root: pathlib.Path | None, is_resume: bool) None[source]

Finish configuring the root logger.

In particular, this function will create the file logger provided that the input path is not None. If the path points to a file that already exists, then the logger will automatically append to the file, otherwise a new file will be created.

Parameters:
  • run_name – the name of the current run.

  • log_root – root directory for log files. None disables file logging.

  • is_resumeTrue when continuing a previous run.

property logger: logging.Logger

Return the logger instance.

property log_file: pathlib.Path | None

Return the path to the current log file.

If the path for the log file was originally None, this will return None as well.

info(msg: str, **kwargs: Any) None[source]

Log using the INFO tag.

Only available for the main process in distributed training.

Parameters:
  • msg – the message to log.

  • kwargs – keyword arguments to logging.Logger.info().

warning(msg: str, **kwargs: Any) None[source]

Log using the WARNING tag.

Parameters:
  • msg – the message to log.

  • kwargs – keyword arguments to logging.Logger.warning().

error(msg: str, **kwargs: Any) None[source]

Log using the ERROR tag.

Parameters:
  • msg – the message to log.

  • kwargs – keyword arguments to logging.Logger.error().

exception(msg: str, **kwargs: Any) None[source]

Log an exception.

Parameters:
  • msg – the message to log.

  • kwargs – keyword arguments to logging.Logger.exception().

flush() None[source]

Flush all handlers.

close() None[source]

Close all handlers.

state_dict() dict[str, Any][source]

Return a dictionary containing the logger state.

The state will be saved under a key called "log_file" holding the current log-file path (if using). If file logging is disabled, None is stored instead.

Returns:

A dictionary with the logger state.

load_state_dict(state_dict: dict[str, Any]) None[source]

Restore the logger state from a previously saved dictionary.

Parameters:

state_dict – the state dictionary returned by state_dict().