AWS Batch

2017/11/29 - AWS Batch - 3 updated api methods

Changes  Update batch client to latest version

DescribeJobs (updated) Link ¶
Changes (response)
{'jobs': {'arrayProperties': {'index': 'integer',
                              'size': 'integer',
                              'statusSummary': {'string': 'integer'}},
          'dependsOn': {'type': 'N_TO_N | SEQUENTIAL'}}}

Describes a list of AWS Batch jobs.

See also: AWS API Documentation

Request Syntax

client.describe_jobs(
    jobs=[
        'string',
    ]
)
type jobs:

list

param jobs:

[REQUIRED]

A space-separated list of up to 100 job IDs.

  • (string) --

rtype:

dict

returns:

Response Syntax

{
    'jobs': [
        {
            'jobName': 'string',
            'jobId': 'string',
            'jobQueue': 'string',
            'status': 'SUBMITTED'|'PENDING'|'RUNNABLE'|'STARTING'|'RUNNING'|'SUCCEEDED'|'FAILED',
            'attempts': [
                {
                    'container': {
                        'containerInstanceArn': 'string',
                        'taskArn': 'string',
                        'exitCode': 123,
                        'reason': 'string',
                        'logStreamName': 'string'
                    },
                    'startedAt': 123,
                    'stoppedAt': 123,
                    'statusReason': 'string'
                },
            ],
            'statusReason': 'string',
            'createdAt': 123,
            'retryStrategy': {
                'attempts': 123
            },
            'startedAt': 123,
            'stoppedAt': 123,
            'dependsOn': [
                {
                    'jobId': 'string',
                    'type': 'N_TO_N'|'SEQUENTIAL'
                },
            ],
            'jobDefinition': 'string',
            'parameters': {
                'string': 'string'
            },
            'container': {
                'image': 'string',
                'vcpus': 123,
                'memory': 123,
                'command': [
                    'string',
                ],
                'jobRoleArn': 'string',
                'volumes': [
                    {
                        'host': {
                            'sourcePath': 'string'
                        },
                        'name': 'string'
                    },
                ],
                'environment': [
                    {
                        'name': 'string',
                        'value': 'string'
                    },
                ],
                'mountPoints': [
                    {
                        'containerPath': 'string',
                        'readOnly': True|False,
                        'sourceVolume': 'string'
                    },
                ],
                'readonlyRootFilesystem': True|False,
                'ulimits': [
                    {
                        'hardLimit': 123,
                        'name': 'string',
                        'softLimit': 123
                    },
                ],
                'privileged': True|False,
                'user': 'string',
                'exitCode': 123,
                'reason': 'string',
                'containerInstanceArn': 'string',
                'taskArn': 'string',
                'logStreamName': 'string'
            },
            'arrayProperties': {
                'statusSummary': {
                    'string': 123
                },
                'size': 123,
                'index': 123
            }
        },
    ]
}

Response Structure

  • (dict) --

    • jobs (list) --

      The list of jobs.

      • (dict) --

        An object representing an AWS Batch job.

        • jobName (string) --

          The name of the job.

        • jobId (string) --

          The ID for the job.

        • jobQueue (string) --

          The Amazon Resource Name (ARN) of the job queue with which the job is associated.

        • status (string) --

          The current status for the job.

        • attempts (list) --

          A list of job attempts associated with this job.

          • (dict) --

            An object representing a job attempt.

            • container (dict) --

              Details about the container in this job attempt.

              • containerInstanceArn (string) --

                The Amazon Resource Name (ARN) of the Amazon ECS container instance that hosts the job attempt.

              • taskArn (string) --

                The Amazon Resource Name (ARN) of the Amazon ECS task that is associated with the job attempt. Each container attempt receives a task ARN when they reach the STARTING status.

              • exitCode (integer) --

                The exit code for the job attempt. A non-zero exit code is considered a failure.

              • reason (string) --

                A short (255 max characters) human-readable string to provide additional details about a running or stopped container.

              • logStreamName (string) --

                The name of the CloudWatch Logs log stream associated with the container. The log group for AWS Batch jobs is /aws/batch/job. Each container attempt receives a log stream name when they reach the RUNNING status.

            • startedAt (integer) --

              The Unix time stamp for when the attempt was started (when the attempt transitioned from the STARTING state to the RUNNING state).

            • stoppedAt (integer) --

              The Unix time stamp for when the attempt was stopped (when the attempt transitioned from the RUNNING state to a terminal state, such as SUCCEEDED or FAILED).

            • statusReason (string) --

              A short, human-readable string to provide additional details about the current status of the job attempt.

        • statusReason (string) --

          A short, human-readable string to provide additional details about the current status of the job.

        • createdAt (integer) --

          The Unix time stamp for when the job was created. For non-array jobs and parent array jobs, this is when the job entered the SUBMITTED state (at the time SubmitJob was called). For array child jobs, this is when the child job was spawned by its parent and entered the PENDING state.

        • retryStrategy (dict) --

          The retry strategy to use for this job if an attempt fails.

          • attempts (integer) --

            The number of times to move a job to the RUNNABLE status. You may specify between 1 and 10 attempts. If the value of attempts is greater than one, the job is retried if it fails until it has moved to RUNNABLE that many times.

        • startedAt (integer) --

          The Unix time stamp for when the job was started (when the job transitioned from the STARTING state to the RUNNING state).

        • stoppedAt (integer) --

          The Unix time stamp for when the job was stopped (when the job transitioned from the RUNNING state to a terminal state, such as SUCCEEDED or FAILED).

        • dependsOn (list) --

          A list of job names or IDs on which this job depends.

          • (dict) --

            An object representing an AWS Batch job dependency.

            • jobId (string) --

              The job ID of the AWS Batch job associated with this dependency.

            • type (string) --

              The type of the job dependency.

        • jobDefinition (string) --

          The job definition that is used by this job.

        • parameters (dict) --

          Additional parameters passed to the job that replace parameter substitution placeholders or override any corresponding parameter defaults from the job definition.

          • (string) --

            • (string) --

        • container (dict) --

          An object representing the details of the container that is associated with the job.

          • image (string) --

            The image used to start the container.

          • vcpus (integer) --

            The number of VCPUs allocated for the job.

          • memory (integer) --

            The number of MiB of memory reserved for the job.

          • command (list) --

            The command that is passed to the container.

            • (string) --

          • jobRoleArn (string) --

            The Amazon Resource Name (ARN) associated with the job upon execution.

          • volumes (list) --

            A list of volumes associated with the job.

            • (dict) --

              A data volume used in a job's container properties.

              • host (dict) --

                The contents of the host parameter determine whether your data volume persists on the host container instance and where it is stored. If the host parameter is empty, then the Docker daemon assigns a host path for your data volume. However, the data is not guaranteed to persist after the containers associated with it stop running.

                • sourcePath (string) --

                  The path on the host container instance that is presented to the container. If this parameter is empty, then the Docker daemon has assigned a host path for you. If the host parameter contains a sourcePath file location, then the data volume persists at the specified location on the host container instance until you delete it manually. If the sourcePath value does not exist on the host container instance, the Docker daemon creates it. If the location does exist, the contents of the source path folder are exported.

              • name (string) --

                The name of the volume. Up to 255 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed. This name is referenced in the sourceVolume parameter of container definition mountPoints.

          • environment (list) --

            The environment variables to pass to a container.

            • (dict) --

              A key-value pair object.

              • name (string) --

                The name of the key-value pair. For environment variables, this is the name of the environment variable.

              • value (string) --

                The value of the key-value pair. For environment variables, this is the value of the environment variable.

          • mountPoints (list) --

            The mount points for data volumes in your container.

            • (dict) --

              Details on a Docker volume mount point that is used in a job's container properties.

              • containerPath (string) --

                The path on the container at which to mount the host volume.

              • readOnly (boolean) --

                If this value is true, the container has read-only access to the volume; otherwise, the container can write to the volume. The default value is false.

              • sourceVolume (string) --

                The name of the volume to mount.

          • readonlyRootFilesystem (boolean) --

            When this parameter is true, the container is given read-only access to its root file system.

          • ulimits (list) --

            A list of ulimit values to set in the container.

            • (dict) --

              The ulimit settings to pass to the container.

              • hardLimit (integer) --

                The hard limit for the ulimit type.

              • name (string) --

                The type of the ulimit.

              • softLimit (integer) --

                The soft limit for the ulimit type.

          • privileged (boolean) --

            When this parameter is true, the container is given elevated privileges on the host container instance (similar to the root user).

          • user (string) --

            The user name to use inside the container.

          • exitCode (integer) --

            The exit code to return upon completion.

          • reason (string) --

            A short (255 max characters) human-readable string to provide additional details about a running or stopped container.

          • containerInstanceArn (string) --

            The Amazon Resource Name (ARN) of the container instance on which the container is running.

          • taskArn (string) --

            The Amazon Resource Name (ARN) of the Amazon ECS task that is associated with the container job. Each container attempt receives a task ARN when they reach the STARTING status.

          • logStreamName (string) --

            The name of the CloudWatch Logs log stream associated with the container. The log group for AWS Batch jobs is /aws/batch/job. Each container attempt receives a log stream name when they reach the RUNNING status.

        • arrayProperties (dict) --

          The array properties of the job, if it is an array job.

          • statusSummary (dict) --

            A summary of the number of array job children in each available job status. This parameter is returned for parent array jobs.

            • (string) --

              • (integer) --

          • size (integer) --

            The size of the array job. This parameter is returned for parent array jobs.

          • index (integer) --

            The job index within the array that is associated with this job. This parameter is returned for array job children.

ListJobs (updated) Link ¶
Changes (request, response)
Request
{'arrayJobId': 'string'}
Response
{'jobSummaryList': {'arrayProperties': {'index': 'integer', 'size': 'integer'},
                    'container': {'exitCode': 'integer', 'reason': 'string'},
                    'createdAt': 'long',
                    'startedAt': 'long',
                    'status': 'SUBMITTED | PENDING | RUNNABLE | STARTING | '
                              'RUNNING | SUCCEEDED | FAILED',
                    'statusReason': 'string',
                    'stoppedAt': 'long'}}

Returns a list of task jobs for a specified job queue. You can filter the results by job status with the jobStatus parameter. If you do not specify a status, only RUNNING jobs are returned.

See also: AWS API Documentation

Request Syntax

client.list_jobs(
    jobQueue='string',
    arrayJobId='string',
    jobStatus='SUBMITTED'|'PENDING'|'RUNNABLE'|'STARTING'|'RUNNING'|'SUCCEEDED'|'FAILED',
    maxResults=123,
    nextToken='string'
)
type jobQueue:

string

param jobQueue:

The name or full Amazon Resource Name (ARN) of the job queue with which to list jobs.

type arrayJobId:

string

param arrayJobId:

The job ID for an array job. Specifying an array job ID with this parameter lists all child jobs from within the specified array.

type jobStatus:

string

param jobStatus:

The job status with which to filter jobs in the specified queue. If you do not specify a status, only RUNNING jobs are returned.

type maxResults:

integer

param maxResults:

The maximum number of results returned by ListJobs in paginated output. When this parameter is used, ListJobs only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sending another ListJobs request with the returned nextToken value. This value can be between 1 and 100. If this parameter is not used, then ListJobs returns up to 100 results and a nextToken value if applicable.

type nextToken:

string

param nextToken:

The nextToken value returned from a previous paginated ListJobs request where maxResults was used and the results exceeded the value of that parameter. Pagination continues from the end of the previous results that returned the nextToken value. This value is null when there are no more results to return.

rtype:

dict

returns:

Response Syntax

{
    'jobSummaryList': [
        {
            'jobId': 'string',
            'jobName': 'string',
            'createdAt': 123,
            'status': 'SUBMITTED'|'PENDING'|'RUNNABLE'|'STARTING'|'RUNNING'|'SUCCEEDED'|'FAILED',
            'statusReason': 'string',
            'startedAt': 123,
            'stoppedAt': 123,
            'container': {
                'exitCode': 123,
                'reason': 'string'
            },
            'arrayProperties': {
                'size': 123,
                'index': 123
            }
        },
    ],
    'nextToken': 'string'
}

Response Structure

  • (dict) --

    • jobSummaryList (list) --

      A list of job summaries that match the request.

      • (dict) --

        An object representing summary details of a job.

        • jobId (string) --

          The ID of the job.

        • jobName (string) --

          The name of the job.

        • createdAt (integer) --

          The Unix time stamp for when the job was created. For non-array jobs and parent array jobs, this is when the job entered the SUBMITTED state (at the time SubmitJob was called). For array child jobs, this is when the child job was spawned by its parent and entered the PENDING state.

        • status (string) --

          The current status for the job.

        • statusReason (string) --

          A short, human-readable string to provide additional details about the current status of the job.

        • startedAt (integer) --

          The Unix time stamp for when the job was started (when the job transitioned from the STARTING state to the RUNNING state).

        • stoppedAt (integer) --

          The Unix time stamp for when the job was stopped (when the job transitioned from the RUNNING state to a terminal state, such as SUCCEEDED or FAILED).

        • container (dict) --

          An object representing the details of the container that is associated with the job.

          • exitCode (integer) --

            The exit code to return upon completion.

          • reason (string) --

            A short (255 max characters) human-readable string to provide additional details about a running or stopped container.

        • arrayProperties (dict) --

          The array properties of the job, if it is an array job.

          • size (integer) --

            The size of the array job. This parameter is returned for parent array jobs.

          • index (integer) --

            The job index within the array that is associated with this job. This parameter is returned for children of array jobs.

    • nextToken (string) --

      The nextToken value to include in a future ListJobs request. When the results of a ListJobs request exceed maxResults, this value can be used to retrieve the next page of results. This value is null when there are no more results to return.

SubmitJob (updated) Link ¶
Changes (request)
{'arrayProperties': {'size': 'integer'},
 'dependsOn': {'type': 'N_TO_N | SEQUENTIAL'}}

Submits an AWS Batch job from a job definition. Parameters specified during SubmitJob override parameters defined in the job definition.

See also: AWS API Documentation

Request Syntax

client.submit_job(
    jobName='string',
    jobQueue='string',
    arrayProperties={
        'size': 123
    },
    dependsOn=[
        {
            'jobId': 'string',
            'type': 'N_TO_N'|'SEQUENTIAL'
        },
    ],
    jobDefinition='string',
    parameters={
        'string': 'string'
    },
    containerOverrides={
        'vcpus': 123,
        'memory': 123,
        'command': [
            'string',
        ],
        'environment': [
            {
                'name': 'string',
                'value': 'string'
            },
        ]
    },
    retryStrategy={
        'attempts': 123
    }
)
type jobName:

string

param jobName:

[REQUIRED]

The name of the job. The first character must be alphanumeric, and up to 128 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed.

type jobQueue:

string

param jobQueue:

[REQUIRED]

The job queue into which the job is submitted. You can specify either the name or the Amazon Resource Name (ARN) of the queue.

type arrayProperties:

dict

param arrayProperties:

The array properties for the submitted job, such as the size of the array. The array size can be between 2 and 10,000. If you specify array properties for a job, it becomes an array job. For more information, see Array Jobs in the AWS Batch User Guide.

  • size (integer) --

    The size of the array job.

type dependsOn:

list

param dependsOn:

A list of dependencies for the job. A job can depend upon a maximum of 20 jobs. You can specify a SEQUENTIAL type dependency without specifying a job ID for array jobs so that each child array job completes sequentially, starting at index 0. You can also specify an N_TO_N type dependency with a job ID for array jobs so that each index child of this job must wait for the corresponding index child of each dependency to complete before it can begin.

  • (dict) --

    An object representing an AWS Batch job dependency.

    • jobId (string) --

      The job ID of the AWS Batch job associated with this dependency.

    • type (string) --

      The type of the job dependency.

type jobDefinition:

string

param jobDefinition:

[REQUIRED]

The job definition used by this job. This value can be either a name:revision or the Amazon Resource Name (ARN) for the job definition.

type parameters:

dict

param parameters:

Additional parameters passed to the job that replace parameter substitution placeholders that are set in the job definition. Parameters are specified as a key and value pair mapping. Parameters in a SubmitJob request override any corresponding parameter defaults from the job definition.

  • (string) --

    • (string) --

type containerOverrides:

dict

param containerOverrides:

A list of container overrides in JSON format that specify the name of a container in the specified job definition and the overrides it should receive. You can override the default command for a container (that is specified in the job definition or the Docker image) with a command override. You can also override existing environment variables (that are specified in the job definition or Docker image) on a container or add new environment variables to it with an environment override.

  • vcpus (integer) --

    The number of vCPUs to reserve for the container. This value overrides the value set in the job definition.

  • memory (integer) --

    The number of MiB of memory reserved for the job. This value overrides the value set in the job definition.

  • command (list) --

    The command to send to the container that overrides the default command from the Docker image or the job definition.

    • (string) --

  • environment (list) --

    The environment variables to send to the container. You can add new environment variables, which are added to the container at launch, or you can override the existing environment variables from the Docker image or the job definition.

    • (dict) --

      A key-value pair object.

      • name (string) --

        The name of the key-value pair. For environment variables, this is the name of the environment variable.

      • value (string) --

        The value of the key-value pair. For environment variables, this is the value of the environment variable.

type retryStrategy:

dict

param retryStrategy:

The retry strategy to use for failed jobs from this SubmitJob operation. When a retry strategy is specified here, it overrides the retry strategy defined in the job definition.

  • attempts (integer) --

    The number of times to move a job to the RUNNABLE status. You may specify between 1 and 10 attempts. If the value of attempts is greater than one, the job is retried if it fails until it has moved to RUNNABLE that many times.

rtype:

dict

returns:

Response Syntax

{
    'jobName': 'string',
    'jobId': 'string'
}

Response Structure

  • (dict) --

    • jobName (string) --

      The name of the job.

    • jobId (string) --

      The unique identifier for the job.