不支持在Hydra中使用环境变量的插值类型

huangapple go评论71阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年2月19日 23:17:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/75501133.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定