0

我在尝试从 S3 自动创建 AWS 数据源时遇到错误:我正在运行一个 shell 脚本:

#!/bin/bash 
for k in 1 2 3 4 5 
do
        aws machinelearning create-data-source-from-s3 --cli-input-json file://data/cfg/dsrc_training_00$k.json
        aws machinelearning create-data-source-from-s3 --cli-input-json file://data/cfg/dsrc_validate_00$k.json 
done

这是它引用的 json 文件的示例:

{
   "DataSourceId": "Iris_training_00{k}",
   "DataSourceName": "[DS Iris] training 00{k}",
   "DataSpec": {
      "DataLocationS3": "s3://ml-test-predicto-bucket/shuffled_{k}.csv",
      "DataSchemaLocationS3": "s3://ml-test-predicto-bucket/dsrc_iris.csv.schema",
      "DataRearrangement": {"splitting":{"percentBegin" : 0, "percentEnd" : 70}}
   },
   "ComputeStatistics": true
}

但是当我从命令行运行我的脚本时,我得到了错误:

Parameter validation failed:
Invalid type for parameter DataSpec.DataRearrangement, value: {u'splitting': {u'percentEnd': u'100', u'percentBegin': u'70'}}, type: <type 'dict'>, valid types: <type 'basestring'>

有人可以帮忙吗,我查看了 API AWS ML 文档,我认为我做的一切都是正确的,但我似乎无法解决这个错误......非常感谢!

4

1 回答 1

1

DataRearrangement元素需要一个JSON字符串对象。您正在传递一个字典对象。

改变:

"DataRearrangement": {"splitting":{"percentBegin" : 0, "percentEnd" : 70}}

[至]

"DataRearrangement": "{\"splitting\":{\"percentBegin\":0,\"percentEnd\":70}}"

于 2017-10-27T15:59:58.630 回答