Managing model stages
How to manage model stage transitions in Neptune
You can manage the stage transitions of each model version separately.
Any project member with editing permissions can change the stage, either through the app or the API.
The available stages in Neptune are:
  • None (default)
  • Staging
  • Production
  • Archived

Changing the model stage in the app

  1. 1.
    Navigate to your models by selecting the Models tab.
  2. 2.
    Click a model in the table to access its versions.
  3. 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. 4.
    To confirm the transition, in the dialog that opens, click Change stage.

Changing the model stage through the API

  1. 1.
    Initialize a Neptune model version:
1
import neptune.new as neptune
2
3
model_version = neptune.init_model_version(
4
version="MODEL_VERSION_ID",
5
)
Copied!
where MODEl_VERSION_ID is the Neptune id of the model version, stored in the sys/id field. For example, PROJ-MOD-19.
2. Change the stage of the model version with the change_stage() method:
1
model_version.change_stage("staging")
Copied!
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:
1
model_version.stop()
Copied!

Conditionally changing the model stage

Tip: 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.90 before making the change:
1
model_version = neptune.init_model_version(
2
version="PROJ-MOD-19",
3
)
4
5
val_acc = model_version["validation/metrics/acc"].fetch()
6
7
if val_acc >= 0.90:
8
model_version.change_stage("staging")
9
Copied!