1

The following code snippet works as expected when running the script without any parameters (execution stops because of missing argument in config):

if __name__ == '__main__':

    config_name = "csv_images_test"

    cs = ConfigStore.instance()
    cs.store(name=config_name, node=Config)

    @hydra.main(config_path="/hdd/twapi/configs/", config_name=config_name)
    def main(cfg: Config) -> None:
        print(OmegaConf.to_yaml(cfg))

    main()

How ever, when i specify this config name via command line, it seems that type checking is not happening:

python /hdd/twapi/src/config_structure.py --config-name=/hdd/twapi/configs/csv_images_test.yaml
4

1 回答 1

1

在 Hydra 1.0 中,配置和匹配的模式之间的匹配是在它们共享相同名称时自动发生的。这在此处记录。

仍在开发中的 Hydra 1.1 改变了这种行为,有利于更灵活地使用默认列表以将模式与配置相匹配。看到这个

这是可能的,因为 Hydra 1.1 中实现了新的默认列表,它支持任意配置中的默认列表,而不仅仅是主要配置。

在此处了解更多信息。

您可以尝试 Hydra 1.1 开发版本(最新版本是1.1.0dev4)。有关安装说明,请参阅 Hydra 的主要自述文件。

于 2021-03-09T17:31:40.667 回答