SageMaker NodeJS的SDK未锁定API版本 [英] SageMaker NodeJS's SDK is not locking the API Version
问题描述
我正在AWS Lambda中运行一些代码来动态创建SageMaker模型. 我像这样锁定Sagemaker的API版本:
I am running some code in AWS Lambda that dynamically creates SageMaker models. I am locking Sagemaker's API version like so:
const sagemaker = new AWS.SageMaker({apiVersion: '2017-07-24'});
这是创建模型的代码:
await sagemaker.createModel({
ExecutionRoleArn: 'xxxxxx',
ModelName: sageMakerConfigId,
Containers: [{
Image: ecrUrl
}]
}).promise()
此代码在2.418.0
上的aws-sdk
本地运行良好.
This code runs just fine locally with aws-sdk
on 2.418.0
.
但是,当将此代码部署到Lambda时,由于创建模型时出现一些验证错误,因此无法使用:
However, when this code is deployed to Lambda, it doesn't work due to some validation errors upon creating the model:
- MissingRequiredParameter:在参数中缺少必需的键"PrimaryContainer"
- UnexpectedParameter:在参数中发现意外的键容器"
- MissingRequiredParameter: Missing required key 'PrimaryContainer' in params
- UnexpectedParameter: Unexpected key 'Containers' found in params
有人使用AWS在Lambda上下文中提供的SDK知道aws-sdk
中NodeJS的现有错误吗?我相信AWS Lambda内提供的SDK比2.418.0
更新,但显然存在兼容性问题.
Is anyone aware of existing bugs in the aws-sdk
for NodeJS using the SDK provided by AWS in the Lambda context? I believe the SDK available inside AWS Lambda is more up-to-date than 2.418.0
but apparently there are compatibility issues.
推荐答案
您已经注意到aws-sdk的嵌入式" lambda版本落后了.它实际上在2.290.0
上(您可以在此处查看有关环境的完整详细信息: https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html )
As you've noticed the 'embedded' lambda version of the aws-sdk lags behind. It's actually on 2.290.0
(you can see the full details on the environment here: https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html)
您可以在这里看到: https://github.com/aws/aws-sdk-js/blame/master/clients/sagemaker.d.ts 直到2.366.0
,该方法的参数才包含Containers
,并且没有需要PrimaryContainer
.
You can see here: https://github.com/aws/aws-sdk-js/blame/master/clients/sagemaker.d.ts that it is not until 2.366.0
that the params for this method included Containers
and did not require PrimaryContainer
.
正如您所指出的,解决方法是使用您正在使用的aws-sdk
版本部署lambda.有时这被称为最佳实践,因为它会将aws-sdk
固定在您构建和测试的功能上.
As you've noted, the workaround is to deploy your lambda with the aws-sdk
version that you're using. This is sometimes noted as a best practice, as it pins the aws-sdk
on the functionality you've built and tested against.
这篇关于SageMaker NodeJS的SDK未锁定API版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!