是否可以仅导入单个配置参数,而不是全部在Hydra中?

发布于 2025-02-08 22:13:49 字数 400 浏览 3 评论 0原文

constants_config.yaml

site:  fb
another_site: google

my_config.yaml

my_site: ${constants_config.yaml]

产生的my_config.yaml

my_site: fb

我只想获得一个常数,而不是整个constants_config.yaml(通过使用默认来完成)

constants_config.yaml

site:  fb
another_site: google

my_config.yaml

my_site: ${constants_config.yaml]

Resulting my_config.yaml

my_site: fb

I just want to get a single constant, not the whole constants_config.yaml (which is done by using default)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

粉红×色少女 2025-02-15 22:13:49

不可能直接。
您可以将插值用于常数节点。
类似:

constants.yaml:

constants:
  site:  fb
  another_site: google

main.yaml:

defaults:
  - constants

my_site: ${constants.site}

组成的配置应看起来像:

constants:
  site:  fb
  another_site: google

my_site: ${constants.site}

Not possible directly.
You can do it with interpolation into a constants node.
Something like:

constants.yaml:

constants:
  site:  fb
  another_site: google

main.yaml:

defaults:
  - constants

my_site: ${constants.site}

The composed config should look something like:

constants:
  site:  fb
  another_site: google

my_site: ${constants.site}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文