英文:
Unsupported Interpolation Type using env variables in Hydra
问题
我正在尝试做什么:在Hydra配置中使用环境变量。
我参考了以下链接:OmegaConf: 环境变量插值 和 Hydra: 作业配置。
这是我的 config.yaml
:
hydra:
job:
env_copy:
- EXPNAME
# 我还尝试了 hydra:EXPNAME 和 EXPNAME,
# 都返回 None
test: ${env:EXPNAME}
然后我在Ubuntu中设置了环境变量:
export EXPNAME="123"
我收到的错误消息是:
omegaconf.errors.UnsupportedInterpolationType: 不支持的插值类型 env
full_key: test
object_type=dict
英文:
What I'm trying to do: use environment variables in a Hydra config.
I worked from the following links: OmegaConf: Environment variable interpolation and Hydra: Job Configuration.
This is my config.yaml
:
hydra:
job:
env_copy:
- EXPNAME
# I also tried hydra:EXPNAME and EXPNAME,
# which return None
test: ${env:EXPNAME}
Then I set the environment variable (Ubuntu) with:
export EXPNAME="123"
The error I get is
omegaconf.errors.UnsupportedInterpolationType: Unsupported interpolation type env
full_key: test
object_type=dict
答案1
得分: 2
试试这个(env
已经在很久以前被删除,以支持 oc.env
)。
test: ${oc.env:EXPNAME}
如果您只需要在本地机器上访问环境变量,我认为其他部分都不需要。
英文:
Try this (env was removed in a long time ago in favor of oc.env).
test: ${oc.env:EXPNAME}
I don't think the rest is needed if all you need is to access environment variables on your local machine.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论