Reputation: 67
I would like to access hydra configuration, e.g., sweeper, from the decorated function:
@hydra.main(config_name="config")
def my_app(cfg: Config) -> None:
OmegaConf.to_yaml(cfg.hydra.sweeper)
Is there any parameter I can pass to @hydra.main()
not to remove that configuration, or is there other place where I can find it? Thanks.
Upvotes: 0
Views: 377
Reputation: 33646
from hydra.core.hydra_config import HydraConfig
@hydra.main()
def my_app(cfg: DictConfig) -> None:
print(HydraConfig.get().sweeper)
You can also access it through the configuration with interpolation:
config.yaml:
hydra_sweeper: ${hydra:sweeper}
See this.
Upvotes: 2