Skip to content

submit_job async

submit_job(
    *,
    config_overrides: Optional[AsyncBatchClientConfig] = None,
    job_name: Optional[String] = None,
    job_queue: Optional[String] = None,
    share_identifier: Optional[String] = None,
    scheduling_priority_override: Optional[Integer] = None,
    array_properties: Optional[ArrayProperties] = None,
    depends_on: Optional[JobDependencyList] = None,
    job_definition: Optional[String] = None,
    parameters: Optional[ParametersMap] = None,
    container_overrides: Optional[ContainerOverrides] = None,
    node_overrides: Optional[NodeOverrides] = None,
    retry_strategy: Optional[RetryStrategy] = None,
    propagate_tags: Optional[Boolean] = None,
    timeout: Optional[JobTimeout] = None,
    tags: Optional[TagrisTagsMap] = None,
    eks_properties_override: Optional[EksPropertiesOverride] = None,
    ecs_properties_override: Optional[EcsPropertiesOverride] = None,
    consumable_resource_properties_override: Optional[
        ConsumableResourceProperties
    ] = None,
) -> SubmitJobResponse

Submits an Batch job from a job definition. Parameters that are specified during SubmitJob override parameters defined in the job definition. vCPU and memory requirements that are specified in the resourceRequirements objects in the job definition are the exception. They can't be overridden this way using the memory and vcpus parameters. Rather, you must specify updates to job definition parameters in a resourceRequirements object that's included in the containerOverrides parameter.

Job queues with a scheduling policy are limited to 500 active share identifiers at a time.

Jobs that run on Fargate resources can't be guaranteed to run for more than 14 days. This is because, after 14 days, Fargate resources might become unavailable and job might be terminated.

Parameters:

  • job_name (Optional[String], default: None ) –

    The name of the job. It can be up to 128 letters long. The first character must be alphanumeric, can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).

  • job_queue (Optional[String], default: None ) –

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

  • share_identifier (Optional[String], default: None ) –

    The share identifier for the job. Don't specify this parameter if the job queue doesn't have a fair-share scheduling policy. If the job queue has a fair-share scheduling policy, then this parameter must be specified.

    This string is limited to 255 alphanumeric characters, and can be followed by an asterisk (*).

  • scheduling_priority_override (Optional[Integer], default: None ) –

    The scheduling priority for the job. This only affects jobs in job queues with a fair-share policy. Jobs with a higher scheduling priority are scheduled before jobs with a lower scheduling priority. This overrides any scheduling priority in the job definition and works only within a single share identifier.

    The minimum supported value is 0 and the maximum supported value is 9999.

  • array_properties (Optional[ArrayProperties], default: None ) –

    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 Batch User Guide.

  • depends_on (Optional[JobDependencyList], default: None ) –

    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. In that case, each index child of this job must wait for the corresponding index child of each dependency to complete before it can begin.

  • job_definition (Optional[String], default: None ) –

    The job definition used by this job. This value can be one of definition-name, definition-name:revision, or the Amazon Resource Name (ARN) for the job definition, with or without the revision (arn:aws:batch:region:account:job-definition/definition-name:revision , or arn:aws:batch:region:account:job-definition/definition-name ).

    If the revision is not specified, then the latest active revision is used.

  • parameters (Optional[ParametersMap], default: None ) –

    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.

  • container_overrides (Optional[ContainerOverrides], default: None ) –

    An object with properties that override the defaults for the job definition 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, which is specified in the job definition or the Docker image, with a command override. You can also override existing environment variables on a container or add new environment variables to it with an environment override.

  • node_overrides (Optional[NodeOverrides], default: None ) –

    A list of node overrides in JSON format that specify the node range to target and the container overrides for that node range.

    This parameter isn't applicable to jobs that are running on Fargate resources; use containerOverrides instead.

  • retry_strategy (Optional[RetryStrategy], default: None ) –

    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.

  • propagate_tags (Optional[Boolean], default: None ) –

    Specifies whether to propagate the tags from the job or job definition to the corresponding Amazon ECS task. If no value is specified, the tags aren't propagated. Tags can only be propagated to the tasks during task creation. For tags with the same name, job tags are given priority over job definitions tags. If the total number of combined tags from the job and job definition is over 50, the job is moved to the FAILED state. When specified, this overrides the tag propagation setting in the job definition.

  • timeout (Optional[JobTimeout], default: None ) –

    The timeout configuration for this SubmitJob operation. You can specify a timeout duration after which Batch terminates your jobs if they haven't finished. If a job is terminated due to a timeout, it isn't retried. The minimum value for the timeout is 60 seconds. This configuration overrides any timeout configuration specified in the job definition. For array jobs, child jobs have the same timeout configuration as the parent job. For more information, see Job Timeouts in the Amazon Elastic Container Service Developer Guide.

  • tags (Optional[TagrisTagsMap], default: None ) –

    The tags that you apply to the job request to help you categorize and organize your resources. Each tag consists of a key and an optional value. For more information, see Tagging Amazon Web Services Resources in Amazon Web Services General Reference.

  • eks_properties_override (Optional[EksPropertiesOverride], default: None ) –

    An object, with properties that override defaults for the job definition, can only be specified for jobs that are run on Amazon EKS resources.

  • ecs_properties_override (Optional[EcsPropertiesOverride], default: None ) –

    An object, with properties that override defaults for the job definition, can only be specified for jobs that are run on Amazon ECS resources.

  • consumable_resource_properties_override (Optional[ConsumableResourceProperties], default: None ) –

    An object that contains overrides for the consumable resources of a job.

Raises:

  • ClientException –

    These errors are usually caused by a client action. One example cause is using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Another cause is specifying an identifier that's not valid.

  • ServerException –

    These errors are usually caused by a server issue.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

To submit a job to a queue This example submits a simple container job called example to the HighPriority job queue.

>>> await client.submit_job(job_name='example', job_queue='HighPriority', job_definition='sleep60')
Source code in docs_src/capo_batch/_services/async_batch.py
async def submit_job(
    self,
    *,
    config_overrides: Optional[AsyncBatchClientConfig] = None,
    job_name: Optional["capo_batch.types.string.String"] = None,
    job_queue: Optional["capo_batch.types.string.String"] = None,
    share_identifier: Optional["capo_batch.types.string.String"] = None,
    scheduling_priority_override: Optional[
        "capo_batch.types.integer.Integer"
    ] = None,
    array_properties: Optional[
        "capo_batch.types.array_properties.ArrayProperties"
    ] = None,
    depends_on: Optional[
        "capo_batch.types.job_dependency_list.JobDependencyList"
    ] = None,
    job_definition: Optional["capo_batch.types.string.String"] = None,
    parameters: Optional["capo_batch.types.parameters_map.ParametersMap"] = None,
    container_overrides: Optional[
        "capo_batch.types.container_overrides.ContainerOverrides"
    ] = None,
    node_overrides: Optional[
        "capo_batch.types.node_overrides.NodeOverrides"
    ] = None,
    retry_strategy: Optional[
        "capo_batch.types.retry_strategy.RetryStrategy"
    ] = None,
    propagate_tags: Optional["capo_batch.types.boolean.Boolean"] = None,
    timeout: Optional["capo_batch.types.job_timeout.JobTimeout"] = None,
    tags: Optional["capo_batch.types.tagris_tags_map.TagrisTagsMap"] = None,
    eks_properties_override: Optional[
        "capo_batch.types.eks_properties_override.EksPropertiesOverride"
    ] = None,
    ecs_properties_override: Optional[
        "capo_batch.types.ecs_properties_override.EcsPropertiesOverride"
    ] = None,
    consumable_resource_properties_override: Optional[
        "capo_batch.types.consumable_resource_properties.ConsumableResourceProperties"
    ] = None,
) -> "capo_batch.types.submit_job_response.SubmitJobResponse":
    """<p>Submits an Batch job from a job definition. Parameters that are specified during <a>SubmitJob</a> override parameters defined in the job definition. vCPU and memory requirements that are specified in the <code>resourceRequirements</code> objects in the job definition are the exception. They can't be overridden this way using the <code>memory</code> and <code>vcpus</code> parameters. Rather, you must specify updates to job definition parameters in a <code>resourceRequirements</code> object that's included in the <code>containerOverrides</code> parameter.</p> <note> <p>Job queues with a scheduling policy are limited to 500 active share identifiers at a time. </p> </note> <important> <p>Jobs that run on Fargate resources can't be guaranteed to run for more than 14 days. This is because, after 14 days, Fargate resources might become unavailable and job might be terminated.</p> </important>

    Args:
        job_name: <p>The name of the job. It can be up to 128 letters long. The first character must be alphanumeric, can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).</p>
        job_queue: <p>The job queue where the job is submitted. You can specify either the name or the Amazon Resource Name (ARN) of the queue.</p>
        share_identifier: <p>The share identifier for the job. Don't specify this parameter if the job queue doesn't have a fair-share scheduling policy. If the job queue has a fair-share scheduling policy, then this parameter must be specified.</p> <p>This string is limited to 255 alphanumeric characters, and can be followed by an asterisk (*).</p>
        scheduling_priority_override: <p>The scheduling priority for the job. This only affects jobs in job queues with a fair-share policy. Jobs with a higher scheduling priority are scheduled before jobs with a lower scheduling priority. This overrides any scheduling priority in the job definition and works only within a single share identifier.</p> <p>The minimum supported value is 0 and the maximum supported value is 9999.</p>
        array_properties: <p>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 <a href="https://docs.aws.amazon.com/batch/latest/userguide/array_jobs.html">Array Jobs</a> in the <i>Batch User Guide</i>.</p>
        depends_on: <p>A list of dependencies for the job. A job can depend upon a maximum of 20 jobs. You can specify a <code>SEQUENTIAL</code> 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 <code>N_TO_N</code> type dependency with a job ID for array jobs. In that case, each index child of this job must wait for the corresponding index child of each dependency to complete before it can begin.</p>
        job_definition: <p>The job definition used by this job. This value can be one of <code>definition-name</code>, <code>definition-name:revision</code>, or the Amazon Resource Name (ARN) for the job definition, with or without the revision (<code>arn:aws:batch:<i>region</i>:<i>account</i>:job-definition/<i>definition-name</i>:<i>revision</i> </code>, or <code>arn:aws:batch:<i>region</i>:<i>account</i>:job-definition/<i>definition-name</i> </code>).</p> <p>If the revision is not specified, then the latest active revision is used.</p>
        parameters: <p>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 <code>SubmitJob</code> request override any corresponding parameter defaults from the job definition.</p>
        container_overrides: <p>An object with properties that override the defaults for the job definition 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, which is specified in the job definition or the Docker image, with a <code>command</code> override. You can also override existing environment variables on a container or add new environment variables to it with an <code>environment</code> override.</p>
        node_overrides: <p>A list of node overrides in JSON format that specify the node range to target and the container overrides for that node range.</p> <note> <p>This parameter isn't applicable to jobs that are running on Fargate resources; use <code>containerOverrides</code> instead.</p> </note>
        retry_strategy: <p>The retry strategy to use for failed jobs from this <a>SubmitJob</a> operation. When a retry strategy is specified here, it overrides the retry strategy defined in the job definition.</p>
        propagate_tags: <p>Specifies whether to propagate the tags from the job or job definition to the corresponding Amazon ECS task. If no value is specified, the tags aren't propagated. Tags can only be propagated to the tasks during task creation. For tags with the same name, job tags are given priority over job definitions tags. If the total number of combined tags from the job and job definition is over 50, the job is moved to the <code>FAILED</code> state. When specified, this overrides the tag propagation setting in the job definition.</p>
        timeout: <p>The timeout configuration for this <a>SubmitJob</a> operation. You can specify a timeout duration after which Batch terminates your jobs if they haven't finished. If a job is terminated due to a timeout, it isn't retried. The minimum value for the timeout is 60 seconds. This configuration overrides any timeout configuration specified in the job definition. For array jobs, child jobs have the same timeout configuration as the parent job. For more information, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/job_timeouts.html">Job Timeouts</a> in the <i>Amazon Elastic Container Service Developer Guide</i>.</p>
        tags: <p>The tags that you apply to the job request to help you categorize and organize your resources. Each tag consists of a key and an optional value. For more information, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html">Tagging Amazon Web Services Resources</a> in <i>Amazon Web Services General Reference</i>.</p>
        eks_properties_override: <p>An object, with properties that override defaults for the job definition, can only be specified for jobs that are run on Amazon EKS resources.</p>
        ecs_properties_override: <p>An object, with properties that override defaults for the job definition, can only be specified for jobs that are run on Amazon ECS resources.</p>
        consumable_resource_properties_override: <p>An object that contains overrides for the consumable resources of a job.</p>

    Raises:
        capo_batch.errors.client_exception.ClientException: <p>These errors are usually caused by a client action. One example cause is using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Another cause is specifying an identifier that's not valid.</p>
        capo_batch.errors.server_exception.ServerException: <p>These errors are usually caused by a server issue.</p>
        capo_batch.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To submit a job to a queue
        This example submits a simple container job called example to the HighPriority job queue.

        >>> await client.submit_job(job_name='example', job_queue='HighPriority', job_definition='sleep60')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_batch.types.submit_job_request.SubmitJobRequest]",
    ) -> AsyncOperationResponse[
        "capo_batch.types.submit_job_response.SubmitJobResponse"
    ]:
        import capo_batch._operations.aws_batch_v20160810.submit_job

        (
            output,
            http_response,
        ) = await capo_batch._operations.aws_batch_v20160810.submit_job.async_submit_job(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("SubmitJob")
    )
    input_: capo_batch.types.submit_job_request.SubmitJobRequest = {}
    if job_name is not None:
        input_["job_name"] = job_name
    if job_queue is not None:
        input_["job_queue"] = job_queue
    if share_identifier is not None:
        input_["share_identifier"] = share_identifier
    if scheduling_priority_override is not None:
        input_["scheduling_priority_override"] = scheduling_priority_override
    if array_properties is not None:
        input_["array_properties"] = array_properties
    if depends_on is not None:
        input_["depends_on"] = depends_on
    if job_definition is not None:
        input_["job_definition"] = job_definition
    if parameters is not None:
        input_["parameters"] = parameters
    if container_overrides is not None:
        input_["container_overrides"] = container_overrides
    if node_overrides is not None:
        input_["node_overrides"] = node_overrides
    if retry_strategy is not None:
        input_["retry_strategy"] = retry_strategy
    if propagate_tags is not None:
        input_["propagate_tags"] = propagate_tags
    if timeout is not None:
        input_["timeout"] = timeout
    if tags is not None:
        input_["tags"] = tags
    if eks_properties_override is not None:
        input_["eks_properties_override"] = eks_properties_override
    if ecs_properties_override is not None:
        input_["ecs_properties_override"] = ecs_properties_override
    if consumable_resource_properties_override is not None:
        input_["consumable_resource_properties_override"] = (
            consumable_resource_properties_override
        )

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output