Creates and submits a DAG job.

Request syntax

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": true
                    }
                ],
                "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": true
                }
            ],
            "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,
        "WriteSupport": true
      }
    }
  }
}

Attribute description

AttributeTypeRequired or NotDescription
NamestringYesName of a job.
DescriptionstringNoDescription of a job.
PriorityintYesPriority of a job. The value ranges from 0 to 1000. Priority increases with the value.
TypestringYesCurrently, a task can be described only in the form of a directed acyclic graph (DAG).
JobFailOnInstanceFailboolYesThe value True indicates that a job fails when an instance fails.
AutoReleaseboolNoThe value True indicates that the system automatically deletes a job after the job runs successfully. Default value: False
NotificationobjectNoNotification message configuration.
DAGobjectYesDescription of a DAG.
TasksobjectYesDescription of a task.
ParametersobjectYesDetails about a task parameter.
CommandobjectYesCommand line parameter related to a user program.
CommandLineStringYesSpecifies 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.”
PackagePathstringYesOSS path in which a user program resides.
EnvVarsstringNoEnvironment variable for the execution of a user program.
InputMappingConfigobjectNoConfiguration of an NFS mounting service.
LocalestringNoCharacter 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.
LockboolNoSpecifies whether the NFS mounting service supports network file locking.
StdoutRedirectPathstringYesOSS directory to which standard output is redirected.
StderrRedirectPathstringYesOSS directory to which a standard error is redirected.
InputMappingobjectNoMapping from the OSS directory to the local directory.
OutputMappingobjectNoMapping from the local directory to the OSS directory.
LogMappingobjectNoMapping 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.
TimeoutintYesMaximum execution time for an instance.
InstanceCountintYesNumber of instances.
MaxRetryCountintNoMaximum number of retries. Default value: 0
ClusterIdstringNoID of a cluster. Either one of this parameter and AutoCluster (anonymous cluster) must be selected.
AutoClusterobjectNoAnonymous cluster. Either one of AutoCluster and ClusterId must be valid and only one of them takes effect.
DependenciesobjectNoObject 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

AttributeTypeRequired or NotDescription
ImageIdstringNoID of a BatchCompute image.
ECSImageIdstringNoID 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.
InstanceTypestringYesType of an instance for setting up a cluster.
ResourceTypeStringNoResource type. “OnDemand” and “Spot” are supported.
SpotStrategyStringNoBidding 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.
SpotPriceLimitFloatNoMaximum 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.
UserDataobjectNoKey-Value mapping. It is user-defined and can be obtained by using metaserver of the ECS.
ConfigsobjectNoCluster configurations.
ReserveOnFailBoolNoWhen 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:

{
    "Id":"job-xxx"
}

Attribute description

AttributeTypeDescription
IdstringID of a job.

Error codes

IdempotentTokenMismatchSpecified idempotent token mismatch.400The token has been used and different from that in the previous request.
Invalid{Parameter}Specified parameter {Parameter} is not valid.400The {Parameter} parameter is invalid.
InvalidClusterIdSpecified parameter ClusterId is not valid. Its type must be string.400ClusterId must be a string.
InvalidClusterIdSpecified parameter ClusterId is not valid. Its length must be in [1, 64].400The length of ClusterId must be in the range of [1, 64].
InvalidClusterIdSpecified parameter ClusterId is not valid. It must only contain characters within [a-zA-Z0-9-], and must not start with [0-9].400ClusterId can contain only letters, numbers, underscores (), and hyphens (-), and cannot start with a number.
InvalidCommandSpecified parameter Command is not valid. Its type must be object.400Command must be an object.
InvalidCommandLineSpecified parameter CommandLine is not valid. Its type must be string.400CommandLine must be a string.
InvalidCommandLineSpecified parameter CommandLine is not valid. Its length must be in [0, 1024].400The length of CommandLine must be in the range of [0, 1024].
InvalidDAGSpecified parameter DAG is not valid. Its type must be object.400DAG must be an object.
InvalidDependenciesSpecified parameter Dependencies is not valid. Its type must be object.400Dependencies must be an object.
InvalidDependencies.{key}.valueSpecified parameter Dependencies.{key}.value is not valid. Its type must be array.400The value of Dependencies.{key} must be an array.
InvalidDescriptionSpecified parameter Description is not valid. Its type must be string.400Description must be a string.
InvalidDescriptionSpecified parameter Description is not valid. Its length must be in [0, 1024].400The length of Description must be in the range of [0, 1024].
InvalidEnvVarsSpecified parameter EnvVars is not valid. Its type must be object.400EnvVars must be an object.
InvalidEnvVarsSpecified parameter EnvVars is not valid. Its size must be in [0, 64].400The 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].400The size of EnvVars.{key} must be in the range of [1, 128].
InvalidEnvVars.{key}.valueSpecified parameter EnvVars.{key}.value is not valid. Its type must be string.400The value of EnvVars.{key} must be a string.
InvalidEnvVars.{key}.valueSpecified parameter EnvVars.{key}.value is not valid. Its length must be in [0, 1024].400The length of EnvVars.{key} must be in the range of [0, 1024].
InvalidHttpBodySpecified parameter HttpBody is not valid. Its type must be object.400Http Body must be an object.
InvalidInputMappingSpecified parameter InputMapping is not valid. Its type must be object.400InputMapping must be an object.
InvalidInputMappingSpecified parameter InputMapping is not valid. Its size must be in [0, 16].400The 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].400The 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.400InputMapping.{key} must be a valid OSS path.
InvalidInputMapping.{key}.valueSpecified parameter InputMapping.{key}.value is not valid. Its type must be string.400The value of InputMapping.{key} must be a string.
InvalidInputMapping.{key}.valueSpecified parameter InputMapping.{key}.value is not valid. Its length must be in [0, 1024].400The length of InputMapping.{key} must be in the range of [0, 1024].
InvalidInputMapping.{key}.valueSpecified parameter InputMapping.{key}.value is not valid. Local path must be an absolute path on linux, and an drive letter on windows.400InputMapping.{key} must be a valid local path.
InvalidInputMappingConfigSpecified parameter InputMappingConfig is not valid. Its type must be object.400InputMappingConfig must be an object.
InvalidInstanceCountSpecified parameter InstanceCount is not valid. Its type must be integer.400InstanceCount must be an integer.
InvalidJobFailOnInstanceFailSpecified parameter JobFailOnInstanceFail is not valid. Its type must be boolean.400JobFailOnInstanceFail must be a boolean value.
InvalidJsonFormatThe request body has an invalid json format.400The request body has an invalid JSON format.
InvalidLocaleSpecified parameter Locale is not valid.400The value of Locale is invalid.
InvalidLockSpecified parameter Lock is not valid. Its type must be boolean.400Lock must be a boolean value.
InvalidLogMappingSpecified parameter LogMapping is not valid. Its type must be object.400LogMapping must be an object.
InvalidLogMappingSpecified parameter LogMapping is not valid. Its size must be in [0, 16].400The 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].400The 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.400LogMapping.{key} must be a valid local path.
InvalidLogMapping.{key}.valueSpecified parameter LogMapping.{key}.value is not valid. Its type must be string.400The value of LogMapping.{key} must be a string.
InvalidLogMapping.{key}.valueSpecified parameter LogMapping.{key}.value is not valid. Its length must be in [0, 1024].400The length of LogMapping.{key} must be in the range of [0, 1024].
InvalidLogMapping.{key}.valueSpecified 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.400The length of LogMapping.{key} must be in the range of [1, 1024].
InvalidMaxRetryCountSpecified parameter MaxRetryCount is not valid. Its type must be integer.400MaxRetryCount must be an integer.
InvalidNameSpecified parameter Name is not valid. Its type must be string.400Name must be a string.
InvalidNameSpecified parameter Name is not valid. Its length must be in [1, 64].400The length of Name must be in the range of [1, 64].
InvalidNameSpecified parameter Name is not valid. It must only contain characters within [a-zA-Z0-9-], and must not start with [0-9].400Name can contain only letters, numbers, underscores, and hyphens, and cannot start with a number.
InvalidOutputMappingSpecified parameter OutputMapping is not valid. Its type must be object.400OutputMapping must be an object.
InvalidOutputMappingSpecified parameter OutputMapping is not valid. Its size must be in [0, 16].400The 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].400The 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.400OutputMapping.{key} must be a valid local path.
InvalidOutputMapping.{key}.valueSpecified parameter OutputMapping.{key}.value is not valid. Its type must be string.400The value of OutputMapping.{key} must be a string.
InvalidOutputMapping.{key}.valueSpecified parameter OutputMapping.{key}.value is not valid. Its length must be in [0, 1024].400The length of OutputMapping.{key} must be in the range of [0, 1024].
InvalidOutputMapping.{key}.valueSpecified 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.400The length of OutputMapping.{key} must be in the range of [1, 1024].
InvalidPackagePathSpecified parameter PackagePath is not valid. Its type must be string.400PackagePath must be a string.
InvalidPackagePathSpecified parameter PackagePath is not valid. Its length must be in [0, 1024].400The length of PackagePath must be in the range of [0, 1024].
InvalidPackagePathSpecified 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.400PackagePath must be a valid OSS path.
InvalidParametersSpecified parameter Parameters is not valid. Its type must be object.400Parameters must be an object.
InvalidPrioritySpecified parameter Priority is not valid. Its type must be integer.400Priority must be an integer.
InvalidPrioritySpecified parameter Priority is not valid. It must be in [0, 1000].400The value of Priority must be in the range of [0, 1000].
InvalidStderrRedirectPathSpecified parameter StderrRedirectPath is not valid. Its type must be string.400StderrRedirectPath must be a string.
InvalidStderrRedirectPathSpecified parameter StderrRedirectPath is not valid. Its length must be in [0, 1024].400The length of StderrRedirectPath must be in the range of [0, 1024].
InvalidStderrRedirectPathSpecified 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.400StderrRedirectPath must be a valid OSS path.
InvalidStdoutRedirectPathSpecified parameter StdoutRedirectPath is not valid. Its type must be string.400StdoutRedirectPath must be a string.
InvalidStdoutRedirectPathSpecified parameter StdoutRedirectPath is not valid. Its length must be in [0, 1024].400The length of StdoutRedirectPath must be in the range of [0, 1024].
InvalidStdoutRedirectPathSpecified 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.400StdoutRedirectPath must be a valid OSS path.
InvalidTasksSpecified parameter Tasks is not valid. Its type must be object.400Tasks must be an object.
InvalidTasksSpecified parameter Tasks is not valid. Its size must be in [1, 16].400The 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].400The 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]..400Tasks.{key} can contain letters, numbers, underscores (_), and hyphens (-), and cannot start with a number.
InvalidTimeoutSpecified parameter Timeout is not valid. Its type must be integer.400Timeout must be an integer.
InvalidTypeSpecified parameter Type is not valid.400The value of Type is invalid.
MissingClusterIdClusterId is mandatory for this action.400The ClusterId parameter is missing.
MissingCommandCommand is mandatory for this action.400The Command parameter is missing.
MissingCommandLineCommandLine is mandatory for this action.400The CommandLine parameter is missing.
MissingDAGDAG is mandatory for this action.400The parameter DAG is missing.
MissingInstanceCountInstanceCount is mandatory for this action.400The InstanceCount parameter is missing.
MissingNameName is mandatory for this action.400The parameter Name is missing.
MissingParametersParameters is mandatory for this action.400The Parameters parameter is missing.
MissingTasksTasks is mandatory for this action.400The parameter Tasks is missing.
MissingTypeType is mandatory for this action.400The parameter Type is missing.
QuotaExhausted.MaxInstanceTimeoutThe MaxInstanceTimeout ({value}) quota is exhausted.403Timeout of an instance cannot exceed {value}.
QuotaExhausted.MaxJobCountThe MaxJobCount ({value}) quota is exhausted.403The number of jobs cannot exceed {value}.
QuotaExhausted.MaxJobTaskCountThe MaxJobTaskCount ({value}) quota is exhausted.403The number of tasks in a job cannot exceed {value}.
QuotaExhausted.MaxTaskInstanceCountThe MaxTaskInstanceCount ({value}) quota is exhausted.403InstanceCount of a task cannot exceed {value}.