Reputation: 1253
Let's say I have a config like the following:
foo:
a : 1
b : 2
c :
aa : ???
bb : 2
bar : ${foo.c}
baz : ${foo.c}
and want to specialise (or override) aa
in bar
and baz
. Is there a clean way to do this? I can't see how to do this with the defaults list without some pain...
It would be nice if there was some syntax like:
...
bar : ${foo.c}
bar.c.aa : 1
baz : ${foo.c}
baz.c.aa : 2
or perhaps using the DSL syntax for command-line overrides...
EDIT: I want the result to be
foo:
a : 1
b : 2
c :
aa : ???
bb : 2
bar :
c :
aa : 1
bb : 2
baz :
c :
aa : 2
bb : 2
(ignore the fact that foo.c.aa
is missing)
I know how to do this programmatically, I am asking it if can be done just using some kind of resolution/interpolation.
It is possible to override values using the command line (with e.g. bar.c.aa=1
), I want this functionality but in the .yaml file itself.
Upvotes: 0
Views: 2528
Reputation: 33646
Hydra does not support this kind of extension. You can achieve it by extending configs as described here.
Something like:
You can compose the config node baz.c and bar.c via the defaults list, having a prototype foo/proto.yaml
act as a base:
aa: ???
bb: 2
bar/c.yaml:
defaults:
- /foo/c@c
c:
aa: 1
# bb will be "inherited" from /foo/c
baz/c.yaml:
defaults:
- /foo/c@c
c:
aa: 2
# bb will be "inherited" from /foo/c
Note:
Upvotes: 1