Skip to main content
App version: 3.4.6

Create a run

To create a new run, use the Run() constructor:

from neptune_scale import Run

run = Run(run_id="astute-kittiwake-23")

The custom run ID provided to the run_id argument must be unique within the project. It can't contain the / character.

Then, to track metadata, call a logging method on the Run object:

for step in epoch:
# your training loop
acc = ...
loss = ...

run.log_metrics(
data={"metrics/accuracy": acc, "metrics/loss": loss},
step=1,
)

To open a particular run directly in the app, construct a URL as follows:

...neptune.ai/{Workspace}/{Project}/-/run/?customId={CustomRunID}

For details, see Construct Neptune URLs.

Set target project

To specify the Neptune project, use the project argument:

from neptune_scale import Run

run = Run(
run_id="astute-kittiwake-23",
project="team-alpha/project-x", # replace with your workspace and project name
)

You can also save the project name as an environment variable. For details, see Get started.

Viewing runs in the app

In the All runs tab, by default, Neptune displays the latest run of each experiment.

To show all runs, ensure that the toggle is enabled:

All runs tab in the Neptune app with a highlighted button for switching between all runs and experiment runs.

You can save your table configuration as a custom view, which makes it easier to work on the runs later.

Passing run object between scripts

Once you've created a run with the Run() constructor, you can pass it around multiple Python functions.

You can use the Run object to populate parameters of functions imported from other files. This way, you can work with a larger codebase and log from multiple Python scripts at once.

Example
main.py
# Import from "utils.py" file
from utils import log_scores_epoch

run = Run(...)

# Log metrics in the same file
for step in epoch:
run.log_metrics(...)

# Log by using an imported function, passing "run" as the argument
log_scores_epoch(run=run)
utils.py
def log_scores_epoch(run):  # "run" is the Neptune run
score1 = ...
score2 = ...

run.log_configs(
{
"scores/score1": score1,
"scores/score1": score2,
},
)

Tracking run history

To take advantage of forking and analysis of full run history, create experiments rather than stand-alone runs.