prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  KFServing Transformer does not work with onnxruntime and trtis model server
  /kind bug
  
  **What steps did you take and what happened:**
  Currently kfserving transformer does not work with onnxruntime and trtis model server due to following validation because their data plane do not support `instances` key in JSON.
  https://github.com/kubeflow/kfserving/blob/master/python/kfserving/kfserving/handlers/http.py#L24 
  
  
  
  **What did you expect to happen:**
  Before we get to V2 data plane with agreed protocol across model servers, we should relax this validation.
  
  **Anything else you would like to add:**
  [Miscellaneous information that will assist in solving the issue.]
  
  
  **Environment:**
  
  - Istio Version:
  - Knative Version:
  - KFServing Version: 0.2.2
  - Kubeflow version:
  - Minikube version:
  - Kubernetes version: (use `kubectl version`):
  - OS (e.g. from `/etc/os-release`):
  
  
  </issue>
  <code>
  [start of python/kfserving/kfserving/handlers/http.py]
  1 import tornado.web
  2 import json
  3 from typing import Dict
  4 from http import HTTPStatus
  5 from kfserving.kfmodel import KFModel
  6 
  7 
  8 class HTTPHandler(tornado.web.RequestHandler):
  9     def initialize(self, models: Dict[str, KFModel]):
  10         self.models = models # pylint:disable=attribute-defined-outside-init
  11 
  12     def get_model(self, name: str):
  13         if name not in self.models:
  14             raise tornado.web.HTTPError(
  15                 status_code=HTTPStatus.NOT_FOUND,
  16                 reason="Model with name %s does not exist." % name
  17             )
  18         model = self.models[name]
  19         if not model.ready:
  20             model.load()
  21         return model
  22 
  23     def validate(self, request):
  24         if "instances" not in request:
  25             raise tornado.web.HTTPError(
  26                 status_code=HTTPStatus.BAD_REQUEST,
  27                 reason="Expected key \"instances\" in request body"
  28             )
  29 
  30         if not isinstance(request["instances"], list):
  31             raise tornado.web.HTTPError(
  32                 status_code=HTTPStatus.BAD_REQUEST,
  33                 reason="Expected \"instances\" to be a list"
  34             )
  35         return request
  36 
  37 
  38 class PredictHandler(HTTPHandler):
  39     def post(self, name: str):
  40         model = self.get_model(name)
  41         try:
  42             body = json.loads(self.request.body)
  43         except json.decoder.JSONDecodeError as e:
  44             raise tornado.web.HTTPError(
  45                 status_code=HTTPStatus.BAD_REQUEST,
  46                 reason="Unrecognized request format: %s" % e
  47             )
  48         request = model.preprocess(body)
  49         request = self.validate(request)
  50         response = model.predict(request)
  51         response = model.postprocess(response)
  52         self.write(response)
  53 
  54 
  55 class ExplainHandler(HTTPHandler):
  56     def post(self, name: str):
  57         model = self.get_model(name)
  58         try:
  59             body = json.loads(self.request.body)
  60         except json.decoder.JSONDecodeError as e:
  61             raise tornado.web.HTTPError(
  62                 status_code=HTTPStatus.BAD_REQUEST,
  63                 reason="Unrecognized request format: %s" % e
  64             )
  65         request = model.preprocess(body)
  66         request = self.validate(request)
  67         response = model.explain(request)
  68         response = model.postprocess(response)
  69         self.write(response)
  70
  [end of python/kfserving/kfserving/handlers/http.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/python/kfserving/kfserving/handlers/http.py b/python/kfserving/kfserving/handlers/http.py
  --- a/python/kfserving/kfserving/handlers/http.py
  +++ b/python/kfserving/kfserving/handlers/http.py
  @@ -21,13 +21,7 @@
           return model
   
       def validate(self, request):
  -        if "instances" not in request:
  -            raise tornado.web.HTTPError(
  -                status_code=HTTPStatus.BAD_REQUEST,
  -                reason="Expected key \"instances\" in request body"
  -            )
  -
  -        if not isinstance(request["instances"], list):
  +        if "instances" in request and not isinstance(request["instances"], list):
               raise tornado.web.HTTPError(
                   status_code=HTTPStatus.BAD_REQUEST,
                   reason="Expected \"instances\" to be a list"
  
verification_info: {"golden_diff": "diff --git a/python/kfserving/kfserving/handlers/http.py b/python/kfserving/kfserving/handlers/http.py\n--- a/python/kfserving/kfserving/handlers/http.py\n+++ b/python/kfserving/kfserving/handlers/http.py\n@@ -21,13 +21,7 @@\n         return model\n \n     def validate(self, request):\n-        if \"instances\" not in request:\n-            raise tornado.web.HTTPError(\n-                status_code=HTTPStatus.BAD_REQUEST,\n-                reason=\"Expected key \\\"instances\\\" in request body\"\n-            )\n-\n-        if not isinstance(request[\"instances\"], list):\n+        if \"instances\" in request and not isinstance(request[\"instances\"], list):\n             raise tornado.web.HTTPError(\n                 status_code=HTTPStatus.BAD_REQUEST,\n                 reason=\"Expected \\\"instances\\\" to be a list\"\n", "issue": "KFServing Transformer does not work with onnxruntime and trtis model server\n/kind bug\r\n\r\n**What steps did you take and what happened:**\r\nCurrently kfserving transformer does not work with onnxruntime and trtis model server due to following validation because their data plane do not support `instances` key in JSON.\r\nhttps://github.com/kubeflow/kfserving/blob/master/python/kfserving/kfserving/handlers/http.py#L24 \r\n\r\n\r\n\r\n**What did you expect to happen:**\r\nBefore we get to V2 data plane with agreed protocol across model servers, we should relax this validation.\r\n\r\n**Anything else you would like to add:**\r\n[Miscellaneous information that will assist in solving the issue.]\r\n\r\n\r\n**Environment:**\r\n\r\n- Istio Version:\r\n- Knative Version:\r\n- KFServing Version: 0.2.2\r\n- Kubeflow version:\r\n- Minikube version:\r\n- Kubernetes version: (use `kubectl version`):\r\n- OS (e.g. from `/etc/os-release`):\r\n\n", "before_files": [{"content": "import tornado.web\nimport json\nfrom typing import Dict\nfrom http import HTTPStatus\nfrom kfserving.kfmodel import KFModel\n\n\nclass HTTPHandler(tornado.web.RequestHandler):\n    def initialize(self, models: Dict[str, KFModel]):\n        self.models = models # pylint:disable=attribute-defined-outside-init\n\n    def get_model(self, name: str):\n        if name not in self.models:\n            raise tornado.web.HTTPError(\n                status_code=HTTPStatus.NOT_FOUND,\n                reason=\"Model with name %s does not exist.\" % name\n            )\n        model = self.models[name]\n        if not model.ready:\n            model.load()\n        return model\n\n    def validate(self, request):\n        if \"instances\" not in request:\n            raise tornado.web.HTTPError(\n                status_code=HTTPStatus.BAD_REQUEST,\n                reason=\"Expected key \\\"instances\\\" in request body\"\n            )\n\n        if not isinstance(request[\"instances\"], list):\n            raise tornado.web.HTTPError(\n                status_code=HTTPStatus.BAD_REQUEST,\n                reason=\"Expected \\\"instances\\\" to be a list\"\n            )\n        return request\n\n\nclass PredictHandler(HTTPHandler):\n    def post(self, name: str):\n        model = self.get_model(name)\n        try:\n            body = json.loads(self.request.body)\n        except json.decoder.JSONDecodeError as e:\n            raise tornado.web.HTTPError(\n                status_code=HTTPStatus.BAD_REQUEST,\n                reason=\"Unrecognized request format: %s\" % e\n            )\n        request = model.preprocess(body)\n        request = self.validate(request)\n        response = model.predict(request)\n        response = model.postprocess(response)\n        self.write(response)\n\n\nclass ExplainHandler(HTTPHandler):\n    def post(self, name: str):\n        model = self.get_model(name)\n        try:\n            body = json.loads(self.request.body)\n        except json.decoder.JSONDecodeError as e:\n            raise tornado.web.HTTPError(\n                status_code=HTTPStatus.BAD_REQUEST,\n                reason=\"Unrecognized request format: %s\" % e\n            )\n        request = model.preprocess(body)\n        request = self.validate(request)\n        response = model.explain(request)\n        response = model.postprocess(response)\n        self.write(response)\n", "path": "python/kfserving/kfserving/handlers/http.py"}]}