Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

CreateModelPackage API - InferenceSpecification "Environment" property not accepted #148

Closed
ZenPylon opened this issue Aug 9, 2021 · 1 comment
Assignees
Labels

Comments

@ZenPylon
Copy link

ZenPylon commented Aug 9, 2021

I'm currently trying to use the SageMaker API's create_model_package() method in a manner similar to the example shown here. However, I receive the following error when including Environment parameter.

ParamValidationError: Parameter validation failed: Unknown parameter in InferenceSpecification.Containers[0]: "Environment", must be one of: ContainerHostname, Image, ImageDigest, ModelDataUrl, ProductId

Code sample:

import boto3

sm_client = boto3.client('sagemaker')

model_package_group_name = 'my-group-name'
submit_dir = 's3://our_bucket/path'
entry_point_script = 'our_inference_code.py'
model_url='s3://our_bucket/model/path'

modelpackage_inference_specification =  {
    "InferenceSpecification": {
      "Containers": [
         {
            "Image": "'246618743249.dkr.ecr.us-west-2.amazonaws.com/sagemaker-scikit-learn:0.23-1-cpu-py3'",
            "Environment": {
                "SAGEMAKER_SUBMIT_DIRECTORY": submit_dir,
                "SAGEMAKER_PROGRAM": entry_point_script
            }
         }
      ],
      "SupportedContentTypes": [ "text/csv" ],
      "SupportedResponseMIMETypes": [ "text/csv" ],
   }
 }


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)

create_mode_package_response = sm_client.create_model_package(**create_model_package_input_dict)
model_package_arn = create_mode_package_response["ModelPackageArn"]
print('ModelPackage Version ARN : {}'.format(model_package_arn))

I would expect this to be valid code, as the docs indicate that the Environment property is listed as a property in the API spec here. I'd appreciate any suggestions. Thanks!

@ngluna ngluna assigned panjws and unassigned ngluna Sep 30, 2021
@saumitravikram
Copy link

Please ensure you are using the latest version of aws python sdk installed for new fields Environment to be available.

@panjws panjws closed this as completed Jan 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants