Skip to main content
App version: 3.4.3

Migrate from Neptune Python client 1.x

Learn about the code changes that you must implement in your exisiting scripts before migrating from version 1.x of the Neptune client library to neptune-scale.

Installation

neptune 1.x
pip install neptune
neptune-scale
pip install neptune-scale

Import

neptune 1.x
import neptune
neptune-scale
import neptune-scale

Run operations

For details on all parameters and methods, see Run.

Initialize a run

neptune 1.x
run = neptune.init_run()
neptune-scale
run = neptune_scale.Run(
run_id=str(random()), # your custom run ID
...
)

sync()

neptune 1.x
run.sync()
neptune-scale
run.wait_for_processing()

wait()

neptune 1.x
run.wait()
neptune-scale
run.wait_for_submission()

Stop a run

neptune 1.x
run.stop()
neptune-scale
run.close()

Logging metadata

For details on supported metadata types, see Attribute types reference.

Add tags

neptune 1.x
run["sys/tags"].add(["tag1", "tag2", ...])
neptune-scale
run.add_tags(["tag1", "tag2", ...])

Add group tags

neptune 1.x
run["sys/group_tags"].add(["tag1", "tag2", ...])
neptune-scale
run.add_tags(["tag1", "tag2", ...], group_tags=True)

Log a dictionary of values

neptune 1.x
run["config"] = stringify_unsupported(config_dict)
neptune-scale
from datetime import datetime
SUPPORTED_DATATYPES = [int, float, str, datetime, bool, list, set]

for key in config_dict:
if type(parameters[key]) not in SUPPORTED_DATATYPES:
run.log_configs({f"config/{key}": str(parameters[key])})
else:
run.log_configs({f"config/{key}": parameters[key]})
note

stringify_unsupported() isn't available in neptune-scale. Before logging, you must flatten all nested dictionaries and convert the data types to the supported ones.

See an example function
def stringify_unsupported(d, parent_key="", sep="/"):

SUPPORTED_DATATYPES = [int, float, str, datetime, bool, list, set]

items = {}
if not isinstance(d, (dict, list, tuple, set)):
return d if type(d) in SUPPORTED_DATATYPES else str(d)
if isinstance(d, dict):
for k, v in d.items():
new_key = f"{parent_key}{sep}{k}" if parent_key else k
if isinstance(v, (dict, list, tuple, set)):
items |= stringify_unsupported(v, new_key, sep=sep)
else:
items[new_key] = v if type(v) in SUPPORTED_DATATYPES else str(v)
elif isinstance(d, (list, tuple, set)):
for i, v in enumerate(d):
new_key = f"{parent_key}{sep}{i}" if parent_key else str(i)
if isinstance(v, (dict, list, tuple, set)):
items.update(stringify_unsupported(v, new_key, sep=sep))
else:
items[new_key] = v if type(v) in SUPPORTED_DATATYPES else str(v)
return items

Log metrics

neptune 1.x
run["metrics"].append({"acc":acc, "loss":loss, ...})
neptune-scale
run.log_metrics(data={"metrics/acc":acc,"metrics/loss":loss,...}, step=step)
note

log_metrics() requires the step parameter. An option to automatically increase the step value isn't supported yet.