CreateJob
描述
创建(提交)一个DAG类型的作业。
请求语法样例
POST /jobs
{
"Name": "testJob",
"Description": "BatchCompute demo job",
"JobFailOnInstanceFail": true,
"Priority": 1,
"Type": "DAG",
"AutoRelease": false,
"Notification": {
"Topic": {
"Name": "test-topic",
"Endpoint": "http://[UserId].mns.[Region].aliyuncs.com/",
"Events": [
"OnJobWaiting",
"OnJobRunning",
"OnJobStopped",
"OnJobFinished",
"OnJobFailed",
"OnTaskWaiting",
"OnTaskRunning",
"OnTaskStopped",
"OnTaskFinished",
"OnTaskFailed",
"OnInstanceWaiting",
"OnInstanceRunning",
"OnInstanceStopped",
"OnInstanceFinished",
"OnInstanceFailed",
"OnPriorityChange"
]
}
},
"DAG": {
"Dependencies": {},
"Tasks": {
"taskA": {
"AutoCluster": {
"Configs": {
"Disks": {
"DataDisk": {
"MountPoint": "/home/mydisk/",
"Size": 0,
"Type": "ephemeral"
},
"SystemDisk": {
"Size": 40,
"Type": "ephemeral"
}
},
"Mounts": {
"Entries": [
{
"Destination": "/home/admin/mount-dest",
"Source": "oss://your-bucket/mount-source",
"WriteSupport": false
}
],
"Locale": "GBK",
"Lock": false,
"CacheSupport": true,
"NAS": {
"AccessGroup": [
"group1",
"group2"
],
"FileSystem": [
"filesystem1",
"filesystem2"
]
},
"OSS": {
"AccessKeyId": "",
"AccessKeySecret": "",
"AccessSecurityToken": ""
}
},
"Networks": {
"Classic": {
"AllowIpAddress": [],
"AllowIpAddressEgress": [],
"AllowSecurityGroup": [],
"AllowSecurityGroupEgress": []
},
"VPC": {
"CidrBlock": "192.168.0.0/16"
}
}
},
"ECSImageId": "",
"ImageId": "img-ubuntu",
"InstanceType": "bcs.a2.large",
"ResourceType": "OnDemand",
"SpotStrategy": "SpotAsPriceGo",
"SpotPriceLimit": 0.0,
"UserData": {},
"ReserveOnFail": false
},
"ClusterId": "cls-6kir9pdp3lg6220g418002",
"InputMapping": {
"oss://bucket/tmp/": "/home/mount1/"
},
"InstanceCount": 1,
"LogMapping": {},
"MaxRetryCount": 0,
"OutputMapping": {
"/home/mount1": "oss://bucket/tmp/"
},
"Mounts": {
"Entries": [
{
"Destination": "/home/admin/mount-dest",
"Source": "oss://your-bucket/mount-source",
"WriteSupport": false
}
],
"Locale": "GBK",
"Lock": false,
"NAS": {
"AccessGroup": [
"group1",
"group2"
],
"FileSystem": [
"filesystem1",
"filesystem2"
]
},
"OSS": {
"AccessKeyId": "",
"AccessKeySecret": "",
"AccessSecurityToken": ""
}
},
"Parameters": {
"Command": {
"CommandLine": "python worker.py",
"EnvVars": {},
"PackagePath": "oss://bucket/tests/worker.tar.gz"
},
"InputMappingConfig": {
"Locale": "GBK",
"Lock": false
},
"StderrRedirectPath": "oss://bucket/tests/logs/",
"StdoutRedirectPath": "oss://bucket/tests/logs/"
},
"Timeout": 172800,
}
}
}
}
属性说明
属性名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
Name | string | 是 | 作业名称。 |
Description | string | 否 | 作业的描述信息。 |
Priority | int | 是 | 作业优先级,范围0-1000,数值越高,优先级越高。 |
Type | string | 是 | 目前仅支持有向无环图(directed acycline graph,DAG)形式描述任务。 |
JobFailOnInstanceFail | bool | 是 | 取值为true表示Instance失败会导致Job失败。 |
AutoRelease | bool | 否 | 取值为true表示Job运行成功后系统会自动删除改Job。默认false。 |
Notification | object | 否 | 消息通知配置,用户指定消息事件Notification。 |
DAG | object | 是 | DAG描述。 |
Tasks | object | 是 | 任务描述。 |
Parameters | object | 是 | 任务参数详情。 |
Command | object | 是 | 用户程序相关命令行参数。 |
CommandLine | string | 是 | 执行用户程序的命令。CommandLine不等同于SHELL,仅支持“解释器 + 脚本”方式,比如“python test.py”或“sh test.sh” |
PackagePath | string | 是 | 用户程序所在OSS路径。 |
EnvVars | string | 否 | 设置用户程序执行时的环境变量。 |
InputMappingConfig | object | 否 | NFS挂载服务配置项。 |
Locale | string | 否 | OSS object挂载到本地时使用的字符集。可选范围包括GBK、GB2312-80、BIG5、ANSI、EUC-JP、EUC-TW、EUC-KR、SHIFT-JIS、KSC5601等。 |
Lock | bool | 否 | NFS挂载服务是否支持网络文件锁。 |
StdoutRedirectPath | string | 是 | 标准输出的OSS路径。 |
StderrRedirectPath | string | 是 | 标准错误的OSS路径。 |
InputMapping | object | 否 | OSS对本地路径映射。 |
OutputMapping | object | 否 | 本地路径对OSS映射。 |
LogMapping | object | 否 | 本地日志路径对OSS映射。OSS是目录,以斜杠结尾。OSS日志名称格式:{本地日志名}.{作业ID}.{任务ID}.{实例ID},比如output_log.job-0000000056A6E991000001780000000D.Echo.0 |
Timeout | int | 是 | 实例最长执行时间。 |
InstanceCount | int | 是 | 实例数量。 |
MaxRetryCount | int | 否 | 最大重试次数,默认为0。 |
ClusterId | string | 否 | 集群标识符。该参数与AutoCluster(匿名集群)必须选择一个 |
AutoCluster | object | 否 | 匿名集群。Auto集群描述,AutoCluster和ClusterId必须一个是有效的,而且只能有一个是有效的。 |
Dependencies | object | 否 | 描述任务之间依赖关系的object结构,其中key为源任务名称,value为目标任务名称 列表,可以描述一对多的顺序关系。 |
AutoCluster
属性名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
ImageId | string | 否 | BatchCompute镜像的ID |
ECSImageId | string | 否 | ECS镜像的ID,必须取值为合法的ECS镜像ID。ECSImageId和ImageId必须只能一个取合法的值,另外一个必须为空。 |
InstanceType | string | 是 | 构建集群的实例类型。目前支持的ECS实例类型 |
ResourceType | string | 否 | 资源类型。支持“OnDemand(按需资源)”,“Spot(竞价型资源)”。 |
SpotStrategy | String | 否 | 实例的竞价策略,只有在ResourceType为Spot的情况下有效。 取值范围: SpotWithPriceLimit:设置上限价格的竞价实例; SpotAsPriceGo:系统自动出价,最高按量付费价格。 |
SpotPriceLimit | Float | 否 | 实例的每小时最高价格(每个实例规格的价格而非每核小时的价格)。支持最大 3 位小数,SpotStrategy 为 SpotWithPriceLimit 生效。 |
UserData | object | 否 | 一个KeyValue映射,用户自定义的信息,使用ECS的metaserver获取。 |
Configs | object | 否 | 集群的一些配置信息,比如实例的磁盘配置,由Configs描述。 |
ReserveOnFail | Bool | 否 | 任务失败时不释放相关的虚拟机,会继续收取这些资源的费用直到用户删除作业,默认为False,仅用于调查问题。 |
DependencyIsvService | string | 否 | 执行程序依赖的阿里云提供的ISV服务,目前提供的ISV服务有:“GTX”,默认为””,不依赖任何ISV服务。 |
返回信息
返回成功
返回201状态码以及Job的id,如下。
{
"Id":"job-xxx"
}
属性说明
属性名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
Id | string | 是 | 作业标识符。 |
错误信息
状态码 | 错误码 | 错误信息 | 语义 |
---|---|---|---|
400 | IdempotentTokenMismatch | Specified idempotent token mismatch. | 说明该token已经被使用过,并且该请求参数与之前的请求不一样。 |
400 | InvalidJsonFormat | The request body has an invalid json format. | 请求body是一个非法的json格式。 |
400 | InvalidHttpBody | Specified parameter HttpBody is not valid. Its type must be object. | http body必须是一个object。 |
400 | MissingName | Name is mandatory for this action. | 缺少Name参数。 |
400 | InvalidName | Specified parameter Name is not valid. Its type must be string. | Name必须是一个string。 |
400 | InvalidName | Specified parameter Name is not valid. Its length must be in [1, 64]. | Name的长度必须在1与64之间。 |
400 | InvalidName | Specified parameter Name is not valid. It must only contain characters within [a-zA-Z0-9_-], and must not start with [0-9]. | Name中只能包括字母数字和_-,但不能以数字开头。 |
400 | InvalidDescription | Specified parameter Description is not valid. Its type must be string. | Description必须是一个string。 |
400 | InvalidDescription | Specified parameter Description is not valid. Its length must be in [0, 1024]. | Description的长度必须在0与1024之间。 |
400 | InvalidPriority | Specified parameter Priority is not valid. Its type must be integer. | Priority必须是一个integer。 |
400 | InvalidPriority | Specified parameter Priority is not valid. It must be in [0, 1000]. | Priority的大小必须在0与1000之间。 |
400 | InvalidJobFailOnInstanceFail | Specified parameter JobFailOnInstanceFail is not valid. Its type must be boolean. | JobFailOnInstanceFail必须是一个布尔类型。 |
400 | MissingType | Type is mandatory for this action. | 缺少Type参数。 |
400 | InvalidType | Specified parameter Type is not valid. | Type参数取值不合法。 |
400 | MissingDAG | DAG is mandatory for this action. | 缺少DAG参数。 |
400 | InvalidDAG | Specified parameter DAG is not valid. Its type must be object. | DAG必须是一个object。 |
400 | MissingTasks | Tasks is mandatory for this action. | 缺少Tasks参数。 |
400 | InvalidTasks | Specified parameter Tasks is not valid. Its type must be object. | Tasks必须是一个object。 |
400 | InvalidTasks | Specified parameter Tasks is not valid. Its size must be in [1, 16]. | UserData的大小必须在1与16之间。 |
400 | InvalidTasks.{key} | Specified parameter Tasks.{key} is not valid. Its length must be in [1, 64]. | Tasks.{key}的大小必须在1与64之间。 |
400 | InvalidTasks.{key} | Specified parameter Tasks.{key} is not valid. It must only contain characters within [a-zA-Z0-9_-], and must not start with [0-9].. | Tasks.{key}中只能包括字母数字和_-,但不能以数字开头。 |
403 | QuotaExhausted.MaxJobCount | The MaxJobCount ({value}) quota is exhausted. | Job数量不能超过{value}。 |
403 | QuotaExhausted.MaxJobTaskCount | The MaxJobTaskCount ({value}) quota is exhausted. | 一个Job中的Task的数量不能超过{value}。 |
403 | QuotaExhausted.MaxTaskInstanceCount | The MaxTaskInstanceCount ({value}) quota is exhausted. | 一个Task的InstanceCount不能超过{value}。 |
403 | QuotaExhausted.MaxInstanceTimeout | The MaxInstanceTimeout ({value}) quota is exhausted. | 一个Instance的Timeout不能超过{value}。 |
400 | MissingParameters | Parameters is mandatory for this action. | 缺少Parameters参数。 |
400 | InvalidParameters | Specified parameter Parameters is not valid. Its type must be object. | Parameters必须是一个object。 |
400 | MissingCommand | Command is mandatory for this action. | 缺少Command参数。 |
400 | InvalidCommand | Specified parameter Command is not valid. Its type must be object. | Command必须是一个object。 |
400 | MissingCommandLine | CommandLine is mandatory for this action. | 缺少CommandLine参数。 |
400 | InvalidCommandLine | Specified parameter CommandLine is not valid. Its type must be string. | CommandLine必须是一个string。 |
400 | InvalidCommandLine | Specified parameter CommandLine is not valid. Its length must be in [0, 1024]. | CommandLine的长度必须在0与1024之间。 |
400 | InvalidPackagePath | Specified parameter PackagePath is not valid. Its type must be string. | PackagePath必须是一个string。 |
400 | InvalidPackagePath | Specified parameter PackagePath is not valid. Its length must be in [0, 1024]. | PackagePath的长度必须在0与1024之间。 |
400 | InvalidPackagePath | Specified parameter PackagePath is not valid. OSS path must start with ‘oss://‘, must end with ‘/‘ if it is a folder, and must not end with ‘/‘ if it is a file. | PackagePath必须是一个合法的OSS路径。 |
400 | InvalidEnvVars | Specified parameter EnvVars is not valid. Its type must be object. | EnvVars必须是一个object。 |
400 | InvalidEnvVars | Specified parameter EnvVars is not valid. Its size must be in [0, 64]. | EnvVars的大小必须在0与64之间。 |
400 | InvalidEnvVars.{key} | Specified parameter EnvVars.{key} is not valid. Its length must be in [1, 128]. | EnvVars.{key}的大小必须在1与128之间。 |
400 | InvalidEnvVars.{key}.value | Specified parameter EnvVars.{key}.value is not valid. Its type must be string. | EnvVars.{key}对应的Value必须是一个string。 |
400 | InvalidEnvVars.{key}.value | Specified parameter EnvVars.{key}.value is not valid. Its length must be in [0, 1024]. | EnvVars.{key}对应的value的长度必须在0与1024之间。 |
400 | InvalidInputMappingConfig | Specified parameter InputMappingConfig is not valid. Its type must be object. | InputMappingConfig必须是一个object。 |
400 | InvalidLocale | Specified parameter Locale is not valid. | Locale参数取值不合法。 |
400 | InvalidLock | Specified parameter Lock is not valid. Its type must be boolean. | Lock必须是一个布尔类型。 |
400 | InvalidStdoutRedirectPath | Specified parameter StdoutRedirectPath is not valid. Its type must be string. | StdoutRedirectPath必须是一个string。 |
400 | InvalidStdoutRedirectPath | Specified parameter StdoutRedirectPath is not valid. Its length must be in [0, 1024]. | StdoutRedirectPath的长度必须在0与1024之间。 |
400 | InvalidStdoutRedirectPath | Specified parameter StdoutRedirectPath is not valid. OSS path must start with ‘oss://‘, must end with ‘/‘ if it is a folder, and must not end with ‘/‘ if it is a file. | StdoutRedirectPath必须是一个合法的OSS路径。 |
400 | InvalidStderrRedirectPath | Specified parameter StderrRedirectPath is not valid. Its type must be string. | StderrRedirectPath必须是一个string。 |
400 | InvalidStderrRedirectPath | Specified parameter StderrRedirectPath is not valid. Its length must be in [0, 1024]. | StderrRedirectPath的长度必须在0与1024之间。 |
400 | InvalidStderrRedirectPath | Specified parameter StderrRedirectPath is not valid. OSS path must start with ‘oss://‘, must end with ‘/‘ if it is a folder, and must not end with ‘/‘ if it is a file. | StderrRedirectPath必须是一个合法的OSS路径。 |
400 | InvalidInputMapping | Specified parameter InputMapping is not valid. Its type must be object. | InputMapping必须是一个object。 |
400 | InvalidInputMapping | Specified parameter InputMapping is not valid. Its size must be in [0, 16]. | InputMapping的Key的个数必须在0与16之间。 |
400 | InvalidInputMapping.{key} | Specified parameter InputMapping.{key} is not valid. Its length must be in [1, 1024]. | InputMapping.{key}的大小必须在1与1024之间。 |
400 | InvalidInputMapping.{key} | Specified parameter InputMapping.{key} is not valid. OSS path must start with ‘oss://‘, must end with ‘/‘ if it is a folder, and must not end with ‘/‘ if it is a file. | InputMapping.{key}必须是一个合法的OSS路径。 |
400 | InvalidInputMapping.{key}.value | Specified parameter InputMapping.{key}.value is not valid. Its type must be string. | InputMapping.{key}对应的Value必须是一个string。 |
400 | InvalidInputMapping.{key}.value | Specified parameter InputMapping.{key}.value is not valid. Its length must be in [0, 1024]. | InputMapping.{key}对应的value的长度必须在0与1024之间。 |
400 | InvalidInputMapping.{key}.value | Specified parameter InputMapping.{key}.value is not valid. Local path must be an absolute path on linux, and an drive letter on windows. | InputMapping.{key}对应的value必须是一个合法的本地路径。 |
400 | InvalidOutputMapping | Specified parameter OutputMapping is not valid. Its type must be object. | OutputMapping必须是一个object。 |
400 | InvalidOutputMapping | Specified parameter OutputMapping is not valid. Its size must be in [0, 16]. | OutputMapping的Key的个数必须在0与16之间。 |
400 | InvalidOutputMapping.{key} | Specified parameter OutputMapping.{key} is not valid. Its length must be in [1, 1024]. | OutputMapping.{key}的大小必须在1与1024之间。 |
400 | InvalidOutputMapping.{key} | Specified parameter OutputMapping.{key} is not valid. Local path must be an absolute path. | OutputMapping.{key}必须是一个合法的本地路径。 |
400 | InvalidOutputMapping.{key}.value | Specified parameter OutputMapping.{key}.value is not valid. Its type must be string. | OutputMapping.{key}对应的Value必须是一个string |
400 | InvalidOutputMapping.{key}.value | Specified parameter OutputMapping.{key}.value is not valid. Its length must be in [0, 1024]. | OutputMapping.{key}对应的value的长度必须在0与1024之间。 |
400 | InvalidOutputMapping.{key}.value | Specified parameter OutputMapping.{key}.value is not valid. OSS path must start with ‘oss://‘, must end with ‘/‘ if it is a folder, and must not end with ‘/‘ if it is a file. | OutputMapping.{key}对应的value的大小必须在1与1024之间。 |
400 | InvalidLogMapping | Specified parameter LogMapping is not valid. Its type must be object. | LogMapping必须是一个object。 |
400 | InvalidLogMapping | Specified parameter LogMapping is not valid. Its size must be in [0, 16]. | LogMapping的Key的个数必须在0与16之间。 |
400 | InvalidLogMapping.{key} | Specified parameter LogMapping.{key} is not valid. Its length must be in [1, 1024]. | LogMapping.{key}的大小必须在1与1024之间。 |
400 | InvalidLogMapping.{key} | Specified parameter LogMapping.{key} is not valid. Local path must be an absolute path. | LogMapping.{key}必须是一个合法的本地路径。 |
400 | InvalidLogMapping.{key}.value | Specified parameter LogMapping.{key}.value is not valid. Its type must be string. | LogMapping.{key}对应的Value必须是一个string。 |
400 | InvalidLogMapping.{key}.value | Specified parameter LogMapping.{key}.value is not valid. Its length must be in [0, 1024]. | LogMapping.{key}对应的value的长度必须在0与1024之间。 |
400 | InvalidLogMapping.{key}.value | Specified parameter LogMapping.{key}.value is not valid. OSS path must start with ‘oss://‘, must end with ‘/‘ if it is a folder, and must not end with ‘/‘ if it is a file. | LogMapping.{key}对应的value的大小必须在1与1024之间。 |
400 | InvalidTimeout | Specified parameter Timeout is not valid. Its type must be integer. | Timeout必须是一个integer。 |
400 | MissingInstanceCount | InstanceCount is mandatory for this action. | 缺少InstanceCount参数。 |
400 | InvalidInstanceCount | Specified parameter InstanceCount is not valid. Its type must be integer. | InstanceCount必须是一个integer。 |
400 | InvalidMaxRetryCount | Specified parameter MaxRetryCount is not valid. Its type must be integer. | MaxRetryCount必须是一个integer。 |
400 | MissingClusterId | ClusterId is mandatory for this action. | 缺少ClusterId参数。 |
400 | InvalidClusterId | Specified parameter ClusterId is not valid. Its type must be string. | ClusterId必须是一个string。 |
400 | InvalidClusterId | Specified parameter ClusterId is not valid. Its length must be in [1, 64]. | ClusterId的长度必须在1与64之间。 |
400 | InvalidClusterId | Specified parameter ClusterId is not valid. It must only contain characters within [a-zA-Z0-9_-], and must not start with [0-9]. | ClusterId中只能包括字母数字和_-,但不能以数字开头。 |
400 | InvalidDependencies | Specified parameter Dependencies is not valid. Its type must be object. | Dependencies必须是一个object。 |
400 | InvalidDependencies.{key}.value | Specified parameter Dependencies.{key}.value is not valid. Its type must be array. | Dependencies.{key}对应的Value必须是一个array。 |
400 | Invalid{Parameter} | Specified parameter {Parameter} is not valid. | {Parameter}参数不合法。 |