简体   繁体   English

Amazon SageMaker Model Registry / Pipelines - 如何为给定的 Model 版本手动设置 Stage?

[英]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:我想为给定的 Model 版本显式设置 Model 注册表中的 Stage 列:

在此处输入图像描述

This picture comes from the documentation and it gets set only when you run the example SageMaker Projects MLOps Templates they provide.此图片来自文档,只有在您运行他们提供的示例 SageMaker Projects MLOps 模板时才会设置。 When I create the Model Package (ie Model Version ) manually, the column remains empty.当我手动创建Model Package (即Model Version )时,该列仍然为空。 How do I set it?我该如何设置? What API do I call? API 叫什么?

Additionally, the documentation on browsing the model version history has a following sentence 另外浏览model版本历史的文档中有如下一句话

在此处输入图像描述

How do we send that exact event ("Deployed to stage XYZ") manually?我们如何手动发送那个确切的事件(“部署到阶段 XYZ”)?

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.我已经彻底检查了 SageMaker MLOps 项目生成的所有文件(CodeBuild Builds、CodePipeline、CloudFormation、各种.py文件、SageMaker Pipeline),但找不到对该事件的任何直接和显式调用。

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.我认为它可能以某种方式连接到标签sagemaker:deployment-stage但我已经将它设置在EndpointEndpointConfigurationModel上,但没有成功。 I also tried to blindly call the UpdateModelPackage API and set Stage in CustomerMetadataProperties .我还尝试盲目调用UpdateModelPackage API 并在CustomerMetadataProperties中设置Stage Again - no luck.再次 - 没有运气。

The only thing I get in that Activity tab is that given Model Version is deployed to Inference endpoint:我在该活动选项卡中得到的唯一信息是给定的 Model 版本已部署到推理端点:

在此处输入图像描述

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.我遇到了完全相同的问题,我想更改 model 阶段,但在 AWS 提供的示例代码中找不到它在哪里完成。

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.然后云形成执行(cfnUpdate 调用)更新阶段并部署。

I couldn't find another way to change the state with a call to update_model_package or other methods.我找不到另一种方法来通过调用 update_model_package 或其他方法来更改 state。

You can set the status with the ModelApprovalStatus parameter in the create_model_package API or the update_model_package API您可以使用create_model_package API 或update_model_package API 中的ModelApprovalStatus参数设置状态

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. 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 ,这使您能够运行您选择的自动化。

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".在默认的 SageMaker 管道项目模板中,您可以在为部署创建的 CodePipeline 管道中看到 EventBridge 驱动的建议逻辑:您可以在顶部看到“触发器 - 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.您不会在 git 中将事件源视为代码,因为预计状态更改将在该演示模板的 Studio model 注册表 UI 中完成。

Those EventBridge events emitted by the Model Registry can also be seen in few blogs: Model Registry 发出的那些 EventBridge 事件也可以在一些博客中看到:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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