helios.core.loggers.root¶
Classes¶
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.LoggerLogger 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 ofwarnings.warnis 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.
Nonedisables file logging.is_resume –
Truewhen 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 returnNoneas well.
- info(msg: str, **kwargs: Any) None[source]¶
Log using the
INFOtag.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
WARNINGtag.- Parameters:
msg – the message to log.
kwargs – keyword arguments to
logging.Logger.warning().
- error(msg: str, **kwargs: Any) None[source]¶
Log using the
ERRORtag.- 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().
- 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,Noneis 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().