helios.core.loggers

Logging sub-package for Helios.

Holds all of the logger classes.

Submodules

Classes

LoggerType

Defines the types of loggers.

Functions

create_loggers(→ None)

Construct the logger instances and add them to the active table.

setup_loggers(→ None)

Call setup() on every active logger for a fresh run.

restore_loggers(→ None)

Restore active loggers from a previous run.

get_logger(→ base.Logger)

Return the active logger identified by name.

get_logger_state_dicts(→ dict[str, dict[str, Any]])

Return the state dictionaries of all active loggers.

flush_loggers(→ None)

Flush all active loggers.

close_loggers(→ None)

Close all active loggers and remove them from the active table.

is_root_logger_active(→ bool)

Return True if the root logger has been created.

get_root_logger(→ root.RootLogger)

Get the root logger instance.

get_tensorboard_writer(...)

Return the Tensorboard writer.

get_wandb_writer(→ wandb.WandbWriter | None)

Return the WandbWriter.

Package Contents

class helios.core.loggers.LoggerType[source]

Bases: enum.Enum

Defines the types of loggers.

ROOT = 'root'
TENSORBOARD = 'tensorboard'
WANDB = 'wandb'
helios.core.loggers.create_loggers(enable_tensorboard: bool = True, capture_warnings: bool = True, wandb_args: wandb.WandbArgs | None = None) None[source]

Construct the logger instances and add them to the active table.

The RootLogger is always created, while additional loggers are only crated when their corresponding flag is True. If a logger has already been created then this function does nothing, making it safe to call multiple times.

In distributed training, this function should be called after the processes have been created to ensure each process gets a copy of the loggers.

Parameters:
  • enable_tensorboard – enable the Tensorboard writer. Defaults to True.

  • capture_warnings – if True, warnings.warn() output is captured by the root logger. Defaults to True.

  • wandb_writer – an already-constructed WandbWriter instance to register, or None to skip W&B logging. Defaults to None.

helios.core.loggers.setup_loggers(run_name: str, log_root: pathlib.Path | None = None) None[source]

Call setup() on every active logger for a fresh run.

This function should be called when the loggers don’t need to continue from a previous run. If you need that, call restore_loggers() instead.

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

  • log_root – root directory under which each logger will create its own subfolder. None disables on-disk output.

helios.core.loggers.restore_loggers(run_name: str, log_root: pathlib.Path | None = None, loggers_state: dict[str, dict[str, Any]] | None = None) None[source]

Restore active loggers from a previous run.

For each active logger whose name appears in the loggers_state dictionary:

1. Call load_state_dict() so that their previous state is loaded. 1. Call setup() so the loggers re-use the original paths.

If an active logger does not have an entry in the dictionary, then it is configured to start fresh.

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

  • log_root – root directory under which each logger will look for its subfolder. None disables on-disk output.

  • loggers_state – mapping of {logger_name: state_dict} as returned by a prior call to get_logger_state_dicts(). None is treated the same as an empty mapping.

helios.core.loggers.get_logger(name: LoggerType) base.Logger[source]

Return the active logger identified by name.

Parameters:

name – the LoggerType value identifying the desired logger.

Returns:

The requested Logger instance.

Raises:

KeyError – if the requested logger has not been created.

helios.core.loggers.get_logger_state_dicts() dict[str, dict[str, Any]][source]

Return the state dictionaries of all active loggers.

Returns:

The dictionary containing the state of all active loggers.

helios.core.loggers.flush_loggers() None[source]

Flush all active loggers.

helios.core.loggers.close_loggers() None[source]

Close all active loggers and remove them from the active table.

helios.core.loggers.is_root_logger_active() bool[source]

Return True if the root logger has been created.

helios.core.loggers.get_root_logger() root.RootLogger[source]

Get the root logger instance.

Returns:

The root logger.

Raises:

KeyError – if the root logger has not been created.

helios.core.loggers.get_tensorboard_writer() tensorboard.TensorboardWriter | None[source]

Return the Tensorboard writer.

If Tensorboard is disabled, this function will return None.

Returns:

The Tensorboard logger, or None if it doesn’t exist.

helios.core.loggers.get_wandb_writer() wandb.WandbWriter | None[source]

Return the WandbWriter.

If Wandb is disabled, this function will return None.

Returns:

The Wandb logger, or None if it doesn’t exist.