-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling OmegaConf.to_container
on interpolation-to-missing errors
#727
Comments
I am currently working on a PR to close #501, introducing a From the perspective of API design, I think it makes sense that |
This is a collateral damage from a breaking change. Not really a bug, more like something we failed to mention as a breaking change (we can add a news fragment for it now). When introducing throw_on_missing, I agree that having it set to False should suppress the InterpolationToMissingValueError as well. |
I actually disagree with This is because trying to resolve an interpolation to a missing value is now considered an error (instead of being considered as yielding a missing value). This is indeed a breaking change, and it should have probably been mentioned in another news item attached to #545 (@omry should I submit a PR for this?) I would suggest not to try and support the example given at the top unless there is a good reason for it. And if we do want to support it, I think it shouldn't be with |
Good point.
My assumption was that most users of
For users in the second category, missing values feel the same as interpolation-to-missing values. Anyway, I'd be fine with not supporting the example at the top. If we do decide to support it, one idea is to add a
Ok :) |
Yeah, if someone really doesn't want any error raised, probably that a "throw_on_resolution_failure_flag" would make more sense (and would also intercept
Yes, that's an option, though it starts making the API somewhat complex just to handle this special case in a special way that may not be consistent with the rest of the codebase. Just to share one example why this might be an issue: I think that in general we want code based on some config |
I think your last example is wrong. round trip conversion is incompatible with Side note: Converting to container also loses all type safety, so it's not really round trip on that dimension as well.
Currently, people that do not want any errors raised can use the default This would mean that while converting a container, to_container would resolve interpolations if and only if resolve is True. That might raise a resolution error if there is an interpolation to a missing value. Since we have 2 boolean flags, let's list all modes: resolve=False, throw_on_missing=FalseNo interpolation resolution, interpolations are returned as strings. resolve=False, throw_on_missing=TrueNo interpolation resolution, interpolations are returned as strings. resolve=True, throw_on_missing=FalseInterpolations are resolved. Interpolation to missing would raise InterpolationToMissingValueError. resolve=True, throw_on_missing=TrueInterpolations are resolved. Interpolation to missing would raise InterpolationToMissingValueError. |
Oh, yeah, I made it sound like the round-trip would return an equivalent object. That's definitely not true (at least interpolations & typing are lost).
As far as I can tell this is the current behavior from #730, up to the handling of interpolations to missing values (which is the point up for debate). |
Ok, great! I'll update the implementation. |
Closing this now since the current behavior for the |
The behavior of the
OmegaConf.to_container
method has changed with respect to interpolation-to-missing nodes.With OmegaConf v2.0.6, no exception is raised on encountering interpolation-to-missing:
Currently on the
master
branch, this no longer works: anInterpolationToMissingValueError
is raised.This behavior change resulted from #545.
The text was updated successfully, but these errors were encountered: