rich_utils

add_as_string_option(func) Callable[source]

Decorator that adds an option to a function that returns a Rich object to return a string instead.

enforce_tags(cfg: DictConfig, save_to_file: bool = False) None[source]

Prompts user to input tags from command line if no tags are provided in config.

Parameters:
  • cfg – A DictConfig composed by Hydra.

  • save_to_file – Whether to export tags to the hydra output folder. Default is False.

format_table_rich(*args, **kwargs)[source]

Wrapper function.

print_config_tree(cfg: DictConfig, print_order: Sequence[str] = ('data', 'model', 'callbacks', 'logger', 'trainer', 'paths', 'extras'), resolve: bool = False, save_to_file: bool = False, print_to_console: bool = True, return_str: bool = False) None | str[source]

Prints the contents of a DictConfig as a tree structure using the Rich library.

Parameters:
  • cfg – A DictConfig composed by Hydra.

  • print_order – Determines in what order config components are printed. Default is

  • `` ("data", "model", "callbacks", "logger", "trainer", "paths", "extras")

  • resolve – Whether to resolve reference fields of DictConfig. Default is False.

  • save_to_file – Whether to export config to the hydra output folder. Default is False.

  • print_to_console – Whether to print config tree to console. Default is True.

  • return_str – Whether to return config tree as a string. Default is False.

Returns:

If return_str=True, returns config tree as a string.

Return type:

None or str

rich_to_str(rich_object: Table | Any) str[source]

Converts a Rich object to a string.