Environment Variables#

Overview of Environment Variables#
Environment variables control how software or packages run inside of the project container.
For example, they are used to pass things like database addresses, API keys, or flags to enable/disable features.
This provides flexibility so the same container can be used in different situations.
Workbench consistently manages environment variables for projects across different hosts and users.
You create them directly in the Desktop App or CLI.
They are key-value pairs with an optional description.
They are divided into non-sensitive and sensitive types.
Table of Environment Variable Types and Information
Environment Variable Type |
Versioned |
Key Storage Location |
Value Storage Location |
Uses |
---|---|---|---|---|
Non-Sensitive |
Key and value |
|
|
Ordinary environment variables needed to set options for software or packages in the container. |
Sensitive |
Key only |
|
|
Secrets like API keys and passwords that should not be stored in the repository. |
Basic Usage for Environment Variables#
Note
The best way to understand how environment variables work is work through the exercises in the Onboarding Project.
Creating an Environment Variable#
Create a variable in Project Tab > Project Container > Environment Variables > Add
Enter the name of the environment variable, e.g. the key
HUGGINGFACE_HUB_CACHE
.Enter the value of the environment variable, e.g. the value
/mnt/cache
.(if sensitive) Check the Sensitive checkbox.
Click Add to create the environment variable.
Note
The value of an environment variable can be updated but the name or key cannot.
To change the name you must delete the existing variable and create one with the new name.
Deleting an Environment Variable#
Go to the Project Tab > Project Container > Environment Variables
Click the option dots on the right of the environment variable you want to delete
Select Remove Environment Variable
Updating an Environment Variable#
Go to Project Tab > Project Container > Environment Variables
Click the option dots on the right of the environment variable you want to update
Select Edit Environment Variable
Enter the new value for the environment variable and click Save
Cloning Project With Sensitive Environment Variables#
Everytime you clone a project with a sensitive environment variable, you will be prompted to enter the value.
Once a sensitive environment variable is created, it is part of that project until it is removed.
However, only keys are stored and versioned in the project repository. Values do not leave the host where they are created.
Everytime you clone a project with a sensitive environment variable, you must re-enter the value of the variable.
This helps with security and lets different users set their own values.
FAQs#
Can I use the CLI to create and configure environment variables?#
Yes. The CLI has the same functionality as the Desktop App.
Creating an Environment Variable
Open the terminal and activate the desired context (location)
Run
nvwb open
to open an existing projectRun
nvwb create environment-variable
Enter the environment variable name (no hyphens)
Enter the value for the environment variable
Enter an optional description for the environment variable
Deleting an Environment Variable
Open the terminal and activate the desired context (location)
Run
nvwb open
to open an existing projectRun
nvwb delete environment-variable
Select the environment variable to delete. You are not prompted for confirmation
Where are sensitive environment variables stored?#
Workbench stores project runtime information for the host in the .nvwb/project-runtime-info/
. The values do not leave the host they are created on.
Each project has a subdirectory, <project-name>-<project-hash>
, where <project-hash>
is a hash of the project repository’s path on disk.
You can see the key-value pairs of sensitive environment variables in the secrets.env
file in the project’s subdirectory.
The full path would be .nvwb/project-runtime-info/<project-name>-<project-hash>/secrets.env
.