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, 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

Depending on your operating system open a terminal or CMD and run this command:
pip
conda
1
pip install neptune-client
Copied!
1
conda install -c conda-forge neptune-client
Copied!
This is tested with neptune-client==0.9.16.
For more help see installing neptune-client.

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
1
import neptune.new as neptune
2
3
run = neptune.init(project='<YOUR_WORKSPACE/YOUR_PROJECT>',
4
api_token='<YOUR_API_TOKEN>') # your credentials
5
6
# Track metadata and hyperparameters of your Run
7
run["JIRA"] = "NPT-952"
8
run["algorithm"] = "ConvNet"
9
10
params = {
11
"batch_size": 64,
12
"dropout": 0.2,
13
"learning_rate": 0.001,
14
"optimizer": "Adam"
15
}
16
run["parameters"] = params
17
18
19
# Track the training process by logging your training metrics
20
for epoch in range(100):
21
run["train/accuracy"].log(epoch * 0.6)
22
run["train/loss"].log(epoch * 0.4)
23
24
# Log the final results
25
run["f1_score"] = 0.66
26
27
# Stop logging to your Run
28
run.stop()
Copied!

Step 3: Add your credentials

To log metadata to Neptune you need to pass your credentials to the neptune.init() method.
1
run = neptune.init(project='<YOUR_WORKSPACE/YOUR_PROJECT>',
2
api_token='<YOUR_API_TOKEN>') # your credentials
Copied!

project

The 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 get your API token directly from here.
How to find your Neptune API token
For example:
1
run = neptune.init(project='funky_steve/timeseries',
2
api_token='eyJhcGlfYW908fsdf23f940jiri0bn3085gh03riv03irn')
Copied!

Step 4: Run your script and explore the results

Now that you have your script ready, run it from your terminal, Jupyter Lab, or other environments.
1
python hello_world.py
Copied!
Click on the link in the terminal or notebook or go directly to the Neptune app.
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?

Last modified 1mo ago