In my project, I'm setting an environment variables using python-dotenv.
I then reference it in my YAML using the co.env
OmegaConf resolver.
# config.yaml
var1: 42
var2: ${oc.env:PROJECT_NUMBER}
# .env
PROJECT_NUMBER=99
Once I run my script, however, the variable appears to be always parsed as a string:
# content of config
{'var1': 42, 'var2': '99'}
As far as I understand from here, this is the intended behavior of oc.env
, and the env
resolver which would guess the primitive type is being deprecated.
How do I ensure that var2
is read as an integer?
Thanks in advance.
You can use oc.decode to decode to get it as a number.
Something like:
var1: 42
var2: ${oc.decode:${oc.env:PROJECT_NUMBER}}