Skip to content

Utils

get_log_dir #

get_log_dir(trainer: Trainer | None) -> Path

Gives back the default directory to use when trainer.log_dir is None (no logger used).

validate_datamodule #

validate_datamodule(datamodule: DM) -> DM

Checks that the transforms / things are setup correctly.

Returns the same datamodule.

print_config #

print_config(
    config: DictConfig,
    print_order: Sequence[str] = (
        "algorithm",
        "datamodule",
        "trainer",
    ),
    resolve: bool = True,
) -> None

Prints content of DictConfig using Rich library and its tree structure.

TAKEN FROM https://github.com/ashleve/lightning-hydra-template/blob/6a92395ed6afd573fa44dd3a054a603acbdcac06/src/utils/__init__.py#L56

Parameters:

Name Type Description Default
config DictConfig

Configuration composed by Hydra.

required
print_order Sequence[str]

Determines in what order config components are printed.

('algorithm', 'datamodule', 'trainer')
resolve bool

Whether to resolve reference fields of DictConfig.

True

default_device #

default_device() -> device

Returns the default device (GPU if available, else CPU).