Open kaimo455 opened 1 year ago
Well, seems that even a simple interpolation field will crash, not customized resolver needed.
import omegaconf
cfg = omegaconf.OmegaConf.create({'a': '???', 'b': '${.a}'})
omegaconf.OmegaConf.missing_keys(cfg)
For reference, here's the traceback produced by the example from the OP:
It looks like invoking OmegaConf.missing_keys
causes 'c'
to be dereferenced.
Hi @kaimo455, thanks for taking the time to file a bug report and open a PR.
I see that your PR #1117 works around this crash by modifying the OmegaConf.missing_keys
function to skip keys that are interpolations. This seems like a reasonable approach to me.
@odelalleau, thoughts? I feel like interpolation should be evaluated and True should be returned they resolve to a missing key. For custom resolvers, I think the behavior should be True if they are dereferencing a missing key (which I think triggers a MissingMandatoryValue somewhere).
@odelalleau, thoughts? I feel like interpolation should be evaluated and True should be returned they resolve to a missing key. For custom resolvers, I think the behavior should be True if they are dereferencing a missing key (which I think triggers a MissingMandatoryValue somewhere).
OmegaConf.is_missing(cfg, c)
returns False
). And trying to access cfg.c
raises a InterpolationToMissingValueError
, not a MissingMandatoryValue
.I don't remember the details, but I believe that there were potential issues in "propagating" missing values through interpolations / resolvers.
Describe the bug When a config contains customized resolvers which depend on some missing field(s), calling
OmegaConf.missing_keys(cfg)
raise an error.To Reproduce
Expected behavior Should just return
{'a', 'b'}
Additional context
Direct Solution I create a pull request for that fix, please see #1117