Skip to content
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

Intruction of merge flag to OmegaConf.update() #367

Closed
omry opened this issue Sep 9, 2020 · 0 comments
Closed

Intruction of merge flag to OmegaConf.update() #367

omry opened this issue Sep 9, 2020 · 0 comments

Comments

@omry
Copy link
Owner

omry commented Sep 9, 2020

OmegaConf.update() behavior when the input value was a list or a dictionary was to assign the value instead of to merge it:

cfg = OmegaConf.create({"a": {"b": 10}})
OmegaConf.update(cfg, "a", {"c": 20}})
# cfg is now {"a": {"c": 20}}

The intended behavior for update lines up better with a merge:

OmegaConf.update(cfg, "a", {"c": 20}})
# cfg is now {"a": {"b": 10, "c": 20}}

To support both use cases, a new merge flag is introduced to update:

def update(
    cfg: Container, key: str, value: Any = None, merge: Optional[bool] = None
) -> None:
  • None: issue a warning, default to False to maintain compatibility.
  • True : Merge config
  • False: Assign config

The default value for merge will become True in a future version.
To avoid unexpected behavior changes, please call update with merge=[True|False].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant