TaskOperations class

Definition

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.

TaskOperations(client, config, serializer, deserializer)
Inheritance
builtins.object
TaskOperations

Parameters

client

Client for service requests.

config

Configuration of service client.

serializer

An object model serializer.

deserializer

An object model deserializer.

Variables

api_version
class
Client API Version. Constant value: "2019-08-01.10.0".

Methods

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

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(job_id, value, task_add_collection_options=None, custom_headers=None, raw=False, threads=0, **operation_config)

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(job_id, task_id, task_delete_options=None, custom_headers=None, raw=False, **operation_config)

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(job_id, task_id, task_get_options=None, custom_headers=None, raw=False, **operation_config)

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(job_id, task_list_options=None, custom_headers=None, raw=False, **operation_config)

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(job_id, task_id, task_list_subtasks_options=None, custom_headers=None, raw=False, **operation_config)

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(job_id, task_id, task_reactivate_options=None, custom_headers=None, raw=False, **operation_config)

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(job_id, task_id, task_terminate_options=None, custom_headers=None, raw=False, **operation_config)

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(job_id, task_id, constraints=None, task_update_options=None, custom_headers=None, raw=False, **operation_config)

Updates the properties of the specified Task.

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

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

job_id
str

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

task
TaskAddParameter

The Task to be added.

task_add_options
TaskAddOptions

Additional parameters for the operation

default value: None
custom_headers
dict

headers that will be added to the request

default value: None
raw
bool

returns the direct response alongside the deserialized response

default value: False
operation_config

Operation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

Exceptions

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

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

job_id
str

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

value
list of azure.batch.models.TaskAddParameter

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
TaskAddCollectionOptions

Additional parameters for the operation

default value: None
custom_headers
dict

headers that will be added to the request

default value: None
raw
bool

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

TaskAddCollectionResult or ClientRawResponse if raw=true

Return type

<xref:azure.batch.models.TaskAddCollectionResult>
<xref:msrest.pipeline.ClientRawResponse>

Exceptions

azure.batch.custom.CreateTasksErrorException

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

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

job_id
str

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

task_id
str

The ID of the Task to delete.

task_delete_options
TaskDeleteOptions

Additional parameters for the operation

default value: None
custom_headers
dict

headers that will be added to the request

default value: None
raw
bool

returns the direct response alongside the deserialized response

default value: False
operation_config

Operation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

Exceptions

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

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

job_id
str

The ID of the Job that contains the Task.

task_id
str

The ID of the Task to get information about.

task_get_options
TaskGetOptions

Additional parameters for the operation

default value: None
custom_headers
dict

headers that will be added to the request

default value: None
raw
bool

returns the direct response alongside the deserialized response

default value: False
operation_config

Operation configuration overrides.

Returns

CloudTask or ClientRawResponse if raw=true

Return type

Exceptions

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

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

job_id
str

The ID of the Job.

task_list_options
TaskListOptions

Additional parameters for the operation

default value: None
custom_headers
dict

headers that will be added to the request

default value: None
raw
bool

returns the direct response alongside the deserialized response

default value: False
operation_config

Operation configuration overrides.

Returns

An iterator like instance of CloudTask

Return type

Exceptions

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

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

job_id
str

The ID of the Job.

task_id
str

The ID of the Task.

task_list_subtasks_options
TaskListSubtasksOptions

Additional parameters for the operation

default value: None
custom_headers
dict

headers that will be added to the request

default value: None
raw
bool

returns the direct response alongside the deserialized response

default value: False
operation_config

Operation configuration overrides.

Returns

CloudTaskListSubtasksResult or ClientRawResponse if raw=true

Return type

Exceptions

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

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

job_id
str

The ID of the Job containing the Task.

task_id
str

The ID of the Task to reactivate.

task_reactivate_options
TaskReactivateOptions

Additional parameters for the operation

default value: None
custom_headers
dict

headers that will be added to the request

default value: None
raw
bool

returns the direct response alongside the deserialized response

default value: False
operation_config

Operation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

Exceptions

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

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

job_id
str

The ID of the Job containing the Task.

task_id
str

The ID of the Task to terminate.

task_terminate_options
TaskTerminateOptions

Additional parameters for the operation

default value: None
custom_headers
dict

headers that will be added to the request

default value: None
raw
bool

returns the direct response alongside the deserialized response

default value: False
operation_config

Operation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

Exceptions

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

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

job_id
str

The ID of the Job containing the Task.

task_id
str

The ID of the Task to update.

constraints
TaskConstraints

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
TaskUpdateOptions

Additional parameters for the operation

default value: None
custom_headers
dict

headers that will be added to the request

default value: None
raw
bool

returns the direct response alongside the deserialized response

default value: False
operation_config

Operation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

Exceptions

Attributes

models

models = <module 'azure.batch.models' from 'c:\\hostedtoolcache\\windows\\python\\3.6.8\\x64\\lib\\site-packages\\azure\\batch\\models\\__init__.py'>