1 回答
- 最新
- 投票最多
- 评论最多
1
You are right that the way to reference the stage is to propagate the tags all the way down to Model
, EndpointConfig
and Endpoint
. When you do that through the MLOps template, CodeBuild and CloudFormation take care of the tagging.
You might need to create_model
from the model package as well, here's a working example:
import boto3 client = boto3.client('sagemaker') role = '<my_role_arn>' model_package_arn = '<my_model_package_arn>' my_tags = [ {'Key': 'sagemaker:deployment-stage', 'Value': 'my_stage'}, {'Key': 'sagemaker:project-id', 'Value': 'my_project_id'}, {'Key': 'sagemaker:project-name', 'Value': 'my_project_name'}, ] client.create_model( ModelName='testing-stage-model', PrimaryContainer={ 'ModelPackageName': model_package_arn, }, ExecutionRoleArn=role, Tags=my_tags ) client.create_endpoint_config( EndpointConfigName='testing-stage-endpoint-config', ProductionVariants=[ { 'VariantName': 'AllTraffic', 'ModelName': 'testing-stage-model', 'InitialInstanceCount': 1, 'InstanceType': 'ml.t2.medium', }, ], Tags=my_tags ) client.create_endpoint( EndpointName='testing-stage-endpoint', EndpointConfigName='testing-stage-endpoint-config', Tags=my_tags )
已回答 2 年前