5

This might be a very specific question, but I will try anyway.

I want to explicitly set the Stage column in Model registry for a given Model Version:

enter image description here

This picture comes from the documentation and it gets set only when you run the example SageMaker Projects MLOps Templates they provide. When I create the Model Package (i.e. Model Version) manually, the column remains empty. How do I set it? What API do I call?

Additionally, the documentation on browsing the model version history has a following sentence

enter image description here

How do we send that exact event ("Deployed to stage XYZ") manually?

I already thoroughly went over all the files SageMaker MLOps Project generates (CodeBuild Builds, CodePipeline, CloudFormation, various .py files, SageMaker Pipeline) but could not find any direct and explicit call for that event.

I think it may be somehow connected to the Tag sagemaker:deployment-stage but I've already set it on Endpoint, EndpointConfiguration and Model, with no success. I also tried to blindly call the UpdateModelPackage API and set Stage in CustomerMetadataProperties. Again - no luck.

The only thing I get in that Activity tab is that given Model Version is deployed to Inference endpoint:

enter image description here

blahblah
  • 1,161
  • 2
  • 14
  • 30
  • Did you ever figure this out? – Ray Hogan Jul 27 '23 at 19:08
  • @RayHogan not really, but perhaps tagging it well does the trick https://repost.aws/questions/QUI07MHIlPSbSwALreeEJ28g/sagemaker-model-registry-how-to-set-the-stage-column-of-a-model-package ? – blahblah Jul 28 '23 at 08:51
  • Yeah, I've deduced it no longer works. The latest SageMaker Studio UI doesn't even display the Stage column anymore, so we are going to use the custom tags instead. – Ray Hogan Jul 28 '23 at 15:11

2 Answers2

1

You can set the status with the ModelApprovalStatus parameter in the create_model_package API or the update_model_package API

Model package state change should create an event in EventBridge (like many other SageMaker events) https://docs.aws.amazon.com/sagemaker/latest/dg/automating-sagemaker-with-eventbridge.html#eventbridge-model-package, which enables you to run the automation of your choice.

In the default SageMaker Pipelines Project template, you can see the EventBridge-driven proposed logic in the CodePipeline pipeline created for deployment: you can see on top "Trigger - CloudWatchEvent". You don't see the event source as code in the git, because the status change is expected to be done in the Studio model registry UI in that demo template.

Those EventBridge events emitted by the Model Registry can also be seen in few blogs:

Olivier Cruchant
  • 3,747
  • 15
  • 18
  • This does not answer my question. I'm well aware how to change the `ModelApprovalStatus` for a given Version and how this automatically triggers the CI/CD pipeline via EventBridge. I've skimmed closely through all the files MLOps Templates create to witness all that magic. What I am looking for is a way to set the STAGE column for a given Version (i.e. `Model Package` in a `Model Package Group`). I want to see explicit (or implicit) mechanism that changes the value in that column (None -> `staging` -> `prod`). Why and when does that happen? What triggers it? – blahblah Dec 02 '21 at 12:16
  • 1
    yes good point I confused Status and Stage ; let me look deeper – Olivier Cruchant Dec 02 '21 at 12:37
1

I was having the exact same issue, I wanted to change the model stage but could not find where it was being done in the sample code AWS provides.

After some research and looking into the sample code I realized that it was being done in the cloud formation execution. First they add the tag

'sagemaker:deployment-stage': stage_config['Parameters']['StageName']

and then the cloud formation execution (cfnUpdate call) updates the stage and deploys.

I couldn't find another way to change the state with a call to update_model_package or other methods.