我正在编写一个lambda(在node.js 6.10中)以更新端点SageMaker。为此,我必须创建一个新的HyperParamterTuningJob(然后对其进行描述)。 我成功地从sdk调用了服务SageMaker的所有功能(例如listModels,createTrainingJob,...)(https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SageMaker.html),其中有些功能除外。
与HyperParameterTuningJob相关的所有功能 (createHyperParameterTuningJob,describeHyperParameterTuningJob,listHyperParameterTuningJobs和stopHyperParameterTuningJob) 在Lambda的SDK中是未知的。
我已将策略“ AmazonSageMakerFullAccess”附加到使用的IAM角色(允许使用所有这些功能)。因此,错误不能来自授权问题。
我已经(通过AWS的接口)创建了一个名为“ myTuningJob”的HyperParameterTuningJob。 每次使用函数describeHyperParamterTuningJob时都会出错。 这是我的lambda代码:
const AWS = require('aws-sdk');
const sagemaker = new AWS.SageMaker({region: 'eu-west-1', apiVersion: '2017-07-24'});
var role = 'arn:aws:iam::xxxxxxxxxxxx:role/service-role/AmazonSageMaker-ExecutionRole-xxxxxxxxxxxxxxx';
exports.handler = (event, context, callback) => {
var params = {
HyperParameterTuningJobName: 'myTuningJob'
};
sagemaker.describeHyperParameterTuningJob(params, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
});
};
当我尝试在AWS lambda中测试此代码时,它将在控制台中返回此结果:
Function Logs:
START RequestId: 6e79aaa4-9a18-11e8-8dcd-d58423b413c1 Version: $LATEST
2018-08-07T08:03:56.336Z 6e79aaa4-9a18-11e8-8dcd-d58423b413c1 TypeError: sagemaker.describeHyperParameterTuningJob is not a function
at exports.handler (/var/task/index.js:10:15)
END RequestId: 6e79aaa4-9a18-11e8-8dcd-d58423b413c1
REPORT RequestId: 6e79aaa4-9a18-11e8-8dcd-d58423b413c1 Duration: 50.00 ms
Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 32 MB
RequestId: 6e79aaa4-9a18-11e8-8dcd-d58423b413c1 Process exited before completing request
当我从sdk调用SageMaker服务的所有其他功能时,它会正常运行,并显示任何错误。
在文档中找不到关于为何与HyperParameterTuningJob相关的这些功能在sdk中未被识别为任何功能的解释。
有人知道为什么它不起作用吗?或任何调用这些函数的解决方案?
答案 0 :(得分:0)
在AWS Lambda中,仅具有稳定版本的sdk可用。 SageMaker服务的sdk尚不稳定,因此与HyperParameterTuningJob相关的功能不在AWS Lambda包含的sdk版本中。
要使用这些功能,您需要在计算机上的本地计算机上安装最新版本的sdk(使用npm install aws-sdk)。 然后压缩node_modules文件夹和您的脚本(称为index.js),然后将此zip文件夹上传到AWS lambda。