Source code for calorine.env

from os import getenv


[docs] def calorine_getenv(variable) -> str: """Get value of environment variable, or default. Possible environment variables are: - `CALORINE_GPUMD_COMMAND` - Command used by :class:`GPUNEP <calorine.calculators.GPUNEP>` to invoke the ``gpumd`` executable. Default: ``'gpumd'``. - `CALORINE_NEP_COMMAND` - Command used by :func:`batch_predict_properties <calorine.tools.batch_predict_properties>` to invoke the ``nep`` executable. Default: ``'nep'``. Parameters ---------- variable Name of variable, without the ``'CALORINE_'`` prefix. Returns ------- Value of variable as string. """ defaults = {'GPUMD_COMMAND': 'gpumd', 'NEP_COMMAND': 'nep'} if variable not in defaults: allowed = '\n'.join(f' CALORINE_{var}' for var in defaults) raise ValueError(f'Environment variable CALORINE_{variable} is unknown. ' f'Allowed variables are:\n{allowed}') return getenv(f'CALORINE_{variable}', defaults[variable])