0

我想从装饰功能访问 hydra 配置,例如清扫器:

@hydra.main(config_name="config")
def my_app(cfg: Config) -> None:
    OmegaConf.to_yaml(cfg.hydra.sweeper)

是否有任何参数可以传递给@hydra.main()不删除该配置,或者是否有其他地方可以找到它?谢谢。

4

1 回答 1

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

于 2021-02-01T17:20:40.220 回答