-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hydra/OmegaConf: how to make and reference nested configuration files? #22
Comments
Hi! To ease a bit the explanation I created a small repo with a minimum working example to gather the (few lines) of code. The Let me check if I got what you want to accomplish:
I think there is a bit of personal preference involved, but I would go as follows. Say that I have two different independent models:
For this example those files would contain only a name: And some default in the main config: In other parts of the configuration you can dynamically resolve any variable (e.g. the name in this case), note how the path of the variable contains the folder name not the file name: Once you have this structure set up you can change the defaults from the main ❯ python main.py model=mlp
data:
dataset:
name: mnist
model:
name: my_awesome_mlp
other:
an_interpolated_var: my_awesome_mlp-mnist
❯ python main.py model=resnet
data:
dataset:
name: mnist
model:
name: my_awesome_resnet
other:
an_interpolated_var: my_awesome_resnet-mnist Now if in future you want to configure yet another model, you can just add a new file under You can also modify directly the various I hope I replied to your question, let me know if you have any other doubts! |
I think you should try with |
Hi, i'm just getting started with Hydra and OmegaConf, populating
nn-template
with my code, and this may seem a silly question, but i can't figure out how to make and use deeply nested configs, specifically how to reference them using variable interpolation.For example, i'd like to place model- or dataset- specific configurations to a separate file, like in
conf/data/dataset_conf.yaml
, but i'm surely doing something wrong because when i try to interpolate${data.dataset_conf.some_key}
i get an exception about thedataset_conf
not being a key in thedata
configuration node.I also tried to make a file in
conf/data/dataset_conf/default.yaml
but got the same kind of errors.So, to the best of my knowledge, there are only two sure ways to add my configuration to the project:
conf/{data,model}/default.yaml
and have slightly longer and less organized configuration files.conf
, for exampleconf/dataset_specific/default.yaml
, and add my configuration there. This has the different disadvantage of not expressing the hierarchy of config files, such as the dataset-specific options not being under thedata
group of configurations.I ended up with option 1, placing the relevant configuration in the same
conf/data/default.yaml
file, under a new nodedataset_conf
, which now looks like this, just to be clear:But this gets messy very soon, considering how i aslo plan on tracking my custom data augmentation pipeline in the config files (a dozen nodes to be
instantiate()
'd), so how does one move all the stuff fromdataset_conf
to another file in the sameconf/data/
folder (or a subfolder thereof), and how does it work to properly reference it from other files?After some googling, I looked into Config Groups and Config Group Options, which have a promising name, but they don't seem exactly fit for the purpose i'm trying to achieve, maybe i got them wrong?
Sorry for the long post and thanks for any answer
The text was updated successfully, but these errors were encountered: