0

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.

Zranz
  • 57
  • 9

1 Answers1

2
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.

Omry Yadan
  • 31,280
  • 18
  • 64
  • 87