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.
>>> 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.
>>> run = neptune.init_run(with_id="<ID_of_previous_run>")
>>> run["learning_rate"] = 0.02
How do I find the ID?
If the run is active, you can also fetch its ID via API:
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.
>>> 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.
>>> run["my_field"] = "lorem"
>>> run["my_field"] = 1
TypeError: value must be a str or NoneType or StringifyValue (was <class 'int'>)
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.
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.
Editing name, description, or tags#
You can edit basic information about runs and model objects directly in the Neptune app.
-
Next to the run ID, click the run menu ( ) and select Run information.
-
Edit the information as needed.
- When you're done, click the check mark ().
To learn more, see Edit name or description.
Prevent creation of new monitoring namespace#
If you don't need to log system metrics or hardware monitoring but need write access to the run, you can resume it with auto-logging options disabled.
This way, you can log new metadata, overwrite existing data, or delete data without creating a new monitoring namespace.
import neptune
run = neptune.init_run(
with_id="CLS-12",
capture_hardware_metrics=False,
capture_stderr=False,
capture_stdout=False,
capture_traceback=False,
git_ref=False,
source_code=[],
)
Related
- Trash and delete data
- Query the Neptune API
- Add field to existing runs
- Learn more about read-only and other modes: Connection modes
- Resume a run
- You can edit some system namespace fields manually. For details, see: System namespace overview