All Products
Search
Document Center

Batch Compute:CreateJob(DAG)

Last Updated:May 09, 2024

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

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.

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.

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.

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:

{
    "Id":"job-xxx"
}

Attribute description

Attribute

Type

Description

Id

string

ID of a job.

Error codes

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 a 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}.