facebookresearch / hydra

Hydra is a framework for elegantly configuring complex applications
https://hydra.cc
MIT License
8.75k stars 628 forks source link

How to change the upper level config? #2652

Closed Hannibal046 closed 1 year ago

Hannibal046 commented 1 year ago

Discussed in https://github.com/facebookresearch/hydra/discussions/2651

Originally posted by **Hannibal046** April 30, 2023 Hi, Thanks so much for this great projects! I am relatively new to Hydra, and I have a problem about **changing the upper level config**. Suppose that my config folder looks like this: config yaml — hydra 2023-04-30 23-36-33 and `conf/config.yaml` looks like this: config yaml — hydra 2023-04-30 23-36-52 What i want is for `wmt` dataset, the `max_epochs` for 100 while for `iwslt` dataset, the `max_epochs` is 10. How could i implement this? I know [Specializing configuration](https://hydra.cc/docs/patterns/specializing_config/), but this seems to handle a special case where there is only one should be specialized. But in my case, i may have much more datasets and i want to give each of them different trainer values, how could i achieve this?
Hannibal046 commented 1 year ago

I used to employ lightning cli to manage my configs and it simply use config overriding to handle this.

For example, i would have a general_config.yaml like this:

general_config yaml — LaMo  SSH: 2558  2023-04-30 23-48-11

And i have a dataset specific config dataset.yaml like this:

ende yaml — LaMo  SSH: 2558  2023-04-30 23-48-43

When executing my command, the trainer arguments in dataset.yaml would override those in general_config.yaml. Do we have similar solutions in Hydra?

python main.py --config general_config.yaml --config dataset.yaml
omry commented 1 year ago

Typically, the configs in a config group are configuring the name with the same config group. If you want to modify the top level config, you can use a global package in the configs. This is similar what is described here.