Skip to content

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, see Setting your API token and Setting the project name.

Environment variable name Description Example
NEPTUNE_API_TOKEN Neptune API token h0dHBzOi8...aHR0cHM6Lkc
NEPTUNE_MODE Connection mode for the tracking debug
NEPTUNE_PROJECT Neptune project name ml-team/classification
NEPTUNE_CUSTOM_RUN_ID Custom run identifier `date | md5`
NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE Whether to allow self-signed certificates TRUE

NEPTUNE_API_TOKEN#

Info

If you don't provide the api_token parameter 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 called NEPTUNE_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 top-right corner of the app, click your avatar icon.
  2. Select Get Your API token.

    How to find your Neptune API token

  3. Depending on your system:

    1. From the API token dialog in Neptune, copy the export command.

      Example:

      export NEPTUNE_API_TOKEN="uyVrZXkiOiIzNTd..."
      
    2. Append the line to your .profile or other shell configuration file.

    1. From the API token dialog in Neptune, copy the export command.

      Example:

      export NEPTUNE_API_TOKEN="uyVrZXkiOiIzNTd..."
      
    2. Append the line to your .profile or other shell configuration file.

    1. From the API token dialog in Neptune, copy the setx command.

      Example:

      setx 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 getpass import getpass
    api_token = getpass('Enter your Neptune API token: ')
    

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 as log() or upload()). 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, see Connection modes reference.

export NEPTUNE_MODE='debug'
export NEPTUNE_MODE='debug'
set NEPTUNE_MODE='debug'
%env NEPTUNE_MODE='debug'

NEPTUNE_PROJECT#

Info

If you don't provide the project parameter 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 form workspace-name/project-name.

To find and set your project name:

  1. Navigate to Settings → Properties
  2. Copy the full name of the project, or keep the page open to copy the name in a moment.

    Where to copy your project name

  3. Next, assign the project name to an environment variable named NEPTUNE_PROJECT:

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

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

where workspace-name/project-name is 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"

where workspace-name/project-name is 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_PRPOJECT "workspace-name/project-name"
    

    where workspace-name/project-name is the full project name you just copied.

  3. To activate the change, restart the terminal.

To set the project only for the current session

On the command line, enter the following:

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

In Terminal, enter the following:

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

In a terminal app, such as PowerShell or Command Prompt, enter the following:

set NEPTUNE_PRPOJECT="workspace-name/project-name"

NEPTUNE_CUSTOM_RUN_ID#

Info

If you don't provide the custom_run_id parameter 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 32 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='Your custom run ID'
# alternatively:
export NEPTUNE_CUSTOM_RUN_ID=`date | md5`
export NEPTUNE_CUSTOM_RUN_ID='Your custom run ID'
# alternatively:
export NEPTUNE_CUSTOM_RUN_ID=`date | md5`
set NEPTUNE_CUSTOM_RUN_ID='Your custom run ID'

NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE#

In some infrastructure setups, you may encounter problems connecting to Neptune because of the SSL certificate configuration:

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

Those problems typically show as an SSLError or NeptuneConnectionLostException.

To solve it, open a terminal and set the NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE environment variable to a value of TRUE:

export NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE='TRUE'
export NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE='TRUE'
set NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE='TRUE'
%env NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE='TRUE'
Back to top