情感识别机器人-提交任务

测试机器人方法

提交数字化资产盘活任务有两种方法:仅使用一种方法即可

  1. 使用 curl 在命令行的方式下提交 job。
  2. 在 API Gateway console 下提交 job。
    • 适合于没有开通 ICP Excepiton 的场景下使用。

使用 curl 在命令行的方式下提交 job

为了方便使用 curl 的方式提交,可以使用在 使用机器人 部分所生成的堡垒机提交任务。

  1. 记录下堡垒机的 EIP。(具体信息可以查看 Cloudformation 堆栈 spotbot-bastion中【资源】标签页中的 EIP 部分) 点击 【资源】 标签页,记录 EIP。例如下图中的 EIP 字段 52.82.89.118

  2. ssh 方式登录到堡垒机,假设使用的 keypair 是 ningxia.pem。由于在Cloudformation 堆栈 spotbot-bastion 使用的是 Amazon Linux2 AMI, 所以 EC2 用户名是 ec2-user 注意: 请修改 52.82.89.118 为您实际生成堡垒机的 EIP

ssh -i ningxia.pem ec2-user@52.82.89.118

SSH 登录成功。

  1. 在堡垒机运行如下命令,或者自己 account下的 accountid, apigateway 以及 bucketname
accoutid=$(aws sts get-caller-identity --region cn-northwest-1 --query 'Account' --output text)
apigatewayid=$(aws apigateway get-rest-apis --query "items[?name=='spot-bot'].id" --region cn-northwest-1 --output text)
apigatewayendpoint="https://$apigatewayid.execute-api.cn-northwest-1.amazonaws.com.cn/Prod/create/proxy"
s3bucketname="spot-bot-exampledata-cn-northwest-1-$accoutid"
echo $accoutid
echo $apigatewayid
echo $apigatewayendpoint
echo $s3bucketname

在堡垒机运行如下的命令,提交job

sentiment_bot_json="{\"s3_bucket\":\"$s3bucketname\", \"s3_path\":\"sentiment_bot/input\",\"bot_name\":\"SENTIMENT_ANALYSIS\", \"number_of_bots\":\"1\",\"bulk_size\":\"500\", \"output_s3_bucket\":\"$s3bucketname\",\"output_s3_prefix\":\"sentiment_bot/output\"}"
curl  -d "$sentiment_bot_json"  -X  POST $apigatewayendpoint

提交成功后,系统返回jobid

[ec2-user@ip-10-0-1-246 ~]$ curl  -d "$sentiment_bot_json"  -X  POST $apigatewayendpoint
{"job_id": "8f622386-f09b-415b-9a77-c7dcc640d153"}

在 API Gateway console 下提交 job

进入 API Gateway console 页面,点击 左侧的 [Resources] , 选择 /create/{any_argument+}/ANY 点击 [Test] 链接

具体信息如下:

  1. Method 选择 Post
  2. 请注意把 s3_bucket 名称 spot-bot-exampledata-cn-northwest-1-123456789012 中的123456789012 替换为自己的 accountid。
    1. 请注意把 output_s3_bucket 名称 spot-bot-exampledata-cn-northwest-1-123456789012 中的123456789012 替换为自己的 accountid。
  3. Reqeust Body 填入如下信息:
{"s3_bucket":"spot-bot-exampledata-cn-northwest-1-123456789012", "s3_path":"sentiment_bot/input","bot_name":"SENTIMENT_ANALYSIS", "number_of_bots":"1","bulk_size":"500", "output_s3_bucket":"spot-bot-exampledata-cn-northwest-1-123456789012","output_s3_prefix":"sentiment_bot/output"}