Document OmegaConf.merge handling of MISSING values (#771)#1309
Open
jbbqqf wants to merge 2 commits into
Open
Conversation
`OmegaConf.merge` gives `MISSING` ("???") on the source side a "no value
to apply" semantic — a non-missing value on the target is never
overwritten by a missing value coming from a later config. This comes
up regularly in user discussions (omry#729, hydra#1729) but was not stated
in the docs.
Add a short doctest-backed subsection to `docs/source/usage.rst` next
to the `OmegaConf.merge()` walk-through showing both directions (source
MISSING is skipped; target MISSING is filled by a later concrete value)
and a one-line motivation for the behavior.
Owner
|
Hi @jbbqqf, thanks again for your help. Filing a PR before I have an idea of how i want to solve it is premature. Thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OmegaConf.mergetreatsMISSING("???") on the source side as "no value to apply" — a non-missing target value is never overwritten by a missing source value. This behavior has resurfaced repeatedly in user discussions (#729, hydra#1729) but was not stated in the docs. Add a short doctest-backed subsection next to the existingOmegaConf.merge()walk-through.Fixes #771.
Context
Issue #771 (filed by @Jasha10) flagged that the merge-vs-missing rule is part of the public contract but only discoverable by reading source. The two motivating discussions:
The behavior itself is unchanged; this PR only adds documentation.
Changes
docs/source/usage.rst— new "Missing values inmerge()" subsection under the existingOmegaConf.merge()heading. Contains a sphinx doctest exercising both orderings (merge(base, override)keeps the concrete value;merge(override, base)fills the missing one) and a one-line motivation for the behavior.news/771.docs— towncrier entry.Reproduce BEFORE/AFTER yourself (copy-paste)
What I ran locally
sphinx-build -b doctest docs/source /tmp/doctest_outon the branch: 409 tests, 18 failures + 1 setup failure.sphinx-build -b doctest docs/source /tmp/doctest_mainonorigin/main: 404 tests, 18 failures + 1 setup failure.The 5-test delta is exactly the size of the new doctest block (one
>>> from omegaconf...plus four>>>data lines plus two expected outputs). The failure count is unchanged: my added block contributes zero new failures and the 18 pre-existing failures are numpy/repr-formatting artifacts unrelated to this PR.Edge cases tested
merge({port: 80}, {port: "???"})merge({port: "???"}, {port: 80})Risk / blast radius
Documentation only. No code changed, no behavior changed. The only file in
omegaconf/is untouched; the only addition is one.rstsubsection plus a towncrier entry.Release note
PR drafted with assistance from Claude Code. The doctest snippet was verified manually against
origin/main(behavior is pre-existing, only the docs change). The reproducer block above was used during development; it is the same one a reviewer can paste verbatim.