class_docstr: Hook for Google ML Engine APIs.
  
  All the methods in the hook where project_id is used must be called with
  keyword arguments rather than positional.
class_docstr_tok: ["Hook","for","Google","ML","Engine","APIs",".","All","the","methods","in","the","hook","where","project_id","is","used","must","be","called","with","keyword","arguments","rather","than","positional","."]
docstr: Cancels a MLEngine job.
  
  :param project_id: The Google Cloud project id within which MLEngine
      job will be cancelled. If set to None or missing, the default project_id from the Google Cloud
      connection is used.
  :param job_id: A unique id for the want-to-be cancelled Google MLEngine training job.
  
  :return: Empty dict if cancelled successfully
  :raises: googleapiclient.errors.HttpError
docstr_tok: ["Cancels","a","MLEngine","job",".",":","param","project_id",":","The","Google","Cloud","project","id","within","which","MLEngine","job","will","be","cancelled",".","If","set","to","None","or","missing",",","the","default","project_id","from","the","Google","Cloud","connection","is","used",".",":","param","job_id",":","A","unique","id","for","the","want-to-be","cancelled","Google","MLEngine","training","job",".",":","return",":","Empty","dict","if","cancelled","successfully",":","raises",":","googleapiclient.errors.HttpError"]
code: def cancel_job(
      self,
      job_id: str,
      project_id: str,
  ) -> dict:
      """
      Cancels a MLEngine job.
  
      :param project_id: The Google Cloud project id within which MLEngine
          job will be cancelled. If set to None or missing, the default project_id from the Google Cloud
          connection is used.
      :param job_id: A unique id for the want-to-be cancelled Google MLEngine training job.
  
      :return: Empty dict if cancelled successfully
      :raises: googleapiclient.errors.HttpError
      """
      hook = self.get_conn()
  
      request = (
          hook.projects()
          .jobs()
          .cancel(name=f"projects/{project_id}/jobs/{job_id}")
      )
  
      try:
          return request.execute(num_retries=self.num_retries)
      except HttpError as e:
          if e.resp.status == 404:
              self.log.error(
                  "Job with job_id %s does not exist. ", job_id
              )
              raise
          elif e.resp.status == 400:
              self.log.info(
                  "Job with job_id %s is already complete, cancellation aborted.",
                  job_id,
              )
              return {}
          else:
              self.log.error("Failed to cancel MLEngine job: %s", e)
              raise
  
imports: from __future__ import annotations
  import contextlib
  import logging
  import random
  import time
  from typing import TYPE_CHECKING, Callable
  from aiohttp import ClientSession
  from gcloud.aio.auth import AioSession, Token
  from googleapiclient.discovery import Resource, build
  from googleapiclient.errors import HttpError
  from airflow.exceptions import AirflowException
  from airflow.providers.google.common.hooks.base_google import GoogleBaseAsyncHook, GoogleBaseHook
  from airflow.version import version
label_desc: Use image node_id 5 for calling the MLEngineHook obj's underlying member method code with example usage: obj.cancel_job(job_id, project_id) and returns: request, dict