Hydra覆盖.YAML配置中的插值dict值
假设我有以下配置:
foo:
a : 1
b : 2
c :
aa : ???
bb : 2
bar : ${foo.c}
baz : ${foo.c}
并且想要在bar
和baz
中专业化(或覆盖)aa
。有什么干净的方法可以做到吗?我看不到如何在没有痛苦的情况下使用默认列表来执行此操作...
如果有一些语法,
...
bar : ${foo.c}
bar.c.aa : 1
baz : ${foo.c}
baz.c.aa : 2
或者使用DSL语法进行命令行覆盖...
编辑:编辑: 我希望结果是
foo:
a : 1
b : 2
c :
aa : ???
bb : 2
bar :
c :
aa : 1
bb : 2
baz :
c :
aa : 2
bb : 2
(忽略foo.c.aa
缺失的事实) 我知道如何以编程方式执行此操作,我问它是否可以使用某种解决方案/插值完成。
可以使用命令行(例如bar.c.aa = 1
)覆盖值,我想要此功能,但在.YAML文件本身中。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
九头蛇不支持这种扩展。
您可以通过按照描述的在这里)来实现它。
像:
您可以通过默认列表组成config节点baz.c和bar.c,具有原型
foo/proto.yaml
充当基础:bar/c.yaml:
baz/c.yaml:
注意:
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:bar/c.yaml:
baz/c.yaml:
Note: