helios.core.loggers.base

Classes

Logger

Base class for all Helios' loggers.

Functions

get_default_log_name(→ str)

Generate the default name used for loggers.

Module Contents

class helios.core.loggers.base.Logger[source]

Bases: abc.ABC

Base class for all Helios’ loggers.

Each logger sub-class is in charge of the following:
  • Their own storage (if applicable) under log_root.

  • Their own persistent settings so they can be resumed.

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

Finish configuring the logger.

Called after the logger has been created. If the logger is being restored, then this is called after load_state_dict() is called. Each derived class should configure its own folder under log_root and create it as needed.

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

  • log_root – root directory for all logs. None means no on-disk output is desired.

  • is_resumeTrue when continuing a previous run.

abstractmethod flush() None[source]

Flush any buffered data to disk.

abstractmethod close() None[source]

Close the logger and release any held resources.

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

Return a dictionary containing the logger state.

Returns:

A dictionary that can be passed to load_state_dict() to restore the logger to the same state.

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

Restore the logger state from a previously saved dictionary.

Must be called before setup() when resuming so that setup can use the saved paths.

Parameters:

state_dict – the state dictionary returned by a prior call to state_dict().

helios.core.loggers.base.get_default_log_name(run_name: str) str[source]

Generate the default name used for loggers.

Parameters:

run_name – the name of the run.

Returns:

The string with the default name.