Hello World

Introduction

This guide will show you how to:

By the end of it, you will see metadata tracked to your first Run in Neptune!

If you are using R, go read this.

Before you start

Make sure you meet the following prerequisites before starting:

  • Have Python 3.6+ installed

  • Have pip or conda installed

You can run this how-to on Google Colab with zero setup. Just click on the Run example in Colab link on the top of the page.

Step 1 - Install neptune-client

Go to the command line of your operating system and run the installation command:

pip
conda
pip
pip install neptune-client
conda
conda install -c conda-forge neptune-client

For more information, read Installation and setup.

Step 2 - Create a hello_world.py

Create a python script called hello_world.py and copy the code below to it:

hello_world.py

import neptune.new as neptune
run = neptune.init(project='<YOUR_WORKSPACE/YOUR_PROJECT>',
api_token='<YOUR_API_TOKEN>') # your credentials
# Track metadata and hyperparameters of your Run
run["JIRA"] = "NPT-952"
run["algorithm"] = "ConvNet"
params = {
"batch_size": 64,
"dropout": 0.2,
"learning_rate": 0.001,
"optimizer": "Adam"
}
run["parameters"] = params
# Track the training process by logging your training metrics
for epoch in range(100):
run["train/accuracy"].log(epoch * 0.6)
run["train/loss"].log(epoch * 0.4)
# Log the final results
run["f1_score"] = 0.66
# Stop logging to your Run
run.stop()

Step 3 - Add your credentials

To log metadata to Neptune you need to pass your credentials to the neptune.init() method.

run = neptune.init(project='<YOUR_WORKSPACE/YOUR_PROJECT>',
api_token='<YOUR_API_TOKEN>') # your credentials

project

project argument has the format workspace_name/project_name

To find it:

  • Go to the Neptune UI

  • Go to your project

  • Open Settings > Properties

  • Copy the project name

api_token

To find it:

  1. Go to the Neptune UI

  2. Open the User menu toggle in the upper right

  3. Click Get Your API token

  4. Copy your API token

or go directly to get my API token page.

How to find your Neptune API token

For example:

run = neptune.init(project='funky_steve/timeseries',
api_token='eyJhcGlfYW908fsdf23f940jiri0bn3085gh03riv03irn')

Step 4 - Run your script and explore results

Now that you have your script ready, run it from your terminal, Jupyter Lab, or other environments.

python hello_world.py

Click on the link in the terminal or notebook or go directly to the Neptune app.

The link should look like this one: https://app.neptune.ai/o/common/org/colab-test-run/e/COL-72/all

See metrics you logged in All Metadata, and Charts sections or go to the Monitoring section to see the hardware consumption.

Conclusions

You’ve learned how to:

  • Install neptune-client,

  • Connect Neptune to your Python script and create a run,

  • Log metrics to Neptune,

  • Explore your metrics in All metadata and Charts sections,

  • See hardware consumption during the run execution in the Monitoring section.

What’s next?