Assign stage to model version
To manage model lifecycle, you can assign stages (such as dev
, staging
,
prod
, etc.) to specific model versions.
To assign a stage to a model version, DVC Studio uses GTO to create an annotated Git tag with the specified stage and version number. Refer to the GTO docs to see the exact format of the Git tag.
You can write CI/CD actions that can actually deploy the models to the different deployment environments upon the creation of a new Git tag for stage assignment. For that, you can leverage any ML model deployment tool, such as MLEM.
You can assign a stage in any of the following ways:
- Use GTO CLI or API. An example would be
gto assign pool-segmentation --version v0.0.1 --stage dev
, assumingdvc.yaml
with the model annotation is located in the root of the repo. If not, you should append its parent directory to the model's name like this:gto assign cv:pool-segmentation --version v0.0.1 --stage dev
(here,cv
is the parent directory). To get a better idea about this case, check out this example monorepo. - To assign stages using DVC Studio, watch this tutorial video or read on below.
-
On the models dashboard, open the 3-dot menu for the model whose version you want to assign the stage to. Then, click on
Assign stage
. This action can also be initiated from the model details page or from the related project’s experiment table - look for theAssign stage
button or icon. -
Select the version to which you want to assign the stage.
-
Enter the stage name (eg,
dev
,shadow
,prod
).You can define the list of stages in the
.gto
config file, which is ayaml
structured file that allows you to specify artifact types and stages. If you have defined the stages in this file, then you can assign to these stages only. But if you have not defined the list of stages, you can enter any string as the stage name. Note the following:- GTO config files with stage names are specific to a Git repository. So, they apply only to models within one repository.
- Currently, you cannot make entries to the GTO config file from DVC Studio.
- If you define stages in the config file at any point, any stage assignments after that point can use only the names defined in the config file.
-
Optionally, provide a Git tag message.
-
Click on
Assign stage
.
Once the action is successful, the stage assignment will show up in the Stages
column of the models dashboard.
If you open the model details page, the stage assignment will be visible in the
model History
section as well as in the Stages
section.
If you go to your Git repository, you will see that a new Git tag referencing the selected version and stage has been created, indicating the stage assignment.