wawawa
wawawa

Reputation: 3355

How should I version control sagemaker model?

So I have a pre-trained ML model stored in an S3 bucket (nameexample.tar.gz), I have a pipeline, and it will run terraform to create a model by using this file on SageMaker and get prediction, my question is what's the best practice of version control the created-model on SageMaker?

My thought is I manually set this model artifact a name like example-v1.tar.gz, meaning this is the first artifact we will deploy, then because my pipeline can version control the terraform code (build a terraform-v1.0.0.zip file) then execute this file to create the model on SageMaker, my question is basically should I just use model-v1 as model name on SageMaker or should I update this model name frequently, like everytime there's a new-versioned terraform zip file, we use the same version number for the model name on SageMaker (model-v1.0.0)?

I'm new to ML model deployment, a bit confused about this, hope this makes sense, can someone help me?Thanks.

Upvotes: 3

Views: 1679

Answers (1)

Frozhen
Frozhen

Reputation: 391

You can use Sagemaker Model Registry to register your model and version control: aws doc

Usage example:

# Specify the model source
model_url = "s3://your-bucket-name/model.tar.gz"

modelpackage_inference_specification =  {
    "InferenceSpecification": {
      "Containers": [
         {
            "Image": '257758044811.dkr.ecr.us-east-2.amazonaws.com/sagemaker-xgboost:1.2-1',
        "ModelDataUrl": model_url
         }
      ],
      "SupportedContentTypes": [ "text/csv" ],
      "SupportedResponseMIMETypes": [ "text/csv" ],
   }
 }

# Alternatively, you can specify the model source like this:
# modelpackage_inference_specification["InferenceSpecification"]["Containers"][0]["ModelDataUrl"]=model_url

create_model_package_input_dict = {
    "ModelPackageGroupName" : model_package_group_name,
    "ModelPackageDescription" : "Model to detect 3 different types of irises (Setosa, Versicolour, and Virginica)",
    "ModelApprovalStatus" : "PendingManualApproval"
}
create_model_package_input_dict.update(modelpackage_inference_specification)

Upvotes: 0

Related Questions