Skip to content

Overwrite logged metadata#

This page explains the mechanics to overwrite or override metadata logged to runs or other objects.

General principle#

If you assign new data to an existing field, that data will overwrite the data previously logged to that field.

Exceptions

Iterative logging methods do not overwrite previous values when resuming a run. These are:

  • append() – the passed value is added to the end of the existing series.
  • extend() – the passed set of values is added to the end of the existing series.
  • track_files() – passing a new file path will add tracking of that file to the overall artifact field.

Overwriting fields#

Caution

Overwriting the metadata stored under a namespace or field cannot be undone.

To edit the value of an existing field, you overwrite it with new data of the same type.

If the run that you want to modify is already active, you can simply re-execute the code that assigns metadata to the field.

Overwriting a field in the same session
>>> run = neptune.init_run()
>>> run["learning_rate"] = 0.01
>>> run["learning_rate"] = 0.02

Result

The value of the learning_rate field has been changed to 0.02 instead of 0.01.

Resuming an inactive run#

If the run that you wish to edit is already inactive, you need to reinitialize it in your code.

Previously logged
>>> run = neptune.init_run()
>>> run["learning_rate"] = 0.01
Resume the run and modify the field
>>> run = neptune.init_run(with_id="<ID_of_previous_run>")
>>> run["learning_rate"] = 0.02
How do I find the ID?

Neptune IDs highlighted in the Neptune web app

If the run is active, you can also fetch its ID via API:

run_id = run["sys/id"].fetch()

Overwriting series fields#

If you resume a run and continue logging to an existing series field, the new values won't overwrite the previous ones.

To overwrite the series field (have it start from a new set of values), you need to pop or delete the field first.

Caution

Using del or pop() on a namespace or field cannot be undone.

Overwriting a series from scratch
>>> print(run.exists("train/accuracy"))
True
>>> del run["train/accuracy"]
>>> print(run.exists("train/accuracy"))
False
>>> for epoch in range(checkpoint, 1000):
...     run["train/accuracy"].append(acc)
>>> # A new series is created under the original field

You can also change the field path to something else, which will preserve the old series.

Overwriting field with new type#

If you've assigned metadata to a field but want to store metadata of a different type under that field name, you need to delete the field first.

Attempt to assign metadata of a different type to the same field
>>> run["my_field"] = "lorem"
>>> run["my_field"] = 1
TypeError: value must be a str or NoneType or StringifyValue (was <class 'int'>)
Delete the field first, then assign a new value
>>> del run["my_field"]
>>> run["my_field"] = 1

Avoiding accidental overwrite#

In general, logging data of a different type to an existing field will automatically fail. In this case, Neptune assumes overwriting is not the intention and throws an exception.

Otherwise, if you frequently update existing runs, you should have some safeguard in place whenever you access fields that already have metadata assigned to them.

Using read only mode#

If you're just fetching metadata and not logging anything new, you can use read-only mode. This ensures that any initialized runs or other Neptune objects won't be modified.

Initialize existing run in read-only mode
import neptune

run = neptune.init_run(with_id="CLS-12", mode="read-only")

# Fetch some logged metadata
dataset_hash = run["data_version"].fetch_hash()
...

You can also set the connection mode with the NEPTUNE_MODE environment variable.

export NEPTUNE_MODE='read-only'
export NEPTUNE_MODE='read-only'
setx NEPTUNE_MODE 'read-only'
%env NEPTUNE_MODE='read-only'

Editing name, description, or tags#

You can edit basic information about runs and model objects directly in the Neptune app.

  1. Next to the run ID, click the run menu () and select Show run information.

    Accessing run information

  2. Edit the information as needed.

  3. When you're done, click the check mark ().

To learn more, see Edit name or description.


Related