Neptune environment variables

List of available Neptune environment variables.

To improve the security and operationalization of your workflow, you can store certain arguments of the Neptune initialization functions as environment variables.

This lets you control experiment tracking parameters separately from the model training code.

Tip

You should always store your Neptune API token as an environment variable rather than passing it through your model-training source code.

As a best practice, we recommend you do the same for the project name. For details, seeSet your API tokenandSet the project name.

Environment variable name Description Default (if not set) Example value
NEPTUNE_API_TOKEN Neptune API token - h0dHBzOi8aHR06E0Z...jMifQ==
NEPTUNE_PROJECT Neptune project name - ml-team/classification
NEPTUNE_CUSTOM_RUN_ID Custom run identifier - date | md5
NEPTUNE_MODE Connection mode for the logging async debug
NEPTUNE_DATA_DIRECTORY Path to.neptunedirectory CWD /path/to/directory/
NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE Whether to allow self-signed certificates False True
NEPTUNE_MAX_DISK_USAGE As a percentage, the max disk usage allowed for Neptune - 80
NEPTUNE_RAISE_ERROR_ON_DISK_USAGE_EXCEEDED Whether Neptune should raise an exception on excessive disk usage, instead of only warning True False
NEPTUNE_ENABLE_DEFAULT_ASYNC_NO_PROGRESS_CALLBACK Whether to use the default callback if the synchronization doesn't progress False True
NEPTUNE_ENABLE_DEFAULT_ASYNC_LAG_CALLBACK Whether to use the default callback when the synchronization lags False True

NEPTUNE_API_TOKEN

Info

If you don't provide theapi_tokenparameter to a Neptune init function, the value of this environment variable will be used.

The API token is used for authentication. It's like a password to the application, so you should always keep it secret. The best way to do that is to store it in an environment variable calledNEPTUNE_API_TOKEN. This way, Neptune picks it up from the environment automatically and you don't need to store the token in the source code.

To find and save your API token as an environment variable:

  1. In the bottom-left corner of the app, expand your user menu.
  2. SelectGet Your API token.
  3. Depending on your system: LinuxmacOSWindowsJupyter NotebookFrom the API token dialog in Neptune, copy theexportcommand and append the line to your.profileor other shell initialization file.Example lineexportNEPTUNE_API_TOKEN="uyVrZXkiOiIzNTd..."From the API token dialog in Neptune, copy theexportcommand and append the line to your.profileor other shell initialization file.Example lineexportNEPTUNE_API_TOKEN="uyVrZXkiOiIzNTd..."From the API token dialog in Neptune, copy thesetxcommand.Example linesetx NEPTUNE_API_TOKEN"uyVrZXkiOiIzNTd..."Open a terminal app, such as PowerShell or Command Prompt.Paste the line you copied and press enter.To activate the change, restart the terminal app.You can also navigate toSettings→Edit the system environment variablesand add the variable there.You can use the os library to set the token as an environment variable.Add the following to a notebook cell:importosfromgetpassimportgetpassos.environ["NEPTUNE_API_TOKEN"]=getpass("Enter your Neptune API token: ")From the API token dialog, copy your token, paste it in the input box, and hitEnter.Note that any environment variables declared this way won't persist after the notebook kernel shuts down. If you start a new kernel, they need to be set again.

SelectGet Your API token.

Depending on your system:

From the API token dialog in Neptune, copy theexportcommand and append the line to your.profileor other shell initialization file.

export NEPTUNE_API_TOKEN="uyVrZXkiOiIzNTd..."

From the API token dialog in Neptune, copy theexportcommand and append the line to your.profileor other shell initialization file.

export NEPTUNE_API_TOKEN="uyVrZXkiOiIzNTd..."
  1. From the API token dialog in Neptune, copy thesetxcommand. Example linesetx NEPTUNE_API_TOKEN"uyVrZXkiOiIzNTd..."
  2. Open a terminal app, such as PowerShell or Command Prompt.
  3. Paste the line you copied and press enter.
  4. To activate the change, restart the terminal app.

From the API token dialog in Neptune, copy thesetxcommand.

setx NEPTUNE_API_TOKEN "uyVrZXkiOiIzNTd..."

Open a terminal app, such as PowerShell or Command Prompt.

You can also navigate toSettings→Edit the system environment variablesand add the variable there.

You can use the os library to set the token as an environment variable.

Add the following to a notebook cell:

import os
from getpass import getpass
os.environ["NEPTUNE_API_TOKEN"] = getpass("Enter your Neptune API token: ")

From the API token dialog, copy your token, paste it in the input box, and hitEnter.

Note that any environment variables declared this way won't persist after the notebook kernel shuts down. If you start a new kernel, they need to be set again.

NEPTUNE_PROJECT

Info

If you don't provide theprojectparameter to a Neptune init function, the value of this environment variable will be used.

The project in which new runs will be created. The project name is given in the formworkspace-name/project-name.

To find and set your project name:

  1. Open the project settings ( ).
  2. SelectDetails & privacy.
  3. Find the copy button () next to the project name.
  4. Assign the project name to an environment variable namedNEPTUNE_PROJECT: LinuxmacOSWindowsJupyter NotebookAppend the following line to your.profile(or other shell configuration file):exportNEPTUNE_PROJECT="workspace-name/project-name"whereworkspace-name/project-nameis the full project name you just copied.Append the following line to your.profile(or other shell configuration file):exportNEPTUNE_PROJECT="workspace-name/project-name"whereworkspace-name/project-nameis the full project name you just copied.To set the project name permanently:Open a terminal app, such as PowerShell or Command Prompt.Paste in the following command and press enter:setx NEPTUNE_PROJECT"workspace-name/project-name"whereworkspace-name/project-nameis the full project name you just copied.To activate the change, restart the terminal.You can also navigate toSettings→Edit the system environment variablesand add the variable there.You can use the os library to set the project name as an environment variable:importosos.environ["NEPTUNE_PROJECT"]="workspace-name/project-name"whereworkspace-name/project-nameis the full project name you just copied.Note that any environment variables declared this way won't persist after the notebook kernel shuts down. If you start a new kernel, they need to be set again.

SelectDetails & privacy.

Find the copy button () next to the project name.

Assign the project name to an environment variable namedNEPTUNE_PROJECT:

Append the following line to your.profile(or other shell configuration file):

export NEPTUNE_PROJECT="workspace-name/project-name"

whereworkspace-name/project-nameis the full project name you just copied.

Append the following line to your.profile(or other shell configuration file):

export NEPTUNE_PROJECT="workspace-name/project-name"

whereworkspace-name/project-nameis the full project name you just copied.

To set the project name permanently:

  1. Open a terminal app, such as PowerShell or Command Prompt.
  2. Paste in the following command and press enter: setx NEPTUNE_PROJECT"workspace-name/project-name" whereworkspace-name/project-nameis the full project name you just copied.
  3. To activate the change, restart the terminal.

Paste in the following command and press enter:

setx NEPTUNE_PROJECT "workspace-name/project-name"

whereworkspace-name/project-nameis the full project name you just copied.

To activate the change, restart the terminal.

You can also navigate toSettings→Edit the system environment variablesand add the variable there.

You can use the os library to set the project name as an environment variable:

import os
os.environ["NEPTUNE_PROJECT"] = "workspace-name/project-name"

whereworkspace-name/project-nameis the full project name you just copied.

Note that any environment variables declared this way won't persist after the notebook kernel shuts down. If you start a new kernel, they need to be set again.

NEPTUNE_CUSTOM_RUN_ID

Info

If you don't provide thecustom_run_idparameter to a Neptune init function, the value of this environment variable will be used.

A unique identifier (ID) that can be used to log metadata to a single run from multiple files or processes. This can be useful if your flow involves distributed training, or you're logging metadata at multiple steps of a pipeline.

The maximum length of the custom ID is 36 characters. Make sure to:

  • Use the same ID everywhere.
  • Clear the ID once you want to log to a different run.
export NEPTUNE_CUSTOM_RUN_ID=`date +"%Y%m%d%H%M%s%N" | md5sum`
export NEPTUNE_CUSTOM_RUN_ID=`date +"%Y%m%d%H%M%s%N" | md5`
set NEPTUNE_CUSTOM_RUN_ID=`date +"%Y%m%d%H%M%s%N"`

NEPTUNE_MODE

The connection mode in which the tracking will work when a new run or other object is initialized.

The default is asynchronous (async), which means that Neptune periodically synchronizes the logged metadata with the server in the background.

You can change the mode, for example, to immediately synchronize the data each time a tracking call is made (such asappend()orupload()). You can also log offline and manually sync the data later, or log in debug mode so that no data is stored anywhere.

To learn more, seeConnection modes reference.

export NEPTUNE_MODE='debug'
export NEPTUNE_MODE='debug'
setx NEPTUNE_MODE 'debug'
%env NEPTUNE_MODE='debug'

NEPTUNE_DATA_DIRECTORY

Path where the.neptunedirectory should be created.

Normally the Neptune data directory (`.neptune/) is created in the current working directory (CWD). If your CWD is not writeable for any reason, you can use this environment variable to specify a different location for the.neptune`folder.

For example, if you declareNEPTUNE_DATA_DIRECTORY=/path/to/dirthen the Neptune data directory will be at/path/to/dir/.neptune/.

See also

Change location of.neptunefolder

NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE

In some infrastructure setups, you may encounter problems connecting to Neptune because of the SSL certificate configuration. This can happen if, for example:

  • You are in a corporate network, behind a proxy that inspects traffic between your runs and Neptune SaaS.
  • The SSL/TLS certificate of your self-hosted installation is not recognized by Python by default.
  • The software on your machine is not up to date.

Those problems typically show as anSSLErrororNeptuneConnectionLostException.

To solve it, open a terminal and set theNEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATEenvironment variable to a value ofTrue:

export NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE='True'
export NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE='True'
setx NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE 'True'
%env NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE='True'

NEPTUNE_MAX_DISK_USAGE

You can manage the maximum allowed disk usage by setting a percentage value to theNEPTUNE_MAX_DISK_USAGEenvironment variable.

By default, Neptune will raise an exception if this limit is exceeded. (If you want Neptune to simply stop logging and saving data to disk instead of throwing an error, you can setNEPTUNE_RAISE_ERROR_ON_DISK_USAGE_EXCEEDEDtoFalse.)

For example, to limit Neptune's disk usage to 80%:

export NEPTUNE_MAX_DISK_USAGE=80
export NEPTUNE_MAX_DISK_USAGE=80
setx NEPTUNE_MAX_DISK_USAGE 80
%env NEPTUNE_MAX_DISK_USAGE=80

NEPTUNE_RAISE_ERROR_ON_DISK_USAGE_EXCEEDED

If this environment variable is set toTrueor not set, Neptune will raise an exception if the disk usage allowed by theNEPTUNE_MAX_DISK_USAGEoption is exceeded.

If you setNEPTUNE_RAISE_ERROR_ON_DISK_USAGE_EXCEEDEDtoFalse, Neptune will instead just print a warning and stop saving data to the disk.

export NEPTUNE_RAISE_ERROR_ON_DISK_USAGE_EXCEEDED='False'
export NEPTUNE_RAISE_ERROR_ON_DISK_USAGE_EXCEEDED='False'
setx NEPTUNE_RAISE_ERROR_ON_DISK_USAGE_EXCEEDED 'False'
%env NEPTUNE_RAISE_ERROR_ON_DISK_USAGE_EXCEEDED='False'

NEPTUNE_ENABLE_DEFAULT_ASYNC_LAG_CALLBACK

Whether to enable the default callback when the lag between a queued operation and its synchronization with the server exceeds 1800 seconds (30 minutes).

You can override this default threshold with theasync_lag_thresholdinitialization parameter.

The default callback function (stop_synchronization_callback()) stops the object after 60 seconds of the callback being called.

To enable the default callback, open a terminal and set the environment variable to a value ofTrue:

export NEPTUNE_ENABLE_DEFAULT_ASYNC_LAG_CALLBACK='True'
export NEPTUNE_ENABLE_DEFAULT_ASYNC_LAG_CALLBACK='True'
setx NEPTUNE_ENABLE_DEFAULT_ASYNC_LAG_CALLBACK 'True'
%env NEPTUNE_ENABLE_DEFAULT_ASYNC_LAG_CALLBACK='True'

For the full guide, seeHow to use callbacks when sync is interrupted.

NEPTUNE_ENABLE_DEFAULT_ASYNC_NO_PROGRESS_CALLBACK

Whether to enable the default callback when the synchronization with the server has not progressed at all for 300 seconds (5 minutes).

You can override this default threshold with theasync_no_progress_thresholdinitialization parameter.

The default callback function (stop_synchronization_callback()) stops the object after 60 seconds of the callback being called.

To enable the default callback, open a terminal and set the environment variable to a value ofTrue:

export NEPTUNE_ENABLE_DEFAULT_ASYNC_NO_PROGRESS_CALLBACK='True'
export NEPTUNE_ENABLE_DEFAULT_ASYNC_NO_PROGRESS_CALLBACK='True'
setx NEPTUNE_ENABLE_DEFAULT_ASYNC_NO_PROGRESS_CALLBACK 'True'
%env NEPTUNE_ENABLE_DEFAULT_ASYNC_NO_PROGRESS_CALLBACK='True'

For the full guide, seeHow to use callbacks when sync is interrupted.



This page is originally sourced from the legacy docs.