register_job_definition
async
¶
register_job_definition(
*,
config_overrides: Optional[AsyncBatchClientConfig] = None,
job_definition_name: Optional[String] = None,
type: Optional[JobDefinitionType] = None,
parameters: Optional[ParametersMap] = None,
scheduling_priority: Optional[Integer] = None,
container_properties: Optional[ContainerProperties] = None,
node_properties: Optional[NodeProperties] = None,
retry_strategy: Optional[RetryStrategy] = None,
propagate_tags: Optional[Boolean] = None,
timeout: Optional[JobTimeout] = None,
tags: Optional[TagrisTagsMap] = None,
platform_capabilities: Optional[PlatformCapabilityList] = None,
eks_properties: Optional[EksProperties] = None,
ecs_properties: Optional[EcsProperties] = None,
consumable_resource_properties: Optional[ConsumableResourceProperties] = None,
) -> RegisterJobDefinitionResponse
Registers an Batch job definition.
Parameters:
-
job_definition_name(Optional[String], default:None) –The name of the job definition to register. It can be up to 128 letters long. It can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).
-
type(Optional[JobDefinitionType], default:None) –The type of job definition. For more information about multi-node parallel jobs, see Creating a multi-node parallel job definition in the Batch User Guide.
-
If the value is
container, then one of the following is required:containerProperties,ecsProperties, oreksProperties. -
If the value is
multinode, thennodePropertiesis required.
If the job is run on Fargate resources, then
multinodeisn't supported. -
-
parameters(Optional[ParametersMap], default:None) –Default parameter substitution placeholders to set in the job definition. Parameters are specified as a key-value pair mapping. Parameters in a
SubmitJobrequest override any corresponding parameter defaults from the job definition. -
scheduling_priority(Optional[Integer], default:None) –The scheduling priority for jobs that are submitted with this job definition. 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.
The minimum supported value is 0 and the maximum supported value is 9999.
-
container_properties(Optional[ContainerProperties], default:None) –An object with properties specific to Amazon ECS-based single-node container-based jobs. If the job definition's
typeparameter iscontainer, then you must specify eithercontainerPropertiesornodeProperties. This must not be specified for Amazon EKS-based job definitions.If the job runs on Fargate resources, then you must not specify
nodeProperties; use onlycontainerProperties. -
node_properties(Optional[NodeProperties], default:None) –An object with properties specific to multi-node parallel jobs. If you specify node properties for a job, it becomes a multi-node parallel job. For more information, see Multi-node Parallel Jobs in the Batch User Guide.
If the job runs on Fargate resources, then you must not specify
nodeProperties; usecontainerPropertiesinstead.If the job runs on Amazon EKS resources, then you must not specify
nodeProperties. -
retry_strategy(Optional[RetryStrategy], default:None) –The retry strategy to use for failed jobs that are submitted with this job definition. Any retry strategy that's specified during a SubmitJob operation overrides the retry strategy defined here. If a job is terminated due to a timeout, it isn't retried.
-
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 are not 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
FAILEDstate.If the job runs on Amazon EKS resources, then you must not specify
propagateTags. -
timeout(Optional[JobTimeout], default:None) –The timeout configuration for jobs that are submitted with this job definition, after which Batch terminates your jobs if they have not finished. If a job is terminated due to a timeout, it isn't retried. The minimum value for the timeout is 60 seconds. Any timeout configuration that's specified during a SubmitJob operation overrides the timeout configuration defined here. For more information, see Job Timeouts in the Batch User Guide.
-
tags(Optional[TagrisTagsMap], default:None) –The tags that you apply to the job definition 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 Batch User Guide.
-
platform_capabilities(Optional[PlatformCapabilityList], default:None) –The platform capabilities required by the job definition. If no value is specified, it defaults to
EC2. To run the job on Fargate resources, specifyFARGATE. To run the job on Amazon ECS Managed Instances, specifyMANAGED_INSTANCES.Jobs with the
MANAGED_INSTANCESplatform capability must useecsProperties(notcontainerProperties) and do not support multi-node parallel jobs.If the job runs on Amazon EKS resources, then you must not specify
platformCapabilities. -
eks_properties(Optional[EksProperties], default:None) –An object with properties that are specific to Amazon EKS-based jobs. This must not be specified for Amazon ECS based job definitions.
-
ecs_properties(Optional[EcsProperties], default:None) –An object with properties that are specific to Amazon ECS-based jobs. This must not be specified for Amazon EKS-based job definitions.
-
consumable_resource_properties(Optional[ConsumableResourceProperties], default:None) –Contains a list of consumable resources required by the 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:
RegisterJobDefinition with tags This demonstrates calling the RegisterJobDefinition action, including tags.
>>> await client.register_job_definition(job_definition_name='sleep30', type='container', container_properties={'image': 'busybox', 'command': ['sleep', '30'], 'resourceRequirements': [{'type': 'MEMORY', 'value': '128'}, {'type': 'VCPU', 'value': '1'}]}, tags={'Department': 'Engineering', 'User': 'JaneDoe'})
To register a GPU job definition on ECS Managed Instances
This example registers a job definition that requests GPU resources on ECS Managed Instances.
>>> await client.register_job_definition(job_definition_name='my-gpu-managed-instances-job-def', type='container', platform_capabilities=['MANAGED_INSTANCES'], ecs_properties={'taskProperties': [{'containers': [{'image': '123456789012.dkr.ecr.us-east-1.amazonaws.com/my-gpu-image:latest', 'name': 'main', 'command': ['nvidia-smi'], 'resourceRequirements': [{'type': 'VCPU', 'value': '4'}, {'type': 'MEMORY', 'value': '16384'}, {'type': 'GPU', 'value': '1'}]}], 'executionRoleArn': 'arn:aws:iam::123456789012:role/ecsTaskExecutionRole'}]})
To register a job definition
This example registers a job definition for a simple container job.
>>> await client.register_job_definition(container_properties={'image': 'busybox', 'command': ['sleep', '10'], 'resourceRequirements': [{'type': 'MEMORY', 'value': '128'}, {'type': 'VCPU', 'value': '1'}]}, type='container', job_definition_name='sleep10')
To register a job definition on ECS Managed Instances
This example registers a job definition that runs on ECS Managed Instances using ecsProperties with the MANAGED_INSTANCES platform capability.
>>> await client.register_job_definition(job_definition_name='my-managed-instances-job-def', type='container', platform_capabilities=['MANAGED_INSTANCES'], ecs_properties={'taskProperties': [{'containers': [{'image': 'public.ecr.aws/amazonlinux/amazonlinux:2023', 'name': 'main', 'command': ['echo', 'hello managed instances'], 'resourceRequirements': [{'type': 'VCPU', 'value': '1'}, {'type': 'MEMORY', 'value': '1024'}]}], 'executionRoleArn': 'arn:aws:iam::123456789012:role/ecsTaskExecutionRole'}]})
To register a multi-container job definition on ECS Managed Instances
This example registers a job definition with a main container and a sidecar logging container on ECS Managed Instances.
>>> await client.register_job_definition(job_definition_name='my-sidecar-managed-instances-job-def', type='container', platform_capabilities=['MANAGED_INSTANCES'], ecs_properties={'taskProperties': [{'containers': [{'image': 'public.ecr.aws/amazonlinux/amazonlinux:2023', 'name': 'main', 'command': ['echo', 'processing data'], 'essential': True, 'resourceRequirements': [{'type': 'VCPU', 'value': '2'}, {'type': 'MEMORY', 'value': '4096'}]}, {'image': 'public.ecr.aws/amazonlinux/amazonlinux:2023', 'name': 'sidecar', 'command': ['echo', 'logging sidecar'], 'essential': False, 'resourceRequirements': [{'type': 'VCPU', 'value': '1'}, {'type': 'MEMORY', 'value': '512'}]}], 'executionRoleArn': 'arn:aws:iam::123456789012:role/ecsTaskExecutionRole'}]})
Source code in docs_src/capo_batch/_services/async_batch.py
2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 | |