Skip to content

Python client library overview#

The Neptune client library (Neptune API) is an open-source suite of libraries to help you log, query, and download model-building metadata. You can also use the Neptune API to manage projects, users, and model stages.

The API is lightweight and designed to integrate with your MLOps tech stack in a flexible manner. It's up to you to define what to log for each run and in what kind of structure.

Visit neptune-client repo on GitHub 

R package

Neptune supports the R language with a separate client library. The R package uses Python underneath the hood.

Usage#

To start using the library, install it via pip or conda:

pip install neptune-client
conda install -c conda-forge neptune-client
Installing through Anaconda Navigator

To find neptune-client, you may need to update your channels and index.

  1. In the Navigator, select Environments.
  2. In the package view, click Channels.
  3. Click Add..., enter conda-forge, and click Update channels.
  4. In the package view, click Update index... and wait until the update is complete. This can take several minutes.
  5. You should now be able to search for neptune-client.

    Note: The displayed version may be outdated. The latest version of the package will be installed.

then import Neptune in your model-training script:

import neptune.new as neptune

and initialize a run, model, or project object that you'll log metadata to:

run = neptune.init_run()  # (1)
  1. You can omit your credentials from the init functions once you've saved them as environment variables. For details, see Setting your API token.

Assign metadata or files to your object, and execute the script as you normally would.

train.py
# Log metrics or other values inside loops
for epoch in range(n_epochs):
    ...  # Your training loop

    run["train/epoch/loss"].log(loss)  # Each log() appends a value
    run["train/epoch/accuracy"].log(acc)

# Track and version artifacts
run["train/images"].track_files("./datasets/images")

# Upload entire files
run["test/preds"].upload("path/to/test_preds.csv")

# Record text or other metadata, in a structure of your choosing
run["tokenizer"] = "regexp_tokenize"

Tip

The Neptune API is also available to use integrated with various machine-learning tools, which lets you log typical metadata with less manual setup.

To learn more, see Integrations.

Neptune CLI#

The Neptune client library comes with a command-line interface (CLI) tool.

You can use Neptune CLI to locally manage the synchronization of your data with Neptune servers, which comes in handy if you have data that's only stored locally (for example, if you experience connectivity issues).

To learn more, see the Neptune CLI overview.