Invoke ModelLifeCycle using the Amazon CLI examples - Amazon SageMaker AI
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Invoke ModelLifeCycle using the Amazon CLI examples

You can use the Amazon CLI tool to manage your Amazon resources. A few Amazon CLI commands include search and list-actions. The following page will provide examples on how to use ModelPackage while using these commands. For information and examples on setting up your stage construct, see Set up Staging Construct Examples.

The examples on this page uses the following variables.

  • region is the region that your model package exists in.

  • stage-name is the name of your defined stage.

  • stage-status is the name of your defined stage status.

The following are example Amazon CLI commands using ModelLifeCycle.

Search for your model packages with a stage-name you have already defined.

aws sagemaker search --region 'region' --resource ModelPackage --search-expression '{"Filters": [{"Name": "ModelLifeCycle.Stage","Value": "stage-name"}]}'

List the actions associated with ModelLifeCycle.

aws sagemaker list-actions --region 'region' --action-type ModelLifeCycle

Create a model package with ModelLifeCycle.

aws sagemaker create-model-package --model-package-group-name 'model-package-group-name' --source-uri 'source-uri' --region 'region' --model-life-cycle '{"Stage":"stage-name", "StageStatus":"stage-status", "StageDescription":"Your Staging Comment"}'

Update a model package with ModelLifeCycle.

aws sagemaker update-model-package --model-package 'model-package-arn' --region 'region' --model-life-cycle '{"Stage":"stage-name", "StageStatus":"stage-status"}'

Search via the ModelLifeCycle field.

aws sagemaker search --region 'region' --resource ModelPackage --search-expression '{"Filters": [{"Name": "ModelLifeCycle.Stage","Value": "stage-name"}]}'

Fetch audit records for ModelLifeField updates via Amazon SageMaker ML Lineage Tracking APIs.

aws sagemaker list-actions --region 'region' --action-type ModelLifeCycle
aws sagemaker describe-action --region 'region' --action-name 'action-arn or action-name'