omry / omegaconf

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

`OmegaConf.resolve` should crash when a resolver input is missing #1131

Open Jasha10 opened 9 months ago

Jasha10 commented 9 months ago

In the following example, OmegaConf.is_missing(config, "a") is False before calling OmegaConf.resolve, and it becomes True after calling OmegaConf.resolve.

from omegaconf import OmegaConf

def no_op(x):
    pass

OmegaConf.register_new_resolver("no_op", no_op)

config = OmegaConf.create({"a": "${no_op:${b}}", "b": "???"})

assert not OmegaConf.is_missing(config, "a")

OmegaConf.resolve(config)

assert not OmegaConf.is_missing(config, "a")  # AssertionError

This violates the principle that working with a resolved config should give the same results as working with an unresolved config. Based on @odelalleau's comment in https://github.com/omry/omegaconf/issues/1130#issuecomment-1757741616

By the way this makes me realize there is an issue: I was expecting OmegaConf.resolve(config) to crash, but it didn't. This is annoying because after resolution OmegaConf.is_missing(config, "a") is True, while it is False before => this is definitely a discrepancy that should be looked into.