Skip to main content

Quickstart

Start by installing Neptune and configuring your Neptune API token and project, as described in Get started.

Then, you can use the following script to log some mocked metadata:

from random import random

from neptune_scale import Run

custom_id = random()
offset = custom_id / 5


def hello_neptune():
run = Run(
api_token="eyJhcGlfYWRkcmVzcyh0...0In0=", # replace with your Neptune API token
project="team-alpha/project-x", # replace with your workspace and project name
experiment_name="seabird-flying-skills",
run_id=f"seagull-{custom_id}",
)

run.log_configs(
{
"parameters/use_preprocessing": True,
"parameters/learning_rate": 0.002,
"parameters/batch_size": 64,
"parameters/optimizer": "Adam",
}
)

for step in range(20):
acc = 1 - 2**-step - random() / (step + 1) - offset
loss = 2**-step + random() / (step + 1) + offset

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

run.add_tags(["purple", "blue", "client 0.6.3"])

run.close()


if __name__ == "__main__":
hello_neptune()

The line if __name__ == "__main__": ensures safe importing of the main module. For details, see the Python documentation.

Passing credentials without environment variables

Although not recommended, you can also pass your Neptune API token and project name directly in the code:

from neptune_scale import Run

run = Run(
project="team-alpha/project-x", # your full project name here
api_token="h0dHBzOi8aHR0cHM6...Y2MifQ==", # your API token here
)

Instead, consider setting your API token and project path to the NEPTUNE_API_TOKEN and NEPTUNE_PROJECT environment variables, respectively.

To inspect the logged metadata in the web app:

  • Click on the run to explore all its metadata.
  • If you log multiple runs, enable compare mode by toggling eye icons ().

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