pythonhydraomegaconf

Unsupported Interpolation Type using env variables in Hydra


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

Solution

  • 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.