简体   繁体   中英

Amazon SageMaker Model Registry / Pipelines - how to manually set a Stage for a given Model Version?

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:

在此处输入图像描述

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 (ie 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

在此处输入图像描述

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:

在此处输入图像描述

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.

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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM