Skip to content

Field types reference#

To support various types of metadata, Neptune fields come in a few different types.

  1. The metadata type and logging method together determine the resulting field type.
  2. The field type determines the available operations and methods.

Field types you can create and modify:

Metadata type Example Logging method      Resulting field type
Single value Parameters, final scores, text, time =/assign() Float, Integer, Boolean, String, Datetime
Series of values Metrics, loss, accuracy append()/extend()* FloatSeries
Series of text Journal, notes append()/extend()* StringSeries
Series of files Image series, predictions append()/extend()* FileSeries
Single file Image, plot file, data sample upload() File
Set of files Large number of files upload_files() FileSet
Tags Text tags to annotate objects add() StringSet
File(s) to be versioned Dataset, model file track_files() Artifact

* Previously log()

The table in the neptune.types section below displays all the supported field types, including those that can be viewed but not manually created.


neptune.types#

Type Description
Artifact Field type for versioning datasets, models, and other files.
Float, Integer, Boolean, String, Datetime, File, GitRef, and RunState Used for a single value of the given type, or a single file.
FileSet Used to hold a larger number of files when access to a single file is rare.
Handler Obtained when you access a field path that doesn't exist yet.
Namespace handler Obtained when you access a field path that is one or more levels higher than an existing field. Used as a shortcut for accessing fields by specifying only a relative path within the namespace.

Example: params_ns = run["parameters"], then params_ns["lr"] = 0.3

Series Used for series of values or files (for example, images). Available types are FloatSeries, StringSeries and FileSeries.
Set Field holding unorganized sets of values. The available type is StringSet, which is used to interact with the object's tags. You can access and modify fields of this type, but not manually create them.

Artifact#

Field type for holding datasets, models, and other artifacts.

The artifact can refer to either a single file or a collection of files. Examples:

  • Dataset in CSV format
  • Folder with training images as PNG files
  • Model binaries

You may want to track files as artifacts especially if they are large (to avoid uploads taking up storage space) but you would still like to version and compare them between runs.

Neptune tracks the following artifact metadata:

  • Version (MD5 hash)
  • Location (path)
  • Size
  • Folder structure
  • Last modified time
How the hash is calculated

The following components are used to calculate the hash of each artifact:

  • Hash of contents
  • Last modification time
  • Size
  • Storage type (local or S3)
  • Path in artifact
  • Original location (URI for S3 or path to local file)

When anything in the above changes, the hash changes as well. This includes adding a file to the artifact.

For instructions, see the Tracking artifacts guide.

Assignment: =#

Convenience alias for assign().

assign()#

Assigns the provided value to the field.

Parameters

Name Type Default Description
value str or Artifact - Value to be stored in the field
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Examples

import neptune

run = neptune.init_run()

run["datasets/images"].track_files("./images")
run["datasets/images-copy"] = run["datasets/images"].fetch()

download()#

Downloads all the files that are referenced in the field.

Parameters

Name     Type Default Description
destination str, optional None Path to where the files should be downloaded. If None, the files are downloaded to the current working directory.
  • If destination is a directory, the files are downloaded to the specified directory, with filenames composed of the field name and extension (if present).
  • If destination is a path to a file, the file is downloaded under the specified name.

Examples

import neptune

run = neptune.init_run(
    with_id="NER-2",  # Neptune ID of a run with artifact
    mode="read-only",  # read-only mode does not count toward monitoring time
)

run["artifacts/images"].download(destination="datasets/train/images")

fetch()#

Fetches the field value.

You should use fetch() only to copy the artifact.

Returns

Artifact object stored in the field.

Examples

import neptune

run = neptune.init_run()

run["datasets/images"].track_files("./images")
run["datasets/images-copy"] = run["datasets/images"].fetch()

fetch_files_list()#

Fetches a list of artifact files.

Returns

List of ArtifactFileData objects for all the files referenced in the artifacts.

You can use the following fields of the ArtifactFileData object:

Name     Type Description
"file_hash" str Hash of the file
"file_path" str URL of the file in the Neptune app
"size" int Size of the file in KB
"metadata" dict Dictionary with the following keys:
  • "file_path": location (path) of the file either on local storage or S3-compatible storage
  • "last_modified": when the artifact content was last changed

Examples

import neptune

run = neptune.init_run(
    with_id="NER-2",  # Neptune ID of a run with artifact
    mode="read-only",  # read-only mode does not count toward monitoring time
)

artifact_list = run["artifacts/images"].fetch_files_list()
artifact_list[0].file_hash
artifact_list[0].file_path
artifact_list[0].metadata["last_modified"]

fetch_hash()#

Fetches the hash of the artifact.

Returns

Hash of the Neptune artifact as a str.

Examples

import neptune

run = neptune.init_run(
    with_id="NER-2",  # Neptune ID of a run with artifact
    mode="read-only",  # read-only mode does not count toward monitoring time
)

run["artifacts/images"].fetch_hash()

track_files()#

Saves the following artifact metadata to Neptune:

  • Version (MD5 hash)
  • Location (path)
  • Size
  • Folder structure
  • Contents

Works for files, folders, or S3-compatible storage.

Parameters

Name     Type Default Description
path str - File path or S3-compatible path to the file or folder that you want to track.
destination str None Location in the Neptune artifact namespace where you want to log the metadata.
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Examples

import neptune

run = neptune.init_run()

run["artifacts/images"].track_files("datasets/train/images")

Float, Integer, Boolean, String, and Datetime#

Field type representing a floating-point number, integer, Boolean value, text string, or datetime value.

Assignment: =#

Convenience alias for assign().

assign()#

Assigns the provided value to the field.

Parameters

Name Type Default Description
value float - Values to assign to the field.
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Examples

import neptune

run = neptune.init_run()

# You can use the Python assign operator (=)
run["params/lr"] = 0.8
# as well as the assign() method
run["params/lr"].assign(0.8)

Parameters

Name Type Default Description
value int - Values to assign to the field.
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Examples

import neptune

run = neptune.init_run()

# You can use the Python assign operator (=)
run["params/max_epochs"] = 10
# as well as the assign() method
run["params/max_epochs"].assign(10)

Parameters

Name Type Default Description
value Boolean - Values to assign to the field.
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Examples

import neptune

run = neptune.init_run()

# You can use the Python assign operator (=)
run["params/use_preprocessing"] = True
# as well as the assign() method
run["params/use_preprocessing"].assign(True)

Parameters

Name Type Default Description
value str - Values to assign to the field.
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Examples

import neptune

run = neptune.init_run()

# You can use the Python assign operator (=)
run["params/optimizer"] = "Adam"
# as well as the assign() method
run["params/optimizer"].assign("Adam")

Note

Due to a technical limitation, we limit the number of indexed characters in String fields to 1000 characters. This means that when searching the runs table, only the first 1000 characters will be considered.

You can use the Python datetime library to express and assign dates and times.

Parameters

Name Type Default Description
value datetime object - Values to assign to the field.
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Examples

Log the exact end of training:

from datetime import datetime
import neptune

run = neptune.init_run()

run["train/end"] = datetime.now()

Log when the evaluation started:

run["eval/start"] = datetime.now()

Log other time-related metadata:

run["dataset/creation_date"] = datetime.fromisoformat("1998-11-01")

fetch()#

Fetches the field value from Neptune servers.

Returns

The float value stored in the field.

Example

import neptune

# Initialize existing run with ID "NER-12"
run = neptune.init_run(with_id="NER-12")

# Fetch highest accuracy so far
top_acc = run["train/acc/highest"].fetch()

Returns

The int value stored in the field.

Example

import neptune

# Initialize existing run with ID "NER-12"
run = neptune.init_run(with_id="NER-12")

# Fetch epoch count
epoch = run["train/epoch"].fetch()

Returns

The bool value stored in the field.

Example

import neptune

# Initialize existing run with ID "NER-12"
run = neptune.init_run(with_id="NER-12")

# Fetch use_proprocessing parameter
use_preprocessing = run["params/use_preprocessing"].fetch()

Returns

The str value stored in the field.

Example

import neptune

# Initialize existing run with ID "NER-12"
run = neptune.init_run(with_id="NER-12")

# Fetch optimizer parameter
optimizer = run["params/optimizer"].fetch()

Returns

The datetime value stored in the field.

Example

import neptune

# Initialize existing run with ID "NER-12"
run = neptune.init_run(with_id="NER-12")

# Fetch the time when the training ended
eval_start = run["train/end"].fetch()

GitRef#

Contains information about the Git repository at the time of starting a tracked run.

  • The GitRef type does not expose any methods, but you can view the source_code/git field in the Neptune web app.
    • To inspect the information, in the run view, go to Source codeGit.
  • You cannot manually create or modify GitRef fields, but you can disable Git tracking (see DISABLED).

Parameters

Name       Description
repository_path

Custom path where Neptune should look for a Git repository. Neptune looks for a repository in the supplied path as well as its parent directories.

If not provided, the path to the script that is currently executed is used.

Returns

GitRef value object with the Git information. For details, see Logging Git info.

Example

import neptune
from neptune.types import GitRef

run = init_run(git_ref=GitRef(repository_path="/path/to/repo"))

DISABLED#

Constant that disables Git tracking for your run.

import neptune
from neptune.types import GitRef

run = init_run(git_ref=GitRef.DISABLED)

File#

Holds a single file of any type.

upload()#

Uploads the provided file under the specified field path.

Parameters

Name Type Default Description
value str or File - Path of the file to upload, or File value object
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Examples

import neptune

run = neptune.init_run()

# Upload example data
run["dataset/data_sample"].upload("sample_data.csv")

Both the content and the extension is stored. When downloaded, the filename is a combination of the path and extension:

run["dataset/data_sample"].download()  # data_sample.csv

Many types are implicitly converted to File on the fly. For example, image-like objects such as Matplotlib figures:

import matplotlib.pyplot as plt

plt.plot(data)
run["dataset/distribution"].upload(plt.gcf())  # gcf() gets the figure object

Assignment: =#

Convenience alias for assign().

assign()#

You can also upload a file by assigning the File value object to the specified field path.

Parameters

Name Type Default Description
value File - File value object
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Examples

import neptune
from neptune.types import File

run = neptune.init_run()

run["dataset/data_sample"] = File("sample_data.csv")

download()#

Downloads the stored file to the working directory or specified destination.

Parameters

Name     Type Default Description
destination str, optional None Path to where the file should be downloaded. If None, the file is downloaded to the working directory.
  • If destination is a directory, the file is downloaded to the specified directory with a filename composed of the field name and extension (if present).
  • If destination is a path to a file, the file is downloaded under the specified name.

fetch_extension()#

A programmatic way to find out the extension of a stored file.

Returns

str with the extension of the stored file.

Examples

import neptune
from neptune.types import File

run = neptune.init_run()

# Upload model as a File field
run["model/last"].upload("model.pt")

# Check extension of the uploaded File
ext = run["model/last"].fetch_extension()
ext == "pt"  # True

as_image()#

Static method for converting image objects or image-like objects to an image File value object.

This way you can upload figures, arrays, and tensors as static images.

Name Description
image Image-like object to be converted. Supported are PyTorch tensors, TensorFlow/Keras tensors, NumPy arrays, PIL images, Matplotlib figures.

Returns

File value object with converted image.

Examples

Convert NumPy array to File value object and upload it:

import neptune
from neptune.types import File

run = neptune.init_run()

run["train/prediction_example"].upload(File.as_image(numpy_array))

Convert PIL image to File value object and upload it:

pil_file = File.as_image(pil_image)
run["dataset/data_sample/img1"].upload(pil_file)

You can also upload a PIL image without explicit conversion:

run["dataset/data_sample/img2"].upload(pil_image)

as_html()#

Converts an object to an HTML File value object.

This way you can upload interactive charts or data frames to explore them in the Neptune app.

Name Description
value Object to be converted. Supported:
  • Altair, Bokeh, Plotly, Matplotlib interactive charts
  • pandas DataFrame objects

as_pickle()#

Pickles a Python object and stores it in a File value object.

This way you can upload any Python object for future use.

Name Description
obj Object to be converted (any Python object that supports pickling).

Returns

File value object with the pickled object.

Examples

import neptune
from neptune.types import File

run = neptune.init_run()

# Pickle model object and upload it
run["results/pickled_model"].upload(File.as_pickle(trained_model))

from_content()#

Factory method for creating File value objects directly from binary and text content.

UTF-8 encoding is used for text content.

Parameters

Name Type Default Description
content str or bytes - Text or binary content to stored in the File value object.
extension str, optional None Extension of the created file that will be used for interpreting the type of content for visualization. If None, it will be bin for binary content and txt for text content.

Returns

File value object created from the content.

Example

import neptune
from neptune.types import File

run = neptune.init_run()

run["large_text_as_file"].upload(File.from_content(variable_with_my_text))

HTML example:

html_str = (
    "<button type='button', style='background-color:#005879; width:400px; "
    "height:400px; font-size:30px'> <a style='color: #ccc', "
    "href='https://docs.neptune.ai'>Take me back to the docs!<a> </button>"
)

with open("sample.html", "w") as f:
    f.write(html_str)
    html_obj = File.from_content(html_str, extension="html")
    run["html_content"].upload(html_obj)

from_path()#

Creates a File value object from a given path.

Equivalent to File(path), but you can specify the extension separately.

Parameters

Name Type Default Description
path str or bytes - Path of the file to be stored in the File value object.
extension str, optional None Extension of the file, if not included in the path argument.

Returns

File value object created based on the path.

Example

import neptune
from neptune.types import File

run = neptune.init_run()

run["sample_text"].upload(File.from_path(path="data/test/sample", extension="txt"))

from_stream()#

Factory method for creating File value objects directly from binary and text streams.

UTF-8 encoding is used for text content.

Parameters

Name Type Default Description
stream IOBase - Stream to be converted.
seek int, optional 0 Change the stream position to the given byte offset. For details, see the IOBase documentation .
extension str, optional None Extension of the created file that will be used for interpreting the type of content for visualization. If None, it will be bin for binary content and txt for text content.

Returns

File value object created from the stream.

Example

import neptune
from neptune.types import File

run = neptune.init_run()

with open("image.jpg", "rb") as f:
    image = File.from_stream(f, extension="jpg")
    run["upload_image_from_stream"].upload(image)

FileSeries#

A field containing a series of image files.

append()#

Logs the provided file to the end of the series.

append() replaces log()

As of neptune-client 0.16.14, append() and extend() are the preferred methods for logging series of values.

You can upgrade your installation with pip install -U neptune-client or continue using log().

Parameters

Name     Type Default Description
value File value object - The file to be appended.
step float, int, optional None Index of the log entry being appended. Must be strictly increasing.
timestamp float, int, optional None Time index of the log entry being appended, in Unix time format. If None, the current time (obtained with time.time()) is used.
name str, optional None Name of the logged file.
description str, optional None Short description of the logged file.
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Examples

Append an image file to a FileSeries field:

import neptune
from neptune.types import File

run = neptune.init_run()
run["train/prediction_example"].append(File(path_to_file))

Log a Matplotlib figure object:

run["train/distribution"].append(plt_histogram, step=epoch)

Convert a NumPy array to File value object and log it:

run["train/prediction_example"].append(File.as_image(numpy_array))

You can also log a name and description for the image:

Log data sample
for plt_image, class_name in data_sample:
    run["data/sample"].append(plt_image, name=class_name)
Log predictions with class probabilities
for image, y_pred in zip(x_test_sample, y_test_sample_pred):
    description = "\n".join(
        [f"class {i}: {pred}" for i, pred in enumerate(y_pred)]
    )
    run["train/predictions"].append(image, description=description)

Logging with custom step:

import matplotlib.pyplot as plt

run = neptune.init_run()

for epoch in range(100):
    plt_fig = get_histogram()

    run["train/distribution"].append(
        plt_fig,
        step=epoch,
    )

extend()#

Appends the provided collection of File value objects to the series.

Parameters

Name     Type Default Description
values collection of File value objects - The collection or dictionary of files to be appended to the series field.
steps collection of float or collection of int (optional) None Indices of the values being appended. Must be strictly increasing.
timestamps collection of float or collection of int (optional) None Time indices of the values being appended, in Unix time format. If None, the current time (obtained with time.time()) is used.
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

log()#

See append() (append one value at a time) or extend() (append a collection of values).

download()#

Downloads all the files stored in the series and saves them locally.

Parameters

Name     Type Default Description
destination str, optional None Path to where the files should be downloaded. If None, the files are downloaded to the working directory.
  • If destination is a directory, the file is downloaded to the specified directory with a filename composed of the field name and extension.
  • If destination is a path to a file, the file is downloaded under the specified name.

download_last()#

Downloads the last file stored in the series and saves it locally.

Parameters

Name     Type Default Description
destination str, optional None Path to where the file should be downloaded. If None, the file is downloaded to the working directory.
  • If destination is a directory, the file is downloaded to the specified directory with a filename composed of the field name and extension.
  • If destination is a path to a file, the file is downloaded under the specified name.

FileSet#

Field type used to hold a larger number of files when access to a single file is rare.

Best used for items that can be easily browsed through the web interface and are typically accessed as a whole, such as a folder of source files or image examples.

upload_files()#

Uploads the provided file or files and stores them under the FileSet field.

Parameters

Name Type Default Description
globs str or collection of str - Path or paths to the files to be uploaded.
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Example

import neptune

run = neptune.init_run()
run["datasets_folder"].upload_files("datasets")

delete_files()#

Deletes the specified files from the FileSet field.

Parameters

Name Type Default Description
paths str or collection of str - Path or paths to files or folders to be deleted.

Note that these are paths relative to the FileSet itself: If the FileSet contains file sample.txt, ner/notes.txt, and ner/data.csv, to delete whole subfolder you would pass ner as the argument.

wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Example

Deleting a file from a FileSet field of an existing run:

>>> import neptune
>>> run = neptune.init_run(with_id="CLAS-14")
>>> run["datasets_folder"].delete_files("datasets/data_sample_v1.csv")

download()#

Downloads all the files stored in the FileSet field in the form of a ZIP archive.

Parameters

Name     Type Default Description
destination str, optional None Path to where the files should be downloaded. If None, the files are downloaded to the working directory.
  • If destination is a directory, the file is downloaded to the specified directory with a filename composed of the field name and extension.
  • If destination is a path to a file, the file is downloaded under the specified name.

FloatSeries#

Field containing a series of numbers, for example:

  • Training metrics
  • Change of performance of the model in production

You can index the series by step or by time.

append()#

Appends the provided value to the series.

append() replaces log()

As of neptune-client 0.16.14, append() and extend() are the preferred methods for logging series of values.

You can upgrade your installation with pip install -U neptune-client or continue using log().

Parameters

Name Type Default Description
value float or int - The value to be added to the series field.
step float, int, optional None Index of the log entry being appended. Must be strictly increasing.

Note: This is effectively how you set custom x values for a chart.

timestamp float, int, optional None Time index of the log entry being appended, in Unix time format. If None, the current time (obtained with time.time()) is used.
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Examples

run = neptune.init_run()

for epoch in range(parameters["n_epochs"]):
    ...  # My training loop

    run["train/epoch/loss"].append(loss)
    run["train/epoch/accuracy"].append(acc)

Setting custom step values:

run["metric"].append(
    value=acc,
    step=i,
)

You can also append values to multiple series at once by passing a dictionary of values. Pass the field name as the key.

run["train"].append({"acc": acc, "loss": loss})

extend()#

Appends the provided collection of values to the series.

Parameters

Name     Type Default Description
values collection of float or collection of int - The collection or dictionary of values to be appended to the series field.
steps collection of float or collection of int (optional) None Indices of the values being appended. Must be strictly increasing.

Note: This is effectively how you set custom x values for a chart.

timestamps collection of float or collection of int (optional) None Time indices of the values being appended, in Unix time format. If None, the current time (obtained with time.time()) is used.
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Example

The following example reads a CSV file into a pandas DataFrame and extracts the values to create a Neptune series field.

run = neptune.init_run()

df = pandas.read_csv("time_series.csv")
ys = df["value"]
ts = df["timestamp"]

run["data/example_series"].extend(ys, timestamps=ts)

log()#

See append() (append one value at a time) or extend() (append a collection of values).

fetch_last()#

Fetches the last value stored in the series.

Returns

Last logged float value.

Example

>>> import neptune
>>> run = neptune.init_run(with_id="CLS-15")
>>> final_loss = run["train/loss"].fetch_last()
>>> print(final_loss)
0.15250000000000002

fetch_values()#

Fetches all values stored in the series.

Parameters

Name         Type Default Description
include_timestamp Boolean, optional False Whether the fetched data should include the timestamp field.

Returns

pandas.DataFrame containing all the values and their indexes stored in the series field.

Example

>>> import neptune
>>> run = neptune.init_run(with_id="CLS-15")
>>> losses = run["train/loss"].fetch_values()
>>> print(losses)
   step  value               timestamp
0   0.0   0.00 2022-07-08 12:30:30.087
1   1.0   0.43 2022-07-08 12:30:30.087
2   2.0   0.86 2022-07-08 12:30:30.087
3   3.0   1.29 2022-07-08 12:30:30.087
4   4.0   1.72 2022-07-08 12:30:30.087
5   5.0   2.15 2022-07-08 12:30:30.087
6   6.0   2.58 2022-07-08 12:30:30.087
7   7.0   3.01 2022-07-08 12:30:30.087
8   8.0   3.44 2022-07-08 12:30:30.088
9   9.0   3.87 2022-07-08 12:30:30.088

Handler#

When you access the path of a run that doesn't exist yet, you obtain a Handler object.

Think of it as a wildcard that can become any type once you invoke a specific logging method on it – if you invoke upload(), it becomes a File field; if you invoke append(), it becomes a FloatSeries.

Note

A Handler object can also become a namespace handler if you create a field at a lower level of organization.

The Handler object exposes:

  • All tracking methods – such as assign(), append(), upload(), and upload_files() – of all other field types
  • Namespace handler methods
Kedro note

The Handler class is located in neptune.handler.Handler. When setting up nodes.py, pass this value to the neptune_run option of the report_accuracy() function:

def report_accuracy(
    predictions: np.ndarray,
    test_y: pd.DataFrame,
    neptune_run: neptune.handler.Handler,
) -> None:
...

Examples

import neptune
run = neptune.init_run()

# Accessing "train/batch/acc" returns a Handler as the field does not exist yet
handler_object = run["train/batch/acc"]

# You can use it as if you would use any other field
handler_object.append(0.7)

# Once the field is created under the path, only field methods are accepted
handler_object.append(0.6)  # Works
handler_object.upload("image.png")  # Error: handler_object became a FloatSeries

Namespace handler#

An object representing a namespace in the metadata structure of a Neptune object. Example: Accessing run["params"] when you have a field params/max_epochs.

You can think of namespaces as folders for organizing your metadata. If you log the fields "params/max_epochs" and "params/lr", they will be grouped under a namespace called "params".

The namespace handler exposes similar methods as other Neptune objects – however, all field paths are relative to the namespace:

import neptune

# You can upload the value through an absolute path
run["params/max_epochs"] = 20

# Or with a namespace handler and a relative path
params_ns = run["params"]
params_ns["max_epochs"] = 20

Field lookup: []#

You can access the field of an object through a dict-like field lookup: run[field_path].

This way, you can

  • track metadata:

    run["params/max_epochs"] = 20
    for epoch in range(20):
        run["epoch/acc"].append(epoch_accuracy)
    
  • fetch already tracked metadata, such as retrieving parameters when resuming a run or downloading metadata for a custom analysis:

    learning_rate = run["params/lr"].fetch()
    
    run["train/diagnostic_plots"].download()
    acc_df = run["train/epoch/acc"].fetch_values()
    

Returns

The returned type depends on the field type and whether a field is stored under the given path.

Path Example Returns
Field exists - The returned type matches the type of the field
Field does not exist - Handler object
Path is namespace and has field

Path: "train"

Field "train/acc" exists

Namespace handler object

Example

import neptune

run = neptune.init_run()

params_ns = run["parameters"]
params_ns["lr"] = 0.3  # Stores 0.3 under the path "parameters/lr"

Assignment: =#

Convenience alias for assign().

assign()#

Assign values to multiple fields from a dictionary. For example, you can use this method to quickly log all the parameters of a run.

Remember that the resulting paths will be a combination of the namespace path and the provided relative path.

Example

import neptune

run = neptune.init_run()

# Assign a single parameter
run["model/params/batch_size"] = 64

# Access params namespace handler
params_ns = run["model/params"]

# Assign additional parameters in batch
PARAMS = {"max_epochs": 20, "optimizer": "Adam"}
params_ns.assign(PARAMS)

# "=" needs to be used in combination with "[]"
params_ns = PARAMS  # Does not work
run["model/params"] = PARAMS  # Works

# This also works with relative paths
model_ns = run["model"]
model_ns["params"] = PARAMS

get_root_object()#

Returns the root-level object of a namespace handler.

For example, if you call the method on the namespace of a run, the run object is returned.

Example

import neptune
run = neptune.init_run()
run["workflow/steps/pretraining/params"] = {...}
...

pretraining = run["workflow/steps/pretraining"]  # (1)!
pretraining.stop()  # Error: pretraining is a namespace, not a run

pretraining_run = pretraining.get_root_object()
pretraining_run.stop()  # The root run is stopped
  1. The namespace "pretraining" is nested under the "workflow/steps" namespace inside the run object. As such, the pretraining object is a namespace handler object.

RunState#

Contains the state (Active/Inactive) of a tracked run.

  • You cannot manually create or modify RunState fields.
  • The RunState type does not expose any methods, but you can:

StringSeries#

Field containing series of text values.

Info

A single text log entry is limited to 1000 characters, but there is no limit to the number of entries in the series.

If the logged text exceeds this character limit, the entry will be truncated to match the limit.

append()#

Appends the provided value to the end of the series.

append() replaces log()

As of neptune-client 0.16.14, append() and extend() are the preferred methods for logging series of values.

You can upgrade your installation with pip install -U neptune-client or continue using log().

Parameters

Name Type Default Description
value str - The value to be logged.
step float, int, optional None Index of the log entry being appended. Must be strictly increasing.

Note: This is effectively how you set custom x values for a chart.

timestamp float, int, optional None Time index of the log entry being appended, in Unix time format. If None, the current time (obtained with time.time()) is used.
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Example

Iteratively log a series of short text entries (max 1000 characters):

for epoch in range(epochs_nr):
    token = str(...)
    run["train/tokens"].append(token)

extend()#

Appends the provided collection of values to the series.

Parameters

Name     Type Default Description
values collection of str - The collection or dictionary of strings to be appended to the series field.
steps collection of float or collection of int (optional) None Indices of the values being appended. Must be strictly increasing.

Note: This is effectively how you set custom x values for a chart.

timestamps collection of float or collection of int (optional) None Time indices of the values being appended, in Unix time format. If None, the current time (obtained with time.time()) is used.
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

log()#

See append() (append one value at a time) or extend() (append a collection of values).

fetch_last()#

Fetches the last value stored in the series.

Returns

Last logged str value.

Example

import neptune

run = neptune.init_run(with_id="CLS-15")

last_stderr_line = run["monitoring/stderr"].fetch_last()

fetch_values()#

Fetches all values stored in the series.

Parameters

Name         Type Default Description
include_timestamp Boolean, optional False Whether the fetched data should include the timestamp field.

Returns

pandas.DataFrame containing all the values and their indexes stored in the series field.

Example

import neptune

run = neptune.init_run(with_id="CLS-15")

stderr = run["monitoring/6519428b/stderr"].fetch_values()

StringSet#

A field containing an unorganized set of strings. You can access and modify fields of this type, but not manually create them.

Currently, the supported StringSet field is "sys/tags". You can use it to manage tags for runs and other Neptune objects.

add()#

Adds the provided text string or strings to the set.

Parameters

Name Type Default Description
values str or collection of str - Tag or tags to be applied.
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Examples

import neptune

run = neptune.init_run()

run["sys/tags"].add(["maskRCNN", "finetune"])

remove()#

Removes the provided tag or tags from the set.

Parameters

Name Type Default Description
values str or collection of str - Tag or tags to be removed.
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Examples

import neptune

run = neptune.init_run()

run["sys/tags"].remove(["finetune"])

clear()#

Removes all tags from the set.

Parameters

Name Type Default Description
wait Boolean, optional False By default, tracked metadata is sent to the server in the background. With this option set to True, Neptune first sends all data before executing the call. See Connection modes.

Examples

import neptune

run = neptune.init_run()

run["sys/tags"].clear()

fetch()#

Fetches all tags from the set.

Returns

set of str with an object's tags.

Example

run_tags = run["sys/tags"].fetch()

if "maskRCNN" in run_tags:
    print_analysis()