class_docstr: TFX infra validator executor.
class_docstr_tok: ["TFX","infra","validator","executor","."]
code: def _PrepareModelPath(
      self,
      model: types.Artifact,
      serving_spec: infra_validator_pb2.ServingSpec,
  ) -> str:
      model_path = path_utils.serving_model_path(
          model.uri, path_utils.is_old_model_artifact(model)
      )
      serving_binary = serving_spec.WhichOneof("serving_binary")
      if serving_binary == _TENSORFLOW_SERVING:
          # TensorFlow Serving requires model to be stored in its own directory
          # structure flavor. If current model_path does not conform to the flavor,
          # we need to make a copy to the temporary path.
          try:
              # Check whether current model_path conforms to the tensorflow serving
              # model path flavor. (Parsed without exception)
              tf_serving_flavor.parse_model_path(
                  model_path,
                  expected_model_name=serving_spec.model_name,
              )
          except ValueError:
              # Copy the model to comply with the tensorflow serving model path
              # flavor.
              temp_model_path = tf_serving_flavor.make_model_path(
                  model_base_path=self._get_tmp_dir(),
                  model_name=serving_spec.model_name,
                  version=int(time.time()),
              )
              io_utils.copy_dir(src=model_path, dst=temp_model_path)
              self._AddCleanup(io_utils.delete_dir, self._get_tmp_dir())
              return temp_model_path
  
      return model_path
  
imports: import contextlib
  import functools
  import os
  import signal
  import threading
  import time
  from typing import Any, Dict, List, Optional
  from absl import logging
  from tfx import types
  from tfx.components.infra_validator import error_types
  from tfx.components.infra_validator import request_builder
  from tfx.components.infra_validator import serving_bins
  from tfx.components.infra_validator import types
  from tfx.components.infra_validator.model_server_runners import kubernetes_runner
  from tfx.components.infra_validator.model_server_runners import local_docker_runner
  from tfx.dsl.components.base import base_executor
  from tfx.proto import infra_validator_pb2
  from tfx.types import artifact_utils
  from tfx.types import standard_component_specs
  from tfx.utils import io_utils
  from tfx.utils import path_utils
  from tfx.utils import proto_utils
  from tfx.utils.model_paths import tf_serving_flavor
  from tensorflow_serving.apis import classification_pb2
  from tensorflow_serving.apis import predict_pb2
  from tensorflow_serving.apis import prediction_log_pb2
  from tensorflow_serving.apis import regression_pb2
label_desc: Use image node_id 8 for calling the Executor obj's underlying member method code with example usage: obj._PrepareModelPath(model, serving_spec) and returns: model_path, temp_model_path