class_docstr: Container builder that uses Google cloud build.
class_docstr_tok: ["Container","builder","that","uses","Google","cloud","build","."]
docstr: Builds, publishes and returns a Docker image.
  
  Args:
      max_status_check_attempts: Maximum number of times allowed to check
          build status. Applicable only to cloud container builder.
      delay_between_status_checks: Time is seconds to wait between status
          checks.
  Returns:
      URI in a registory where the Docker image has been built and pushed.
docstr_tok: ["Builds",",","publishes","and","returns","a","Docker","image",".","Args",":","max_status_check_attempts",":","Maximum","number","of","times","allowed","to","check","build","status",".","Applicable","only","to","cloud","container","builder",".","delay_between_status_checks",":","Time","is","seconds","to","wait","between","status","checks",".","Returns",":","URI","in","a","registory","where","the","Docker","image","has","been","built","and","pushed","."]
code: def get_docker_image(
      self, max_status_check_attempts=40, delay_between_status_checks=30
  ):
      """Builds, publishes and returns a Docker image.
  
      Args:
          max_status_check_attempts: Maximum number of times allowed to check
              build status. Applicable only to cloud container builder.
          delay_between_status_checks: Time is seconds to wait between status
              checks.
      Returns:
          URI in a registory where the Docker image has been built and pushed.
      """
      self._get_tar_file_path()
      storage_object_name = self._upload_tar_to_gcs()
      # Use the given Docker image name, if available.
      if self.docker_config:
          image_uri = self.docker_config.image
      else:
          image_uri = None
      image_uri = image_uri or generate_image_uri()
  
      logger.info(
          "Building and publishing Docker image using Google Cloud Build: %s",
          image_uri,
      )
      build_service = discovery.build(
          "cloudbuild",
          "v1",
          cache_discovery=False,
          requestBuilder=google_api_client.TFCloudHttpRequest,
      )
      request_dict = self._create_cloud_build_request_dict(
          image_uri,
          storage_object_name,
          max_status_check_attempts * delay_between_status_checks,
      )
  
      try:
          # Call to queue request to build and push Docker image.
          print(
              "Submitting Docker build and push request to Cloud Build."
          )
          print("Please access your Cloud Build job information here:")
          print("https://console.cloud.google.com/cloud-build/builds")
          create_response = (
              build_service.projects()
              .builds()
              .create(projectId=self.project_id, body=request_dict)
              .execute()
          )
  
          # `create` returns a long-running `Operation`.
          # https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/operations#Operation  # pylint: disable=line-too-long
          # This contains the build id, which we can use to get the status.
  
          attempts = 1
          while attempts <= max_status_check_attempts:
              # Call to check on the status of the queued request.
              get_response = (
                  build_service.projects()
                  .builds()
                  .get(
                      projectId=self.project_id,
                      id=create_response["metadata"]["build"]["id"],
                  )
                  .execute()
              )
  
              # `get` response is a `Build` object which contains `Status`.
              # https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#Build.Status    # pylint: disable=line-too-long
              status = get_response["status"]
              if status != "WORKING" and status != "QUEUED":
                  break
  
              attempts += 1
              # Wait for 30 seconds before we check on status again.
              print(
                  "Waiting for Cloud Build, checking status in 30 seconds."
              )
              time.sleep(delay_between_status_checks)
          if status != "SUCCESS":
              raise RuntimeError(
                  "There was an error executing the cloud build job. "
                  "Job status: " + status
              )
  
      except errors.HttpError as err:
          raise RuntimeError(
              "There was an error submitting the cloud build job. ", err
          )
      return image_uri
  
imports: import logging
  import os
  import sys
  import tarfile
  import tempfile
  import time
  import uuid
  import warnings
  from .None import gcp
  from .None import machine_config
  import docker
  from google.cloud import storage
  from google.cloud.exceptions import NotFound
  from googleapiclient import discovery
  from googleapiclient import errors
  import requests
  from ..utils import google_api_client
  from ..utils import tf_utils
label_desc: Use image node_id 1 for calling the CloudContainerBuilder obj's underlying member method code with example usage: obj.get_docker_image(max_status_check_attempts, delay_between_status_checks) and returns: image_uri