Skip to content

Managing the model version stage#

You can manage the stage transitions of each model version separately.

The available stages are:

  • None (default)
  • Staging
  • Production
  • Archived

Any project member with editing permissions can change the stage, either through the app or the API.

Changing the stage in the app#

  1. Navigate to your models by selecting the Models tab.
  2. Click a model in the table to access its versions.
  3. In the Stage column next to the model version ID, click the stage drop-down and select a different stage from the list.
  4. To confirm the transition, in the dialog that opens, click Change stage.

Changing the stage through the API#

  1. Initialize a Neptune model version by passing the ID of an existing version:

    import neptune.new as neptune
    
    model_version = neptune.init_model_version(
        with_id="CLS-PRE-4",
    )
    
    How do I find the ID?

    The Neptune ID is a unique identifier for the object. It's shown in the leftmost column of the table view.

    The ID is stored in the system namespace, in the "sys/id" field.

  2. Pass the desired stage to the change_stage() method of the model version object:

    model_version.change_stage("staging")
    

    Tip

    This method is synchronous, which means that the stage is changed as soon as the line is executed.

  3. To stop the connection to Neptune and sync all data, call the stop() method and execute the script or cell:

    model_version.stop()
    

Conditionally changing the model stage#

You can make the stage transition conditional by fetching some relevant metadata from the model version and checking the value.

The following code snippet fetches an accuracy value from the metrics logged for the model version, then compares it against a threshold of 0.9 before making the change:

model_version = neptune.init_model_version(
    with_id="CLS-PRE-4",
)

val_acc = model_version["validation/metrics/acc"].fetch()

if val_acc >= 0.9:
    model_version.change_stage("staging")