Overriding config file with another config before applying CLI overrides? #2833
-
Hi, I want to merge an additional config file into the config that Hydra composes before it applies the CLI overrides. The intended use case is a package that comes with its own Hydra configs and I want to override some of its parameters through an additional config file. model: some-model
quantize: true
imgsize: 640 The extra config file is located somewhere else: quantize: false I think a possible solution would be to make the extra config the primary config and add a defaults section to it that includes the other config's values. This is, however, not possible for me, as I cannot change the extra config file or make it the primary config. I would be interested in having an option {"model": "some-model", "quantize": False, "imgsize": 320} I've tried merging the configs in the app, but then the extra config's values take precedence over those of the CLI (which I do not want). extracfg = OmegaConf.load(<path>)
config = OmegaConf.merge(config, extracfg) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes that would indeed be the "normal" way to achieve this. Alternatively, you could append your extra config to the default list (e.g. |
Beta Was this translation helpful? Give feedback.
Yes that would indeed be the "normal" way to achieve this.
Alternatively, you could append your extra config to the default list (e.g.
+extra=extra_config
), using the#@package _global_
directive to override the root config and this config found underconf/extra/extra_config.yaml
(you might need to modify the config search path to find it if you can't put it in the base conf folder).