Skip to content

How inheritance handles nested configs #472

Answered by rsokl
DirkKuhn asked this question in Q&A
Discussion options

You must be logged in to vote

All of hydra-zen's config-creation functions - builds, make_config - return dynamically-generated dataclass types, so the inheritance behavior you are seeing is just straightforward class inheritance.

You can get the behavior you are looking for by using OmegaConf.merge:

from hydra_zen import make_config
from omegaconf import OmegaConf

base = make_config(a=dict(b=0, c=0))
cfg = make_config(a=dict(c=1, d=1), bases=(base,))

OmegaConf.merge(base, cfg)

produces

{'a': {'b': 0, 'c': 1, 'd': 1}}

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@DirkKuhn
Comment options

Answer selected by DirkKuhn
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants