question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling `OmegaConf.to_container` on interpolation-to-missing errors

See original GitHub issue

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:

>>> cfg = OmegaConf.create({"missing": "???", "x": "${missing}"})
>>> OmegaConf.to_container(cfg, resolve=True)
{'missing': '???', 'x': '???'}

Currently on the master branch, this no longer works: an InterpolationToMissingValueError is raised. This behavior change resulted from #545.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
odelalleaucommented, May 26, 2021

I actually disagree with to_container(..., resolve=True, throw_on_missing=False) allowing interpolations to missing values. The main reason is that this would be inconsistent with (at least) OmegaConf.select() where throw_on_missing=False doesn’t allow this, and instead one should use throw_on_resolution_failure=False (resulting in a value of None).

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 throw_on_missing=False. This may actually require revisiting some key decisions made in #545 so it should be considered carefully.

1reaction
omrycommented, May 21, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

throw_on_missing keyword argument for OmegaConf ... - GitHub
Feature: Currently, calling OmegaConf.to_container(cfg) can result in a python ... Calling OmegaConf.to_container on interpolation-to-missing errors #727.
Read more >
Installation — OmegaConf 2.1.3.dev0 documentation
Add new interpolation types by registering resolvers using OmegaConf.register_new_resolver() . Such resolvers are called when the config node is accessed.
Read more >
OmegaConf Documentation
INSTANTIATE, interpolations nested within a structured config node will be resolved, even if OmegaConf. to_container is called with the the keyword argument ...
Read more >
Installation — OmegaConf 2.0.6 documentation - Read the Docs
You can create OmegaConf objects from multiple sources. ... "oops" cannot be converted to an int Traceback (most recent call last): ... omegaconf.errors....
Read more >
OmegaConf Documentation
OmegaConf is a YAML based hierarchical configuration system, with support for merging configurations from multi- ple sources (files, CLI ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found