vantage6.algorithm.tools.util.get_env_var#

get_env_var(var_name, default=None, as_type='str')#

Get the value of an environment variable. Environment variables are encoded by the node so they need to be decoded here.

Note that this decoding follows the reverse of the encoding in the node: first replace ‘=’ back and then decode the base32 string.

Parameters:
  • var_name (str) – Name of the environment variable

  • default (str | None) – Default value to return if the environment variable is not found

  • as_type (str) – Type to convert the environment variable to. Default is ‘str’, other options are ‘bool’ and ‘int’.

Returns:

var_value – Value of the environment variable, or default value if not found

Return type:

str | None

Raises:

EnvironmentVariableError – If the environment variable value cannot be converted to e.g. an integer or boolean when that is requested.