amazon-web-services - 为什么我不能在 AWS Batch C++ SDK 中覆盖多节点并行作业的容器变量?
问题描述
我正在使用 AWS Batch。我的目标是通过适用于 C++ 的 AWS 开发工具包创建多节点并行作业。为此,我按照此处的说明创建了一个工作定义。
我正在使用 AWS C++ SDK,我注意到当我尝试覆盖环境变量或命令时,实际上没有任何内容传输到作业中。
有趣的是,对于使用普通作业定义(与多节点作业相反)的作业,相同的代码工作得非常好:
#include <aws/batch/BatchClient.h>
#include <aws/batch/model/ContainerOverrides.h>
#include <aws/batch/model/KeyValuePair.h>
#include <aws/batch/model/SubmitJobRequest.h>
#include <aws/core/Aws.h>
#include <aws/core/utils/Outcome.h>
int main(void)
{
Aws::SDKOptions options;
Aws::InitAPI(options);
Aws::Batch::BatchClient batchClient;
Aws::Batch::Model::SubmitJobRequest submitJobRequest;
Aws::Batch::Model::SubmitJobOutcome submitJobOutcome;
Aws::Batch::Model::ContainerOverrides containerOverrides;
Aws::Batch::Model::KeyValuePair envVariable;
envVariable.SetName("foo");
envVariable.SetValue("bar");
containerOverrides.AddEnvironment(envVariable); // This does nothing for a multi-node job definition.
containerOverrides.AddCommand("foobarbaz"); // This does nothing for a multi-node job definition.
submitJobRequest.SetJobName("myjob");
submitJobRequest.SetJobDefinition("arn:aws:...."); // This string is an example. I have used the actual job definition ARN.
submitJobRequest.SetJobQueue("arn:aws:...."); // This string is an exmaple. I have used the actual queue ARN.
submitJobRequest.SetContainerOverrides(containerOverrides);
submitJobOutcome = batchClient.SubmitJob(submitJobRequest);
Aws::ShutdownAPI(options);
return 0;
}
我应该为多节点并行作业使用不同的 API 吗?
解决方案
不要在请求中设置顶级容器覆盖,而是尝试在请求的节点覆盖内设置容器覆盖。节点覆盖具有节点属性覆盖向量,其中包含您的容器覆盖,包括环境变量。在节点属性覆盖中,您需要指定目标节点的名称。
我不太擅长 C++,所以我无法为您提供准确的代码示例,但 SDK 调用的 API 的 JSON 看起来像这样:
POST /v1/submitjob HTTP/1.1
Content-type: application/json
{
"jobDefinition": "string",
"jobName": "string",
"jobQueue": "string",
"nodeOverrides": {
"nodePropertyOverrides": [
{
"containerOverrides": {
"command": [ "string" ],
"environment": [
{
"name": "string",
"value": "string"
}
],
"instanceType": "string",
"memory": number,
"resourceRequirements": [
{
"type": "string",
"value": "string"
}
],
"vcpus": number
},
"targetNodes": "string"
}
],
"numNodes": number
},
# lots of other stuff
}
希望有帮助。
推荐阅读
- d3.js - svg 如何在 svg 符号上添加边框?
- ms-access - 在导航表单中的子表单之间切换
- vega-lite - 如何在具有相同比例的 2 个系列的 vega-lite 中添加辅助 Y 轴?
- android - apk (.apk) 和应用程序包 (.aab) 之间的区别
- webgl - 如何为 WebGL 中的输出纹理或帧缓冲区提供偏移量?
- php - laravel 如何创建通知表?
- javascript - 如何从内部分配 PROMISE 之外的值
- typescript - 可以在 Typescript 库中的 package.json 中将 @types 库作为正常依赖项吗?
- disassembly - xc16获取反汇编(listing.disasm)文件的命令是什么?
- geneticsharp - 如何自定义染色体基因的值?