Skip to content

Log to an existing object#

To connect to an existing object, you can reinitialize it in your code by passing its Neptune ID to the with_id argument. This works for any Neptune object: runs, models, and the project itself.

Resuming an object lets you:

  • add new data or visualizations to a previously closed run
  • modify existing data by overriding a field with a new value
  • delete data from the object
  • access its metadata in read-only mode

There is no limit to the number of times you can resume an object.

To connect to an existing object:

  1. Obtain the Neptune ID of the object to resume.

    • Each object's ID is stored in the sys/id field.
    • You can see it displayed in the leftmost column of the table view.
    • If the object has been initialized in the code, you can obtain it programmatically with

      object_id = neptune_object["sys/id"].fetch()
      
  2. Initialize the object with the ID:

    run = neptune.init_run(
        with_id="CLS-123",
    )
    
    model = neptune.init_model(
        with_id="CLS-PRE",
    )
    
    model_version = neptune.init_model_version(
        with_id="CLS-PRE-11",
    )
    
  3. Log metadata to the object as you normally would.

    You can overwrite existing fields, delete fields, or create new ones.

Fetching metadata in read only mode#

If you're just fetching metadata and not logging new data, you can initialize any existing Neptune object in read only mode.

This mode ensures that the object's metadata won't be modified.

import neptune

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

Related

  • For more about the different modes you can use Neptune in, see Connection modes

Initializing a Neptune project#

You can also treat your Neptune project as an object and log metadata to it via the Neptune API.

Data logged like this will appear under the Project metadata tab of your project.

For more, see Log project-level metadata.


Related