climart/utils/utils.py
def print_config(
        config,
        fields: Union[str, Sequence[str]] = (
                "datamodule",
                "end_model",
                "trainer",
                # "callbacks",
                # "logger",
                "seed",
        ),
        resolve: bool = True,
) -> None:
    """Prints content of DictConfig using Rich library and its tree structure.

    Credits go to: https://github.com/ashleve/lightning-hydra-template

    Args:
        config (ConfigDict): Configuration
        fields (Sequence[str], optional): Determines which main fields from config will
        be printed and in what order.
        resolve (bool, optional): Whether to resolve reference fields of DictConfig.
    """
    import importlib
    if not importlib.util.find_spec("rich") or not importlib.util.find_spec("omegaconf"):
        # no pretty printing
        return
    from omegaconf import DictConfig, OmegaConf
    import rich.syntax
    import rich.tree

    style = "dim"
    tree = rich.tree.Tree(":gear: CONFIG", style=style, guide_style=style)
    if isinstance(fields, str):
        if fields.lower() == 'all':
            fields = config.keys()
        else:
            fields = [fields]

    for field in fields:
        branch = tree.add(field, style=style, guide_style=style)

        config_section = config.get(field)
        branch_content = str(config_section)
        if isinstance(config_section, DictConfig):
            branch_content = OmegaConf.to_yaml(config_section, resolve=resolve)

        branch.add(rich.syntax.Syntax(branch_content, "yaml"))

    rich.print(tree)
Prints content of DictConfig using Rich library and its tree structure.

    Credits go to: https://github.com/ashleve/lightning-hydra-template

    Args:
        config (ConfigDict): Configuration
        fields (Sequence[str], optional): Determines which main fields from config will
        be printed and in what order.
        resolve (bool, optional): Whether to resolve reference fields of DictConfig.
    
Prints content of DictConfig using Rich library and its tree structure.

config (ConfigDict): Configuration
fields (Sequence[str], optional): Determines which main fields from config will
be printed and in what order.
resolve (bool, optional): Whether to resolve reference fields of DictConfig.
Prints content of DictConfig using Rich library and its tree structure . config ( ConfigDict ) : Configuration fields ( Sequence [ str ] optional ) : Determines which main fields from config will be printed and in what order . resolve ( bool optional ) : Whether to resolve reference fields of DictConfig .
def print_config(
        config,
        fields: Union[str, Sequence[str]] = (
                "datamodule",
                "end_model",
                "trainer",
                "seed",
        ),
        resolve: bool = True,
) -> None:
    import importlib
    if not importlib.util.find_spec("rich") or not importlib.util.find_spec("omegaconf"):
        return
    from omegaconf import DictConfig, OmegaConf
    import rich.syntax
    import rich.tree
    style = "dim"
    tree = rich.tree.Tree(":gear: CONFIG", style=style, guide_style=style)
    if isinstance(fields, str):
        if fields.lower() == 'all':
            fields = config.keys()
        else:
            fields = [fields]
    for field in fields:
        branch = tree.add(field, style=style, guide_style=style)
        config_section = config.get(field)
        branch_content = str(config_section)
        if isinstance(config_section, DictConfig):
            branch_content = OmegaConf.to_yaml(config_section, resolve=resolve)
        branch.add(rich.syntax.Syntax(branch_content, "yaml"))
    rich.print(tree)
def print_config ( config , fields : Union [ str , Sequence [ str ] ] = ( "datamodule" , "end_model" , "trainer" , "seed" , ) , resolve : bool = True , ) -> None : import importlib if not importlib . util . find_spec ( "rich" ) or not importlib . util . find_spec ( "omegaconf" ) : return from omegaconf import DictConfig , OmegaConf import rich . syntax import rich . tree style = "dim" tree = rich . tree . Tree ( ":gear: CONFIG" , style = style , guide_style = style ) if isinstance ( fields , str ) : if fields . lower ( ) == 'all' : fields = config . keys ( ) else : fields = [ fields ] for field in fields : branch = tree . add ( field , style = style , guide_style = style ) config_section = config . get ( field ) branch_content = str ( config_section ) if isinstance ( config_section , DictConfig ) : branch_content = OmegaConf . to_yaml ( config_section , resolve = resolve ) branch . add ( rich . syntax . Syntax ( branch_content , "yaml" ) ) rich . print ( tree )
Prints content of DictConfig using Rich library and its tree structure.
Prints content of DictConfig using Rich library and its tree structure .
# "callbacks", # "logger", """Prints content of DictConfig using Rich library and its tree structure.

    Credits go to: https://github.com/ashleve/lightning-hydra-template

    Args:
        config (ConfigDict): Configuration
        fields (Sequence[str], optional): Determines which main fields from config will
        be printed and in what order.
        resolve (bool, optional): Whether to resolve reference fields of DictConfig.
    """ # no pretty printing
config
fields
Union[str, Sequence[str]]
resolve
bool