Send an RPC request to the Servomatic prediction service.

  Args:
    examples: A list of examples that matches the model spec.
    serving_bundle: A `ServingBundle` object that contains the information to
      make the serving request.

  Returns:
    A ClassificationResponse or RegressionResponse proto.

def call_servo(examples, serving_bundle):
  """Send an RPC request to the Servomatic prediction service.

  Args:
    examples: A list of examples that matches the model spec.
    serving_bundle: A `ServingBundle` object that contains the information to
      make the serving request.

  Returns:
    A ClassificationResponse or RegressionResponse proto.
  """
  parsed_url = urlparse('http://' + serving_bundle.inference_address)
  channel = implementations.insecure_channel(parsed_url.hostname,
                                             parsed_url.port)
  stub = prediction_service_pb2.beta_create_PredictionService_stub(channel)

  if serving_bundle.use_predict:
    request = predict_pb2.PredictRequest()
  elif serving_bundle.model_type == 'classification':
    request = classification_pb2.ClassificationRequest()
  else:
    request = regression_pb2.RegressionRequest()
  request.model_spec.name = serving_bundle.model_name
  if serving_bundle.model_version is not None:
    request.model_spec.version.value = serving_bundle.model_version
  if serving_bundle.signature is not None:
    request.model_spec.signature_name = serving_bundle.signature

  if serving_bundle.use_predict:
    # tf.compat.v1 API used here to convert tf.example into proto. This
    # utility file is bundled in the witwidget pip package which has a dep
    # on TensorFlow.
    request.inputs[serving_bundle.predict_input_tensor].CopyFrom(
      tf.compat.v1.make_tensor_proto(
        values=[ex.SerializeToString() for ex in examples],
        dtype=types_pb2.DT_STRING))
  else:
    request.input.example_list.examples.extend(examples)

  if serving_bundle.use_predict:
    return common_utils.convert_predict_response(
      stub.Predict(request, 30.0), serving_bundle) # 30 secs timeout
  elif serving_bundle.model_type == 'classification':
    return stub.Classify(request, 30.0)  # 30 secs timeout
  else:
    return stub.Regress(request, 30.0)