stable_learning_control.utils.log_utils.helpers
Several logging related helper functions.
Attributes
Functions
|
Colorize a string. |
|
Print a colorized message to stdout. |
|
Sets up the output_dir for a logger and returns a dict for logger kwargs. |
|
Convert a dictionary to a markdown table. |
Module Contents
- stable_learning_control.utils.log_utils.helpers.colorize(string, color, bold=False, highlight=False)[source]
Colorize a string.
See also
This function wraps the
gym.utils.colorize()
function to make sure that it also works with empty color strings.- Parameters:
- Returns:
Colorized string.
- Return type:
- stable_learning_control.utils.log_utils.helpers.log_to_std_out(msg, color='', bold=False, highlight=False, type=None, *args, **kwargs)[source]
Print a colorized message to stdout.
- Parameters:
msg (str) – Message you want to log.
color (str, optional) – Color you want the message to have. Defaults to
""
.bold (bool, optional) – Whether you want the text to be bold text has to be bold.
highlight (bool, optional) – Whether you want to highlight the text. Defaults to
False
.type (str, optional) – The log message type. Options are:
info
,warning
anderror
. Defaults toNone
.*args – All args to pass to the print function.
**kwargs – All kwargs to pass to the print function.
- stable_learning_control.utils.log_utils.helpers.setup_logger_kwargs(exp_name, seed=None, save_checkpoints=False, use_tensorboard=False, tb_log_freq='low', use_wandb=False, wandb_job_type=DEFAULT_WANDB_JOB_TYPE, wandb_project=DEFAULT_WANDB_PROJECT, wandb_group=None, wandb_run_name=None, quiet=False, verbose_fmt=DEFAULT_STD_OUT_TYPE, verbose_vars=[], data_dir=None, datestamp=False)[source]
Sets up the output_dir for a logger and returns a dict for logger kwargs.
If no seed is given and datestamp is false,
output_dir = data_dir/exp_name
If a seed is given and datestamp is false,
output_dir = data_dir/exp_name/exp_name_s[seed]
If datestamp is true, amend to
output_dir = data_dir/YY-MM-DD_exp_name/YY-MM-DD_HH-MM-SS_exp_name_s[seed]
You can force datestamp=True by setting
FORCE_DATESTAMP=True
instable_learning_control/user_config.py
.- Parameters:
exp_name (str) – Name for experiment.
seed (int, optional) – Seed for random number generators used by experiment.
save_checkpoints (bool, optional) – Save checkpoints during training. Defaults to
False
.use_tensorboard (bool, optional) – Whether you want to use TensorBoard. Defaults to
True
.tb_log_freq (str, optional) – The TensorBoard log frequency. Options are
low
(Recommended: logs at every epoch) andhigh
(logs at every SGD update ” batch). Defaults tolow
since this is less resource intensive.use_wandb (bool, optional) – Whether you want to use Weights & Biases. Defaults to
False
.wandb_job_type (str, optional) – The Weights & Biases job type. Defaults to
None
.wandb_project (str, optional) – The name of the Weights & Biases project you want to log to. Defaults to
None
.wandb_group (str, optional) – The name of the Weights & Biases group you want to assign the run to. Defaults to
None
.wandb_run_name (str, optional) – The name of the Weights & Biases run. Defaults to
None
which means that the run name is automatically generated.quiet (bool, optional) – Whether you want to suppress logging of the diagnostics to the stdout. Defaults to
False
.verbose_fmt (str, optional) – The format in which the diagnostics are displayed to the terminal. Options are
table
which supplies them as a table andline
which prints them in one line. Defaults toline
.verbose_vars (list, optional) – A list of variables you want to log to the stdout. By default all variables are logged.
data_dir (str, optional) – Path to folder where results should be saved. Default is the
DEFAULT_DATA_DIR
instable_learning_control/user_config.py
. Defaults toNone
.datestamp (bool, optional) – Whether to include a date and timestamp in the name of the save directory. Defaults to
False
.
- Returns:
- logger_kwargs
A dict containing output_dir and exp_name.
- Return type: