Skip to content

Setting custom run ID#

When working with pipelines or multiple scripts, you may need to access the same run in multiple places.

You can achieve this by specifying a custom identifier (ID) for the run. When you use the same ID for different run instances, you ensure that all metadata is logged to the same run.

To automatically make the ID unique for each new run, you may wish to compose it from components such as hash and time.

Good to know

  • The maximum length of the ID is 32 characters.
  • The custom ID is stored in the system namespace (sys/custom_run_id) field of the run.

Setting custom ID through environment variable#

When a run is initialized, Neptune automatically picks up the custom ID from the environment variable NEPTUNE_CUSTOM_RUN_ID.

To ensure a unique ID for every run, you can use the following example:

export NEPTUNE_CUSTOM_RUN_ID=`date | md5`
export NEPTUNE_CUSTOM_RUN_ID=`date | md5`
set NEPTUNE_CUSTOM_RUN_ID=`date | md5`

Setting custom ID through init_run() argument#

You can set the ID through the custom_run_id argument of the init_run() method when initializing the run.

To ensure a unique ID for every run, you can use the following example:

Example
import hashlib
import time

run = neptune.init_run(
    custom_run_id=hashlib.md5(str(time.time()).encode()).hexdigest(),
)

You can also manually set the ID to a string of your choice.

run = neptune.init_run(custom_run_id="Your custom run ID")