All Products
Search
Document Center

CreateJob

Last Updated: May 14, 2018

Description

Creates and submits a DAG job.

Request syntax

  1. POST /jobs
  2. {
  3. "Name": "testJob",
  4. "Description": "BatchCompute demo job",
  5. "JobFailOnInstanceFail": true,
  6. "Priority": 1,
  7. "Type": "DAG",
  8. "AutoRelease": false,
  9. "Notification": {
  10. "Topic": {
  11. "Name": "test-topic",
  12. "Endpoint": "http://[UserId].mns.[Region].aliyuncs.com/",
  13. "Events": [
  14. "OnJobWaiting",
  15. "OnJobRunning",
  16. "OnJobStopped",
  17. "OnJobFinished",
  18. "OnJobFailed",
  19. "OnTaskWaiting",
  20. "OnTaskRunning",
  21. "OnTaskStopped",
  22. "OnTaskFinished",
  23. "OnTaskFailed",
  24. "OnInstanceWaiting",
  25. "OnInstanceRunning",
  26. "OnInstanceStopped",
  27. "OnInstanceFinished",
  28. "OnInstanceFailed",
  29. "OnPriorityChange"
  30. ]
  31. }
  32. },
  33. "DAG": {
  34. "Dependencies": {},
  35. "Tasks": {
  36. "taskA": {
  37. "AutoCluster": {
  38. "Configs": {
  39. "Disks": {
  40. "DataDisk": {
  41. "MountPoint": "/home/mydisk/",
  42. "Size": 0,
  43. "Type": "ephemeral"
  44. },
  45. "SystemDisk": {
  46. "Size": 40,
  47. "Type": "ephemeral"
  48. }
  49. },
  50. "Mounts": {
  51. "Entries": [
  52. {
  53. "Destination": "/home/admin/mount-dest",
  54. "Source": "oss://your-bucket/mount-source",
  55. "WriteSupport": true
  56. }
  57. ],
  58. "Locale": "GBK",
  59. "Lock": false,
  60. "CacheSupport": true,
  61. "NAS": {
  62. "AccessGroup": [
  63. "group1",
  64. "group2"
  65. ],
  66. "FileSystem": [
  67. "filesystem1",
  68. "filesystem2"
  69. ]
  70. },
  71. "OSS": {
  72. "AccessKeyId": "",
  73. "AccessKeySecret": "",
  74. "AccessSecurityToken": ""
  75. }
  76. },
  77. "Networks": {
  78. "Classic": {
  79. "AllowIpAddress": [],
  80. "AllowIpAddressEgress": [],
  81. "AllowSecurityGroup": [],
  82. "AllowSecurityGroupEgress": []
  83. },
  84. "VPC": {
  85. "CidrBlock": "10.0.0.0/8"
  86. }
  87. }
  88. },
  89. "ECSImageId": "",
  90. "ImageId": "img-ubuntu",
  91. "InstanceType": "bcs.a2.large",
  92. "ResourceType": "OnDemand",
  93. "SpotStrategy": "SpotAsPriceGo",
  94. "SpotPriceLimit": 0.0,
  95. "UserData": {},
  96. "ReserveOnFail": true
  97. },
  98. "ClusterId": "cls-6kir9pdp3lg6220g418002",
  99. "InputMapping": {
  100. "oss://bucket/tmp/": "/home/mount1/"
  101. },
  102. "InstanceCount": 1,
  103. "LogMapping": {},
  104. "MaxRetryCount": 0,
  105. "OutputMapping": {
  106. "/home/mount1": "oss://bucket/tmp/"
  107. },
  108. "Mounts": {
  109. "Entries": [
  110. {
  111. "Destination": "/home/admin/mount-dest",
  112. "Source": "oss://your-bucket/mount-source",
  113. "WriteSupport": true
  114. }
  115. ],
  116. "Locale": "GBK",
  117. "Lock": false,
  118. "NAS": {
  119. "AccessGroup": [
  120. "group1",
  121. "group2"
  122. ],
  123. "FileSystem": [
  124. "filesystem1",
  125. "filesystem2"
  126. ]
  127. },
  128. "OSS": {
  129. "AccessKeyId": "",
  130. "AccessKeySecret": "",
  131. "AccessSecurityToken": ""
  132. }
  133. },
  134. "Parameters": {
  135. "Command": {
  136. "CommandLine": "python worker.py",
  137. "EnvVars": {},
  138. "PackagePath": "oss://bucket/tests/worker.tar.gz"
  139. },
  140. "InputMappingConfig": {
  141. "Locale": "GBK",
  142. "Lock": false
  143. },
  144. "StderrRedirectPath": "oss://bucket/tests/logs/",
  145. "StdoutRedirectPath": "oss://bucket/tests/logs/"
  146. },
  147. "Timeout": 172800,
  148. "WriteSupport": true
  149. }
  150. }
  151. }
  152. }

Attribute description

Attribute Type Required or Not Description
Name string Yes Name of a job.
Description string No Description of a job.
Priority int Yes Priority of a job. The value ranges from 0 to 1000. Priority increases with the value.
Type string Yes Currently, a task can be described only in the form of a directed acyclic graph (DAG).
JobFailOnInstanceFail bool Yes The value True indicates that a job fails when an instance fails.
AutoRelease bool No The value True indicates that the system automatically deletes a job after the job runs successfully. Default value: False
Notification object No Notification message configuration. You can specify a message event Notification.
DAG object Yes Description of a DAG.
Tasks object Yes Description of a task.
Parameters object Yes Details about a task parameter.
Command object Yes Command line parameter related to a user program.
CommandLine String Yes Specifies a command for executing a user program. CommandLine is different from Shell. It supports only the form of “interpreter + script”, for example, “python test.py” or “sh test.sh.”
PackagePath string Yes OSS path in which a user program resides.
EnvVars string No Environment variable for the execution of a user program.
InputMappingConfig object No Configuration of an NFS mounting service.
Locale string No Character set used when an OSS object is mounted to the local server.Optional values include GBK, GB2312-80, BIG5, ANSI, EUC-JP, EUC-TW, EUC-KR, SHIFT-JIS, and KSC5601.
Lock bool No Specifies whether the NFS mounting service supports network file locking.
StdoutRedirectPath string Yes OSS directory to which standard output is redirected.
StderrRedirectPath string Yes OSS directory to which a standard error is redirected.
InputMapping object No Mapping from the OSS directory to the local directory.
OutputMapping object No Mapping from the local directory to the OSS directory.
LogMapping object No Mapping from the local log path to the OSS. The directory is “OSS” ending with a slash. An OSS log is named in the format of {Local log name}.{Job ID}.{Task ID}.{Instance ID}, for example, output_log.job-0000000056A6E991000001780000000D.Echo.0.
Timeout int Yes Maximum execution time for an instance.
InstanceCount int Yes Number of instances.
MaxRetryCount int No Maximum number of retries. Default value: 0
ClusterId string No ID of a cluster. Either one of this parameter and AutoCluster (anonymous cluster) must be selected.
AutoCluster object No Anonymous cluster. Either one of AutoCluster and ClusterId must be valid and only one of them takes effect.
Dependencies object No Object structure of a dependency between tasks. The key parameter indicates the name of a source task. The value parameter indicates a list of target task names and can describe a one-to-multiple sequenced relationship.

AutoCluster

Attribute Type Required or Not Description
ImageId string No ID of a BatchCompute image.
ECSImageId string No ID of an ECS image. The value must be a valid ID of an ECS image. Only one of ECSImageId and ImageId can be set to a valid value, and the other one must be left blank.
InstanceType string Yes Type of an instance for setting up a cluster. See Currently supported ECS instance types.
ResourceType String No Resource type. “OnDemand” and “Spot” are supported.
SpotStrategy String No Bidding strategy for an instance. It takes effect only when ResourceType is Spot.
Values:
SpotWithPriceLimit: Set the maximum price for the spot instance.
SpotAsPriceGo: The system provides a price automatically. The maximum value is the Pay-As-You-Go price.
SpotPriceLimit Float No Maximum price of an instance per hour (the price of each type of instance, not the price for each hour).The value can contain at most three decimals. It takes effect when SpotStrategy is SpotWithPriceLimit.
UserData object No Key-Value mapping. It is user-defined and can be obtained by using metaserver of the ECS.
Configs object No Cluster configurations, such as the disk configuration of the instance. It is described by Configs.
ReserveOnFail Bool No When a task fails, related VMs are not released, and the fees for these resources are still charged until the user deletes the job. The default value is False. It is used only in a survey.

Response

Success

The 201 status code and the following job ID are returned:

  1. {
  2. "Id":"job-xxx"
  3. }

Attribute description

Attribute Type Description
Id string ID of a job.

Error codes

Error code Error message HTTP status code Meaning
IdempotentTokenMismatch Specified idempotent token mismatch. 400 The token has been used and different from that in the previous request.
Invalid{Parameter} Specified parameter {Parameter} is not valid. 400 The {Parameter} parameter is invalid.
InvalidClusterId Specified parameter ClusterId is not valid. Its type must be string. 400 ClusterId must be a string.
InvalidClusterId Specified parameter ClusterId is not valid. Its length must be in [1, 64]. 400 The length of ClusterId must be in the range of [1, 64].
InvalidClusterId Specified parameter ClusterId is not valid. It must only contain characters within [a-zA-Z0-9-], and must not start with [0-9]. 400 ClusterId can contain only letters, numbers, underscores (), and hyphens (-), and cannot start with a number.
InvalidCommand Specified parameter Command is not valid. Its type must be object. 400 Command must be an object.
InvalidCommandLine Specified parameter CommandLine is not valid. Its type must be string. 400 CommandLine must be a string.
InvalidCommandLine Specified parameter CommandLine is not valid. Its length must be in [0, 1024]. 400 The length of CommandLine must be in the range of [0, 1024].
InvalidDAG Specified parameter DAG is not valid. Its type must be object. 400 DAG must be an object.
InvalidDependencies Specified parameter Dependencies is not valid. Its type must be object. 400 Dependencies must be an object.
InvalidDependencies.{key}.value Specified parameter Dependencies.{key}.value is not valid. Its type must be array. 400 The value of Dependencies.{key} must be an array.
InvalidDescription Specified parameter Description is not valid. Its type must be string. 400 Description must be a string.
InvalidDescription Specified parameter Description is not valid. Its length must be in [0, 1024]. 400 The length of Description must be in the range of [0, 1024].
InvalidEnvVars Specified parameter EnvVars is not valid. Its type must be object. 400 EnvVars must be an object.
InvalidEnvVars Specified parameter EnvVars is not valid. Its size must be in [0, 64]. 400 The value of EnvVars must be in the range of [0, 64].
InvalidEnvVars.{key} Specified parameter EnvVars.{key} is not valid. Its length must be in [1, 128]. 400 The size of EnvVars.{key} must be in the range of [1, 128].
InvalidEnvVars.{key}.value Specified parameter EnvVars.{key}.value is not valid. Its type must be string. 400 The value of EnvVars.{key} must be a string.
InvalidEnvVars.{key}.value Specified parameter EnvVars.{key}.value is not valid. Its length must be in [0, 1024]. 400 The length of EnvVars.{key} must be in the range of [0, 1024].
InvalidHttpBody Specified parameter HttpBody is not valid. Its type must be object. 400 Http Body must be an object.
InvalidInputMapping Specified parameter InputMapping is not valid. Its type must be object. 400 InputMapping must be an object.
InvalidInputMapping Specified parameter InputMapping is not valid. Its size must be in [0, 16]. 400 The number of keys in InputMapping must be in the range of [0, 16].
InvalidInputMapping.{key} Specified parameter InputMapping.{key} is not valid. Its length must be in [1, 1024]. 400 The length of InputMapping.{key} must be in the range of [1, 1024].
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. 400 InputMapping.{key} must be a valid OSS path.
InvalidInputMapping.{key}.value Specified parameter InputMapping.{key}.value is not valid. Its type must be string. 400 The value of InputMapping.{key} must be a string.
InvalidInputMapping.{key}.value Specified parameter InputMapping.{key}.value is not valid. Its length must be in [0, 1024]. 400 The length of InputMapping.{key} must be in the range of [0, 1024].
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. 400 InputMapping.{key} must be a valid local path.
InvalidInputMappingConfig Specified parameter InputMappingConfig is not valid. Its type must be object. 400 InputMappingConfig must be an object.
InvalidInstanceCount Specified parameter InstanceCount is not valid. Its type must be integer. 400 InstanceCount must be an integer.
InvalidJobFailOnInstanceFail Specified parameter JobFailOnInstanceFail is not valid. Its type must be boolean. 400 JobFailOnInstanceFail must be a boolean value.
InvalidJsonFormat The request body has an invalid json format. 400 The request body has an invalid JSON format.
InvalidLocale Specified parameter Locale is not valid. 400 The value of Locale is invalid.
InvalidLock Specified parameter Lock is not valid. Its type must be boolean. 400 Lock must be a boolean value.
InvalidLogMapping Specified parameter LogMapping is not valid. Its type must be object. 400 LogMapping must be an object.
InvalidLogMapping Specified parameter LogMapping is not valid. Its size must be in [0, 16]. 400 The number of keys in LogMapping must be in the range of [0, 16].
InvalidLogMapping.{key} Specified parameter LogMapping.{key} is not valid. Its length must be in [1, 1024]. 400 The length of LogMapping.{key} must be in the range of [1, 1024].
InvalidLogMapping.{key} Specified parameter LogMapping.{key} is not valid. Local path must be an absolute path. 400 LogMapping.{key} must be a valid local path.
InvalidLogMapping.{key}.value Specified parameter LogMapping.{key}.value is not valid. Its type must be string. 400 The value of LogMapping.{key} must be a string.
InvalidLogMapping.{key}.value Specified parameter LogMapping.{key}.value is not valid. Its length must be in [0, 1024]. 400 The length of LogMapping.{key} must be in the range of [0, 1024].
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. 400 The length of LogMapping.{key} must be in the range of [1, 1024].
InvalidMaxRetryCount Specified parameter MaxRetryCount is not valid. Its type must be integer. 400 MaxRetryCount must be an integer.
InvalidName Specified parameter Name is not valid. Its type must be string. 400 Name must be a string.
InvalidName Specified parameter Name is not valid. Its length must be in [1, 64]. 400 The length of Name must be in the range of [1, 64].
InvalidName Specified parameter Name is not valid. It must only contain characters within [a-zA-Z0-9-], and must not start with [0-9]. 400 Name can contain only letters, numbers, underscores, and hyphens, and cannot start with a number.
InvalidOutputMapping Specified parameter OutputMapping is not valid. Its type must be object. 400 OutputMapping must be an object.
InvalidOutputMapping Specified parameter OutputMapping is not valid. Its size must be in [0, 16]. 400 The number of keys in OutputMapping must be in the range of [0, 16].
InvalidOutputMapping.{key} Specified parameter OutputMapping.{key} is not valid. Its length must be in [1, 1024]. 400 The length of OutputMapping.{key} must be in the range of [1, 1024].
InvalidOutputMapping.{key} Specified parameter OutputMapping.{key} is not valid. Local path must be an absolute path. 400 OutputMapping.{key} must be a valid local path.
InvalidOutputMapping.{key}.value Specified parameter OutputMapping.{key}.value is not valid. Its type must be string. 400 The value of OutputMapping.{key} must be a string.
InvalidOutputMapping.{key}.value Specified parameter OutputMapping.{key}.value is not valid. Its length must be in [0, 1024]. 400 The length of OutputMapping.{key} must be in the range of [0, 1024].
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. 400 The length of OutputMapping.{key} must be in the range of [1, 1024].
InvalidPackagePath Specified parameter PackagePath is not valid. Its type must be string. 400 PackagePath must be a string.
InvalidPackagePath Specified parameter PackagePath is not valid. Its length must be in [0, 1024]. 400 The length of PackagePath must be in the range of [0, 1024].
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. 400 PackagePath must be a valid OSS path.
InvalidParameters Specified parameter Parameters is not valid. Its type must be object. 400 Parameters must be an object.
InvalidPriority Specified parameter Priority is not valid. Its type must be integer. 400 Priority must be an integer.
InvalidPriority Specified parameter Priority is not valid. It must be in [0, 1000]. 400 The value of Priority must be in the range of [0, 1000].
InvalidStderrRedirectPath Specified parameter StderrRedirectPath is not valid. Its type must be string. 400 StderrRedirectPath must be a string.
InvalidStderrRedirectPath Specified parameter StderrRedirectPath is not valid. Its length must be in [0, 1024]. 400 The length of StderrRedirectPath must be in the range of [0, 1024].
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. 400 StderrRedirectPath must be a valid OSS path.
InvalidStdoutRedirectPath Specified parameter StdoutRedirectPath is not valid. Its type must be string. 400 StdoutRedirectPath must be a string.
InvalidStdoutRedirectPath Specified parameter StdoutRedirectPath is not valid. Its length must be in [0, 1024]. 400 The length of StdoutRedirectPath must be in the range of [0, 1024].
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. 400 StdoutRedirectPath must be a valid OSS path.
InvalidTasks Specified parameter Tasks is not valid. Its type must be object. 400 Tasks must be an object.
InvalidTasks Specified parameter Tasks is not valid. Its size must be in [1, 16]. 400 The size of UserData must be in the range of [1, 16].
InvalidTasks.{key} Specified parameter Tasks.{key} is not valid. Its length must be in [1, 64]. 400 The length of Tasks.{key} must be in the range of [1, 64].
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].. 400 Tasks.{key} can contain letters, numbers, underscores (_), and hyphens (-), and cannot start with a number.
InvalidTimeout Specified parameter Timeout is not valid. Its type must be integer. 400 Timeout must be an integer.
InvalidType Specified parameter Type is not valid. 400 The value of Type is invalid.
MissingClusterId ClusterId is mandatory for this action. 400 The ClusterId parameter is missing.
MissingCommand Command is mandatory for this action. 400 The Command parameter is missing.
MissingCommandLine CommandLine is mandatory for this action. 400 The CommandLine parameter is missing.
MissingDAG DAG is mandatory for this action. 400 The parameter DAG is missing.
MissingInstanceCount InstanceCount is mandatory for this action. 400 The InstanceCount parameter is missing.
MissingName Name is mandatory for this action. 400 The parameter Name is missing.
MissingParameters Parameters is mandatory for this action. 400 The Parameters parameter is missing.
MissingTasks Tasks is mandatory for this action. 400 The parameter Tasks is missing.
MissingType Type is mandatory for this action. 400 The parameter Type is missing.
QuotaExhausted.MaxInstanceTimeout The MaxInstanceTimeout ({value}) quota is exhausted. 403 Timeout of an instance cannot exceed {value}.
QuotaExhausted.MaxJobCount The MaxJobCount ({value}) quota is exhausted. 403 The number of jobs cannot exceed {value}.
QuotaExhausted.MaxJobTaskCount The MaxJobTaskCount ({value}) quota is exhausted. 403 The number of tasks in a job cannot exceed {value}.
QuotaExhausted.MaxTaskInstanceCount The MaxTaskInstanceCount ({value}) quota is exhausted. 403 InstanceCount of a task cannot exceed {value}.