Search code examples
pythonfb-hydra

Multiple defaults in Hydra from command line


I have the following folder structure

configs
|------- default.yaml
|------- setting_A.yaml
|------- setting_B.yaml
|------- a bunch of folders

My default.yaml is

defaults:
  - agent: default
  # - setting_A
  # - setting_B

other configs from subfolders

setting_A and setting_B define parameters from different configs file in the subfolders. For instance size of network, timeout, etc... For example, in setting_A I am doing something simple so I need small networks, short timeout, etc... I can select which set of defaults to use by uncommenting either setting_A or setting_B in default.yaml. But this is very annoying. Is there a way to pass it via command line?

Something like python main.py +defaults=setting_A.


Solution

  • The syntax you are using is defining a non overridable config. See The Defaults List page for details.

    In short, you need to place your configs in a config group to be able to override them.

    Refer to the Configuring experiments pattern to see a way to achieve the effect you want.