TaskOperations Class

TaskOperations operations.

You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute.

Inheritance
builtins.object
TaskOperations

Constructor

TaskOperations(client, config, serializer, deserializer)

Parameters

Name Description
client
Required

Client for service requests.

config
Required

Configuration of service client.

serializer
Required

An object model serializer.

deserializer
Required

An object model deserializer.

Variables

Name Description
api_version

The API version to use for the request. Constant value: "2024-02-01.19.0".

Methods

add

Adds a Task to the specified Job.

The maximum lifetime of a Task from addition to completion is 180 days. If a Task has not completed within 180 days of being added it will be terminated by the Batch service and left in whatever state it was in at that time.

add_collection

Adds a collection of tasks to the specified job.

Note that each task must have a unique ID. The Batch service may not return the results for each task in the same order the tasks were submitted in this request. If the server times out or the connection is closed during the request, the request may have been partially or fully processed, or not at all. In such cases, the user should re-issue the request. Note that it is up to the user to correctly handle failures when re-issuing a request. For example, you should use the same task IDs during a retry so that if the prior operation succeeded, the retry will not create extra tasks unexpectedly. If the response contains any tasks which failed to add, a client can retry the request. In a retry, it is most efficient to resubmit only tasks that failed to add, and to omit tasks that were successfully added on the first attempt. The maximum lifetime of a task from addition to completion is 180 days. If a task has not completed within 180 days of being added it will be terminated by the Batch service and left in whatever state it was in at that time.

delete

Deletes a Task from the specified Job.

When a Task is deleted, all of the files in its directory on the Compute Node where it ran are also deleted (regardless of the retention time). For multi-instance Tasks, the delete Task operation applies synchronously to the primary task; subtasks and their files are then deleted asynchronously in the background.

get

Gets information about the specified Task.

For multi-instance Tasks, information such as affinityId, executionInfo and nodeInfo refer to the primary Task. Use the list subtasks API to retrieve information about subtasks.

list

Lists all of the Tasks that are associated with the specified Job.

For multi-instance Tasks, information such as affinityId, executionInfo and nodeInfo refer to the primary Task. Use the list subtasks API to retrieve information about subtasks.

list_subtasks

Lists all of the subtasks that are associated with the specified multi-instance Task.

If the Task is not a multi-instance Task then this returns an empty collection.

reactivate

Reactivates a Task, allowing it to run again even if its retry count has been exhausted.

Reactivation makes a Task eligible to be retried again up to its maximum retry count. The Task's state is changed to active. As the Task is no longer in the completed state, any previous exit code or failure information is no longer available after reactivation. Each time a Task is reactivated, its retry count is reset to 0. Reactivation will fail for Tasks that are not completed or that previously completed successfully (with an exit code of 0). Additionally, it will fail if the Job has completed (or is terminating or deleting).

terminate

Terminates the specified Task.

When the Task has been terminated, it moves to the completed state. For multi-instance Tasks, the terminate Task operation applies synchronously to the primary task; subtasks are then terminated asynchronously in the background.

update

Updates the properties of the specified Task.

add

Adds a Task to the specified Job.

The maximum lifetime of a Task from addition to completion is 180 days. If a Task has not completed within 180 days of being added it will be terminated by the Batch service and left in whatever state it was in at that time.

add(job_id, task, task_add_options=None, custom_headers=None, raw=False, **operation_config)

Parameters

Name Description
job_id
Required
str

The ID of the Job to which the Task is to be added.

task
Required

The Task to be added.

task_add_options

Additional parameters for the operation

default value: None
custom_headers

headers that will be added to the request

default value: None
raw

returns the direct response alongside the deserialized response

default value: False
operation_config
Required

Operation configuration overrides.

Returns

Type Description
None,
<xref:msrest.pipeline.ClientRawResponse>

None or ClientRawResponse if raw=true

Exceptions

Type Description

add_collection

Adds a collection of tasks to the specified job.

Note that each task must have a unique ID. The Batch service may not return the results for each task in the same order the tasks were submitted in this request. If the server times out or the connection is closed during the request, the request may have been partially or fully processed, or not at all. In such cases, the user should re-issue the request. Note that it is up to the user to correctly handle failures when re-issuing a request. For example, you should use the same task IDs during a retry so that if the prior operation succeeded, the retry will not create extra tasks unexpectedly. If the response contains any tasks which failed to add, a client can retry the request. In a retry, it is most efficient to resubmit only tasks that failed to add, and to omit tasks that were successfully added on the first attempt. The maximum lifetime of a task from addition to completion is 180 days. If a task has not completed within 180 days of being added it will be terminated by the Batch service and left in whatever state it was in at that time.

add_collection(job_id, value, task_add_collection_options=None, custom_headers=None, raw=False, threads=0, **operation_config)

Parameters

Name Description
job_id
Required
str

The ID of the job to which the task collection is to be added.

value
Required

The collection of tasks to add. The total serialized size of this collection must be less than 4MB. If it is greater than 4MB (for example if each task has 100's of resource files or environment variables), the request will fail with code 'RequestBodyTooLarge' and should be retried again with fewer tasks.

task_add_collection_options

Additional parameters for the operation

default value: None
custom_headers

headers that will be added to the request

default value: None
raw

returns the direct response alongside the deserialized response

default value: False
threads
int

number of threads to use in parallel when adding tasks. If specified and greater than 0, will start additional threads to submit requests and wait for them to finish. Otherwise will submit add_collection requests sequentially on main thread

default value: 0

Returns

Type Description
<xref:msrest.pipeline.ClientRawResponse>

TaskAddCollectionResult or <xref:msrest.pipeline.ClientRawResponse> if raw=true

Exceptions

Type Description
azure.batch.custom.CreateTasksErrorException

delete

Deletes a Task from the specified Job.

When a Task is deleted, all of the files in its directory on the Compute Node where it ran are also deleted (regardless of the retention time). For multi-instance Tasks, the delete Task operation applies synchronously to the primary task; subtasks and their files are then deleted asynchronously in the background.

delete(job_id, task_id, task_delete_options=None, custom_headers=None, raw=False, **operation_config)

Parameters

Name Description
job_id
Required
str

The ID of the Job from which to delete the Task.

task_id
Required
str

The ID of the Task to delete.

task_delete_options

Additional parameters for the operation

default value: None
custom_headers

headers that will be added to the request

default value: None
raw

returns the direct response alongside the deserialized response

default value: False
operation_config
Required

Operation configuration overrides.

Returns

Type Description
None,
<xref:msrest.pipeline.ClientRawResponse>

None or ClientRawResponse if raw=true

Exceptions

Type Description

get

Gets information about the specified Task.

For multi-instance Tasks, information such as affinityId, executionInfo and nodeInfo refer to the primary Task. Use the list subtasks API to retrieve information about subtasks.

get(job_id, task_id, task_get_options=None, custom_headers=None, raw=False, **operation_config)

Parameters

Name Description
job_id
Required
str

The ID of the Job that contains the Task.

task_id
Required
str

The ID of the Task to get information about.

task_get_options

Additional parameters for the operation

default value: None
custom_headers

headers that will be added to the request

default value: None
raw

returns the direct response alongside the deserialized response

default value: False
operation_config
Required

Operation configuration overrides.

Returns

Type Description
<xref:msrest.pipeline.ClientRawResponse>

CloudTask or ClientRawResponse if raw=true

Exceptions

Type Description

list

Lists all of the Tasks that are associated with the specified Job.

For multi-instance Tasks, information such as affinityId, executionInfo and nodeInfo refer to the primary Task. Use the list subtasks API to retrieve information about subtasks.

list(job_id, task_list_options=None, custom_headers=None, raw=False, **operation_config)

Parameters

Name Description
job_id
Required
str

The ID of the Job.

task_list_options

Additional parameters for the operation

default value: None
custom_headers

headers that will be added to the request

default value: None
raw

returns the direct response alongside the deserialized response

default value: False
operation_config
Required

Operation configuration overrides.

Returns

Type Description

An iterator like instance of CloudTask

Exceptions

Type Description

list_subtasks

Lists all of the subtasks that are associated with the specified multi-instance Task.

If the Task is not a multi-instance Task then this returns an empty collection.

list_subtasks(job_id, task_id, task_list_subtasks_options=None, custom_headers=None, raw=False, **operation_config)

Parameters

Name Description
job_id
Required
str

The ID of the Job.

task_id
Required
str

The ID of the Task.

task_list_subtasks_options

Additional parameters for the operation

default value: None
custom_headers

headers that will be added to the request

default value: None
raw

returns the direct response alongside the deserialized response

default value: False
operation_config
Required

Operation configuration overrides.

Returns

Type Description
<xref:msrest.pipeline.ClientRawResponse>

CloudTaskListSubtasksResult or ClientRawResponse if raw=true

Exceptions

Type Description

reactivate

Reactivates a Task, allowing it to run again even if its retry count has been exhausted.

Reactivation makes a Task eligible to be retried again up to its maximum retry count. The Task's state is changed to active. As the Task is no longer in the completed state, any previous exit code or failure information is no longer available after reactivation. Each time a Task is reactivated, its retry count is reset to 0. Reactivation will fail for Tasks that are not completed or that previously completed successfully (with an exit code of 0). Additionally, it will fail if the Job has completed (or is terminating or deleting).

reactivate(job_id, task_id, task_reactivate_options=None, custom_headers=None, raw=False, **operation_config)

Parameters

Name Description
job_id
Required
str

The ID of the Job containing the Task.

task_id
Required
str

The ID of the Task to reactivate.

task_reactivate_options

Additional parameters for the operation

default value: None
custom_headers

headers that will be added to the request

default value: None
raw

returns the direct response alongside the deserialized response

default value: False
operation_config
Required

Operation configuration overrides.

Returns

Type Description
None,
<xref:msrest.pipeline.ClientRawResponse>

None or ClientRawResponse if raw=true

Exceptions

Type Description

terminate

Terminates the specified Task.

When the Task has been terminated, it moves to the completed state. For multi-instance Tasks, the terminate Task operation applies synchronously to the primary task; subtasks are then terminated asynchronously in the background.

terminate(job_id, task_id, task_terminate_options=None, custom_headers=None, raw=False, **operation_config)

Parameters

Name Description
job_id
Required
str

The ID of the Job containing the Task.

task_id
Required
str

The ID of the Task to terminate.

task_terminate_options

Additional parameters for the operation

default value: None
custom_headers

headers that will be added to the request

default value: None
raw

returns the direct response alongside the deserialized response

default value: False
operation_config
Required

Operation configuration overrides.

Returns

Type Description
None,
<xref:msrest.pipeline.ClientRawResponse>

None or ClientRawResponse if raw=true

Exceptions

Type Description

update

Updates the properties of the specified Task.

update(job_id, task_id, constraints=None, task_update_options=None, custom_headers=None, raw=False, **operation_config)

Parameters

Name Description
job_id
Required
str

The ID of the Job containing the Task.

task_id
Required
str

The ID of the Task to update.

constraints

Constraints that apply to this Task. If omitted, the Task is given the default constraints. For multi-instance Tasks, updating the retention time applies only to the primary Task and not subtasks.

default value: None
task_update_options

Additional parameters for the operation

default value: None
custom_headers

headers that will be added to the request

default value: None
raw

returns the direct response alongside the deserialized response

default value: False
operation_config
Required

Operation configuration overrides.

Returns

Type Description
None,
<xref:msrest.pipeline.ClientRawResponse>

None or ClientRawResponse if raw=true

Exceptions

Type Description

Attributes

models

models = <module 'azure.batch.models' from 'C:\\hostedtoolcache\\windows\\Python\\3.11.9\\x64\\Lib\\site-packages\\azure\\batch\\models\\__init__.py'>