pythonyamlomegaconf

Load YAML files in structured folders with OmegaConf


configs
|_________ experiment
|         |--------- test.yaml
|--------- default.yaml

default.yaml has some configuration parameters and then

experiment: test.yaml

test.yaml defines more parameters, such as learning_rate: 0.1.
I would like to load them recursively with OmegaConf. If I do

from omegaconf import DictConfig, OmegaConf
conf = OmegaConf.load("configs/default.yaml")

It doesn't work because conf has key experiment with value test, rather than key learning_rate with value 0.1.
It is possible to read YAML files recursively?


Solution

  • OmegaConf is a low level library. It does not support higher level functionality like what you seems to be asking for. If you want to compose configs from multiple files/sources into a single object, I recommend that you use Hydra (@hydra.main() or the Compose API).