Last active
December 31, 2024 09:00
-
-
Save bdsaglam/586704a98336a0cf0a65a6e7c247d248 to your computer and use it in GitHub Desktop.
Use Hydra in Jupyter notebook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pathlib | |
import hydra | |
hydra._internal.hydra.GlobalHydra().clear() | |
config_dir = pathlib.Path('/path/to/configs/') | |
hydra.experimental.initialize(config_dir=config_dir) | |
cfg = hydra.experimental.compose(config_file='config.yaml', overrides=[]) | |
print(cfg.pretty()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for new hydra versions (definitely for >1.2, maybe earlier too) use
hydra.core.global_hydra.GlobalHydra.instance().clear()
instead ofhydra._internal.hydra.GlobalHydra().clear()
.Also,
hydra
does not containexperimental
anymore (andcfg.pretty
also does not exist) andconfig_file
was renamed toconfig_name
.So, to sum up:
Source: hydra compose_configs_in_notebook