I'm working through this Hydra doc example to override the main config with an experiment config. Differing from the Hydra example I have another level of folder hierarchy to gather all associated configs into a single sub-folder.
conf
├── data
│ ├── cifar100_data
│ │ ├── cifar100_extended.yaml
│ │ └── cifar100.yaml
│ └── default.yaml
├── experiment
│ └── cifar100.yaml
└── training_config.yaml
In my example, I have a basic training_config:
defaults:
- data: default
data/default.yaml:
# @package data
dataset: mnist
n_classes: 10
and two config files for cifar100 data
cifar100_data/cifar100.yaml:
name: cifar100
n_classes: 100
cifar100_data/cifar100_extended.yaml:
# @package data
defaults:
- cifar100
augmentations:
- rotate
I'm trying to override training_config with experiment/cifar100 --> python my_app.py experiment=cifar100:
experiment/cifar100 try 1:
# @package _global_
defaults:
- override /data/cifar100_data: cifar100_extended
error message:
hydra.errors.ConfigCompositionException: In 'experiment/cifar100': Could not override 'data/cifar100_data'. No match in the defaults list.
experiment/cifar100 try 2:
# @package _global_
defaults:
- override /data: cifar100_data/cifar100_extended
error message:
hydra.errors.MissingConfigException: In 'data/cifar100_data/cifar100_extended': Could not load 'data/cifar100'.
How can I properly run such an experiment with an extra hierarchy compared to default config?
EDIT following the answer:
I've adjust cifar100_extended.yaml to:
# @package data
defaults:
- cifar100_data/cifar100
augmentations:
- rotate
as suggested in the answer, and was able to generate a valid config.
However, now I can't run cifar100_extended.yaml directly, and recieving the following error
hydra.errors.MissingConfigException: In 'cifar100_data/cifar100_extended': Could not load 'cifar100_data/cifar100_data/cifar100'.
This a bit unusual. Your data config group should be
data, not/data/cifar100_data, so the second form is the correct one:The error you are getting is:
This is telling you that while trying to data/cifar100_data/cifar100_extended, Hydra attempted to load data/cifar100 and could not find it. Indeed, that file is in
data/cifar100_data/cifar100and not indata/cifar100.This looks like a bug because relative config group entries should be relative to the containing config, and cifa100 is right next to cifar100_extended.
The bug is related to your unusual construction of a config group with sub directories which is not something that is properly supported (normally the expectation is that each sub directory is its own config group).
A work around is to adjust
cifar100_extended.yamlto: