class_docstr: Hook for Azure Batch APIs.
  
  :param azure_batch_conn_id: :ref:`Azure Batch connection id<howto/connection:azure_batch>`
      of a service principal which will be used to start the container instance.
class_docstr_tok: ["Hook","for","Azure","Batch","APIs",".",":","param","azure_batch_conn_id",":",":","ref",":","`","Azure","Batch","connection","id","<","howto\/connection",":","azure_batch",">","`","of","a","service","principal","which","will","be","used","to","start","the","container","instance","."]
docstr: Wait for tasks in a particular job to complete.
  
  :param job_id: A string that identifies the job
  :param timeout: The amount of time to wait before timing out in minutes
docstr_tok: ["Wait","for","tasks","in","a","particular","job","to","complete",".",":","param","job_id",":","A","string","that","identifies","the","job",":","param","timeout",":","The","amount","of","time","to","wait","before","timing","out","in","minutes"]
code: def wait_for_job_tasks_to_complete(
      self, job_id: str, timeout: int
  ) -> list[batch_models.CloudTask]:
      """
      Wait for tasks in a particular job to complete.
  
      :param job_id: A string that identifies the job
      :param timeout: The amount of time to wait before timing out in minutes
      """
      timeout_time = timezone.utcnow() + timedelta(minutes=timeout)
      while timezone.utcnow() < timeout_time:
          tasks = list(self.connection.task.list(job_id))
  
          incomplete_tasks = [
              task
              for task in tasks
              if task.state != batch_models.TaskState.completed
          ]
          if not incomplete_tasks:
              # detect if any task in job has failed
              fail_tasks = [
                  task
                  for task in tasks
                  if task.execution_info.result
                  == batch_models.TaskExecutionResult.failure
              ]
              return fail_tasks
          for task in incomplete_tasks:
              self.log.info(
                  "Waiting for %s to complete, currently on %s state",
                  task.id,
                  task.state,
              )
          time.sleep(15)
      raise TimeoutError("Timed out waiting for tasks to complete")
  
imports: from __future__ import annotations
  import time
  from datetime import timedelta
  from functools import cached_property
  from typing import TYPE_CHECKING, Any
  from azure.batch import BatchServiceClient, batch_auth, models
  from airflow.exceptions import AirflowException
  from airflow.hooks.base import BaseHook
  from airflow.providers.microsoft.azure.utils import AzureIdentityCredentialAdapter, add_managed_identity_connection_widgets, get_field
  from airflow.utils import timezone
label_desc: Use image node_id 15 for calling the AzureBatchHook obj's underlying member method code with example usage: obj.wait_for_job_tasks_to_complete(job_id, timeout) and returns: fail_tasks