omry / omegaconf

Flexible Python configuration system. The last one you will ever need.
BSD 3-Clause "New" or "Revised" License
1.95k stars 107 forks source link

Node interpolation not working #1145

Closed Qolorerr closed 10 months ago

Qolorerr commented 10 months ago

I trying to use node interpolation in the config file but it doesn't work. It doesn't work on the basic examples too, like: cfg = oc.create({'test': 255, 'tes2': '${test}'}) print(cfg) And I get {'test': 255, 'tes2': '${test}'} What am I doing wrong?

Qolorerr commented 10 months ago

OmegaConf.resolve(cfg) fixed issue

odelalleau commented 10 months ago

You can also look at the OmegaConf.{to_object,to_container,to_yaml} functions that provide various options to export the config with / without resolution of interpolations.

omry commented 10 months ago

Interpolation is evaluated lazily on access. As mentioned, you can call resolve to eagerly update all interpolations to their resolved values.