class_docstr: Make async prediction requests to an Amazon SageMaker endpoint.
class_docstr_tok: ["Make","async","prediction","requests","to","an","Amazon","SageMaker","endpoint","."]
docstr: Check the Amazon S3 output path for the output.
  
  This method waits for either the output file or the failure file to be found on the
  specified S3 output path. Whichever file is found first, its corresponding event is
  triggered, and the method executes the appropriate action based on the event.
  
  Args:
      output_path (str): The S3 path where the output file is expected to be found.
      failure_path (str): The S3 path where the failure file is expected to be found.
      waiter_config (boto3.waiter.WaiterConfig): The configuration for the S3 waiter.
  
  Returns:
      Any: The deserialized result from the output file, if the output file is found first.
      Otherwise, raises an exception.
  
  Raises:
      AsyncInferenceModelError: If the failure file is found before the output file.
      PollingTimeoutError: If both files are not found and the S3 waiter
       has thrown a WaiterError.
docstr_tok: ["Check","the","Amazon","S3","output","path","for","the","output",".","This","method","waits","for","either","the","output","file","or","the","failure","file","to","be","found","on","the","specified","S3","output","path",".","Whichever","file","is","found","first",",","its","corresponding","event","is","triggered",",","and","the","method","executes","the","appropriate","action","based","on","the","event",".","Args",":","output_path","(","str",")",":","The","S3","path","where","the","output","file","is","expected","to","be","found",".","failure_path","(","str",")",":","The","S3","path","where","the","failure","file","is","expected","to","be","found",".","waiter_config","(","boto3.waiter.WaiterConfig",")",":","The","configuration","for","the","S3","waiter",".","Returns",":","Any",":","The","deserialized","result","from","the","output","file",",","if","the","output","file","is","found","first",".","Otherwise",",","raises","an","exception",".","Raises",":","AsyncInferenceModelError",":","If","the","failure","file","is","found","before","the","output","file",".","PollingTimeoutError",":","If","both","files","are","not","found","and","the","S3","waiter","has","thrown","a","WaiterError","."]
code: def _check_output_and_failure_paths(
      self, output_path, failure_path, waiter_config
  ):
      """Check the Amazon S3 output path for the output.
  
      This method waits for either the output file or the failure file to be found on the
      specified S3 output path. Whichever file is found first, its corresponding event is
      triggered, and the method executes the appropriate action based on the event.
  
      Args:
          output_path (str): The S3 path where the output file is expected to be found.
          failure_path (str): The S3 path where the failure file is expected to be found.
          waiter_config (boto3.waiter.WaiterConfig): The configuration for the S3 waiter.
  
      Returns:
          Any: The deserialized result from the output file, if the output file is found first.
          Otherwise, raises an exception.
  
      Raises:
          AsyncInferenceModelError: If the failure file is found before the output file.
          PollingTimeoutError: If both files are not found and the S3 waiter
           has thrown a WaiterError.
      """
      output_bucket, output_key = parse_s3_url(output_path)
      failure_bucket, failure_key = parse_s3_url(failure_path)
  
      output_file_found = threading.Event()
      failure_file_found = threading.Event()
  
      def check_output_file():
          try:
              output_file_waiter = self.s3_client.get_waiter(
                  "object_exists"
              )
              output_file_waiter.wait(
                  Bucket=output_bucket,
                  Key=output_key,
                  WaiterConfig=waiter_config._to_request_dict(),
              )
              output_file_found.set()
          except WaiterError:
              pass
  
      def check_failure_file():
          try:
              failure_file_waiter = self.s3_client.get_waiter(
                  "object_exists"
              )
              failure_file_waiter.wait(
                  Bucket=failure_bucket,
                  Key=failure_key,
                  WaiterConfig=waiter_config._to_request_dict(),
              )
              failure_file_found.set()
          except WaiterError:
              pass
  
      output_thread = threading.Thread(target=check_output_file)
      failure_thread = threading.Thread(target=check_failure_file)
  
      output_thread.start()
      failure_thread.start()
  
      while (
          not output_file_found.is_set()
          and not failure_file_found.is_set()
      ):
          time.sleep(1)
  
      if output_file_found.is_set():
          s3_object = self.s3_client.get_object(
              Bucket=output_bucket, Key=output_key
          )
          result = self.predictor._handle_response(response=s3_object)
          return result
  
      failure_object = self.s3_client.get_object(
          Bucket=failure_bucket, Key=failure_key
      )
      failure_response = self.predictor._handle_response(
          response=failure_object
      )
  
      raise AsyncInferenceModelError(
          message=failure_response
      ) if failure_file_found.is_set() else PollingTimeoutError(
          message="Inference could still be running",
          output_path=output_path,
          seconds=waiter_config.delay * waiter_config.max_attempts,
      )
  
imports: from __future__ import absolute_import
  import threading
  import time
  import uuid
  from botocore.exceptions import WaiterError
  from sagemaker import s3
  from sagemaker.exceptions import PollingTimeoutError, AsyncInferenceModelError
  from sagemaker.async_inference import WaiterConfig, AsyncInferenceResponse
  from sagemaker.s3 import parse_s3_url
  from sagemaker.session import Session
  from sagemaker.utils import name_from_base, sagemaker_timestamp, format_tags
label_desc: Use image node_id 9 for calling the AsyncPredictor obj's underlying member method code with example usage: obj._check_output_and_failure_paths(output_path, failure_path, waiter_config) and returns: result