Skip to main content
Version: 0.11


After office politics, you decide that you want to use MySQL by default. You no longer want to type db=mysql every time you run your application.

You can add a defaults list into your config file.

Config group defaults#

Configuration file: config.yaml

defaults:  - db: mysql

Remember to specify config.yaml as the config_path.

@hydra.main(config_path='conf/config.yaml')def my_app(cfg):    print(OmegaConf.to_yaml(cfg))

When you run the updated application, MySQL is loaded by default.

$ python my_app.pydb:  driver: mysql  pass: secret  user: omry

Overriding a config group default#

You can still load PostgreSQL, and override individual values.

$ python db=postgresql db.timeout=20db:  driver: postgresql  pass: drowssap  timeout: 20  user: postgres_user

You can prevent a default from being loaded by assigning null to it in the command line:

$ python db=null{}

Non-config group defaults#

Sometimes a config file you want to merge does not belong in any config group. The following will load some_file.yaml from your config directory:

defaults:  - some_file

Config files that not a part of a config group like db cannot be overridden.