Setting a base namespace#
You can organize your metadata into folder-like structures with the help of namespaces and handler objects.
If you assign a run namespace path to a variable, you get a namespace handler object. The namespace handler exposes similar methods as other Neptune objects – however, all field paths are relative to the namespace.
Start by creating a Handler
object and turn it into a namespace by organizing metadata inside it:
params_ns = run["params"] # Create a namespace handler
params_ns["max_epochs"] = 20 # Log directly to the namespace instead of to the run
params_ns["batch_size"] = 32
In the pipeline logging example below, we show how to use a handler to organize metadata from a particular step of a run into a given namespace.
Pipeline logging example#
Let's say we have a data preprocessing step in our pipeline, and we would like to ensure that all of the metadata generated during this part is organized under a folder named "preprocessing".
We would start a Neptune run early in the script:
import neptune
from sklearn.datasets import fetch_lfw_people
from utils import *
dataset = fetch_lfw_people(min_faces_per_person=70, resize=0.4)
run = neptune.init_run()
dataset_config = {...}
To collect the metadata from this step into one place, we set up a preprocessing
namespace inside the run. This will be the base namespace where all the preprocessing metadata is logged.
We define the path run["preprocessing"]
and assign it to a handler object, which we'll then use to log metadata as if it were a run.
dataset_transform = Preprocessing(...)
preprocessing_handler["dataset/scaler"].upload(path_to_scaler)
This way, whenever we log something to preprocessing_handler
, it'll end up under the path run["preprocessing/..."]
.
See full example script on GitHub 
Setting base namespace in integrations#
Most integrations automatically organize the metadata logged by the integration framework into a dedicated namespace.
You can usually customize the name of this namespace with the help of a parameter.
import neptune
from neptune.integrations.tensorflow_keras import NeptuneCallback
neptune_run = neptune.init_run()
model.fit(
x_train,
y_train,
...,
callbacks=[NeptuneCallback(
run=neptune_run,
base_namespace="train",
)],
)
Even if there is no automatic namespace implementation, whenever you can pass a Neptune Run
object to a callback, you can instead pass a namespace handler.
neptune_run = neptune.init_run()
train_namespace = run["train"]
model.some_method(
...,
callbacks=[NeptuneLogger(run=train_namespace)],
)
For the exact implementations, check the specific Integrations and their API references.