Logging Utilities¶
fusion_bench.utils.rich_utils
¶
display_available_styles()
¶
Display all available styles in a grid.
Source code in fusion_bench/utils/rich_utils.py
enforce_tags(cfg, save_to_file=False)
¶
Prompts user to input tags from command line if no tags are provided in config.
:param cfg: A DictConfig composed by Hydra.
:param save_to_file: Whether to export tags to the hydra output folder. Default is False
.
Source code in fusion_bench/utils/rich_utils.py
print_bordered(message, title=None, style='blue', code_style=None)
¶
Print a message with a colored border.
Args: message (str): The message to print. title (str, optional): The title of the panel. Defaults to None. style (str, optional): The color style for the border. Defaults to "cyan". code_style (str, optional): The syntax highlighting style if the message is code. Set to None for plain text. Defaults to "python".
Source code in fusion_bench/utils/rich_utils.py
print_config_tree(cfg, print_order=('data', 'model', 'callbacks', 'logger', 'trainer', 'paths', 'extras'), resolve=False, save_to_file=False)
¶
Prints the contents of a DictConfig as a tree structure using the Rich library.
:param cfg: A DictConfig composed by Hydra.
:param print_order: Determines in what order config components are printed. Default is ("data", "model",
"callbacks", "logger", "trainer", "paths", "extras")
.
:param resolve: Whether to resolve reference fields of DictConfig. Default is False
.
:param save_to_file: Whether to export config to the hydra output folder. Default is False
.
Source code in fusion_bench/utils/rich_utils.py
setup_colorlogging(force=False, level=logging.INFO, **kwargs)
¶
Sets up color logging for the application.
Source code in fusion_bench/utils/rich_utils.py
fusion_bench.utils.pylogger
¶
RankZeroLogger
¶
Bases: Logger
A logger that logs only on rank zero and works just like logging.Logger
Source code in fusion_bench/utils/pylogger.py
RankedLogger
¶
Bases: LoggerAdapter
A multi-GPU-friendly python command line logger.
Source code in fusion_bench/utils/pylogger.py
__init__(name=__name__, rank_zero_only=False, extra=None)
¶
Initializes a multi-GPU-friendly python command line logger that logs on all processes with their rank prefixed in the log message.
:param name: The name of the logger. Default is __name__
.
:param rank_zero_only: Whether to force all logs to only occur on the rank zero process. Default is False
.
:param extra: (Optional) A dict-like object which provides contextual information. See logging.LoggerAdapter
.
Source code in fusion_bench/utils/pylogger.py
log(level, msg, rank=None, *args, **kwargs)
¶
Delegate a log call to the underlying logger, after prefixing its message with the rank
of the process it's being logged from. If 'rank'
is provided, then the log will only
occur on that rank/process.
:param level: The level to log at. Look at logging.__init__.py
for more information.
:param msg: The message to log.
:param rank: The rank to log at.
:param args: Additional args to pass to the underlying logging function.
:param kwargs: Any additional keyword args to pass to the underlying logging function.
Source code in fusion_bench/utils/pylogger.py
get_rankzero_logger(name=None)
¶
Return a logger with the specified name, creating it if necessary.
If no name is specified, return the root logger.