prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Knative KafaSource detects wrong URL to serve events
  /kind bug
  
  **What steps did you take and what happened:**
  [A clear and concise description of what the bug is.]
  - Deployed knative-eventing and kafkasource.
  - Added https://github.com/kserve/kserve/blob/master/docs/samples/kafka/addressable-resolver.yaml
  - knative eventing is able to read the kafka source.
  - The service name created by inferenceservice is \<isvc-name>-predictor-default. However the kafkasource sends the events to http://\<isvc-name>.\<namespace>.svc.cluster.local
  
  **What did you expect to happen:**
  - I expected the requests to be sent to http://\<isvc-name>-predictor-default.\<namespace>.svc.cluster.local
  
  **What's the InferenceService yaml:**
  ```
  apiVersion: "serving.kserve.io/v1beta1"
  kind: "InferenceService"
  metadata:
    name: "<inference-name>"
    namespace: "\<namespace>"
    annotations:
      prometheus.io/scrape: 'true'
      prometheus.io/port: '8082'
    labels:
      name: "\<label>"
  spec:
    predictor:
      minReplicas: 3
      maxReplicas: 100
      pytorch:
        name: \<name>
        storageUri: gs://<storage>
        resources:
          limits:
            cpu: 3000m
            memory: 3Gi
          requests:
            cpu: 2000m
            memory: 3Gi
  ```
  **Anything else you would like to add:**
  [Miscellaneous information that will assist in solving the issue.]
  ```
  ingress: |-
      {
          "ingressGateway" : "knative-serving/knative-ingress-gateway",
          "ingressService" : "istio-ingressgateway.istio-system.svc.cluster.local",
          "localGateway" : "knative-serving/knative-local-gateway",
          "localGatewayService" : "knative-local-gateway.istio-system.svc.cluster.local",
          "ingressDomain"  : "example.com",
          "ingressClassName" : "kong",
          "domainTemplate": "{{ .Name }}-{{ .Namespace }}.{{ .IngressDomain }}",
          "urlScheme": "http"
      }
  ```
  
  **Environment:**
   Using Kong
   RawDeployment
  Torchserve version : 0.6.1
  - Istio Version: Istio not installed
  - Knative Version: knative serving not installled. knative eventing v1.8.2
  - KServe Version: 0.9.0
  - Kubeflow version: N/A
  - Cloud Environment: GKE
  - Minikube/Kind version:
  - Kubernetes version: (use `kubectl version`): 1.23
  - OS (e.g. from `/etc/os-release`): GKE
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `docs/samples/kafka/image_transformer/image_transformer.py`
  Content:
  ```
  1 #
  2 # Licensed under the Apache License, Version 2.0 (the "License");
  3 # you may not use this file except in compliance with the License.
  4 # You may obtain a copy of the License at
  5 #
  6 #    http://www.apache.org/licenses/LICENSE-2.0
  7 #
  8 # Unless required by applicable law or agreed to in writing, software
  9 # distributed under the License is distributed on an "AS IS" BASIS,
  10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11 # See the License for the specific language governing permissions and
  12 # limitations under the License.
  13 
  14 import kserve
  15 from typing import Dict, Union
  16 import logging
  17 import boto3
  18 import cv2
  19 from cloudevents.http import CloudEvent
  20 
  21 from kserve import InferRequest, InferResponse
  22 from kserve.protocol.grpc.grpc_predict_v2_pb2 import ModelInferResponse
  23 
  24 logging.basicConfig(level=kserve.constants.KSERVE_LOGLEVEL)
  25 
  26 session = boto3.Session()
  27 client = session.client('s3', endpoint_url='http://minio-service:9000', aws_access_key_id='minio',
  28                         aws_secret_access_key='minio123')
  29 
  30 
  31 def image_transform(image):
  32     img = cv2.imread(image, cv2.IMREAD_GRAYSCALE)
  33     g = cv2.resize(255 - img, (28, 28))
  34     g = g.flatten() / 255.0
  35     return g.tolist()
  36 
  37 
  38 class ImageTransformer(kserve.Model):
  39     def __init__(self, name: str, predictor_host: str):
  40         super().__init__(name)
  41         self.predictor_host = predictor_host
  42         self._key = None
  43 
  44     def preprocess(self, inputs: Union[Dict, CloudEvent, InferRequest],
  45                    headers: Dict[str, str] = None) -> Union[Dict, InferRequest]:
  46         if inputs['EventName'] == 's3:ObjectCreated:Put':
  47             bucket = inputs['Records'][0]['s3']['bucket']['name']
  48             key = inputs['Records'][0]['s3']['object']['key']
  49             self._key = key
  50             client.download_file(bucket, key, '/tmp/' + key)
  51             request = image_transform('/tmp/' + key)
  52             return {"instances": [request]}
  53         raise Exception("unknown event")
  54 
  55     def postprocess(self, response: Union[Dict, InferResponse, ModelInferResponse], headers: Dict[str, str] = None) \
  56             -> Union[Dict, ModelInferResponse]:
  57         logging.info(response)
  58         index = response["predictions"][0]["classes"]
  59         logging.info("digit:" + str(index))
  60         client.upload_file('/tmp/' + self._key, 'digit-' + str(index), self._key)
  61         return response
  62
  ```
  
  Path: `docs/samples/kafka/setup.py`
  Content:
  ```
  1 #
  2 # Licensed under the Apache License, Version 2.0 (the "License");
  3 # you may not use this file except in compliance with the License.
  4 # You may obtain a copy of the License at
  5 #
  6 #    http://www.apache.org/licenses/LICENSE-2.0
  7 #
  8 # Unless required by applicable law or agreed to in writing, software
  9 # distributed under the License is distributed on an "AS IS" BASIS,
  10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11 # See the License for the specific language governing permissions and
  12 # limitations under the License.
  13 import os
  14 
  15 from setuptools import setup, find_packages
  16 
  17 tests_require = [
  18     'pytest',
  19     'pytest-tornasync',
  20     'mypy'
  21 ]
  22 
  23 with open(os.path.join(os.getcwd(), '../../../python/VERSION')) as version_file:
  24     version = version_file.read().strip()
  25 
  26 setup(
  27     name='transformer',
  28     version='0.1.0',
  29     author_email='dsun20@bloomberg.net',
  30     license='../../LICENSE.txt',
  31     url='https://github.com/kserve/kserve/tree/master/docs/samples/kafka',
  32     description='Transformer',
  33     long_description=open('README.md').read(),
  34     python_requires='>=3.7',
  35     packages=find_packages("transformer"),
  36     install_requires=[
  37         f"kserve>={version}",
  38         "pandas>=0.24.2",
  39         "opencv-python-headless==4.2.0.32",
  40     ],
  41     tests_require=tests_require,
  42     extras_require={'test': tests_require}
  43 )
  44
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/docs/samples/kafka/image_transformer/image_transformer.py b/docs/samples/kafka/image_transformer/image_transformer.py
  --- a/docs/samples/kafka/image_transformer/image_transformer.py
  +++ b/docs/samples/kafka/image_transformer/image_transformer.py
  @@ -11,13 +11,14 @@
   # See the License for the specific language governing permissions and
   # limitations under the License.
   
  -import kserve
  -from typing import Dict, Union
   import logging
  +from typing import Dict, Union
  +
   import boto3
   import cv2
   from cloudevents.http import CloudEvent
   
  +import kserve
   from kserve import InferRequest, InferResponse
   from kserve.protocol.grpc.grpc_predict_v2_pb2 import ModelInferResponse
   
  @@ -26,6 +27,7 @@
   session = boto3.Session()
   client = session.client('s3', endpoint_url='http://minio-service:9000', aws_access_key_id='minio',
                           aws_secret_access_key='minio123')
  +digits_bucket = 'digits'
   
   
   def image_transform(image):
  @@ -41,8 +43,9 @@
           self.predictor_host = predictor_host
           self._key = None
   
  -    def preprocess(self, inputs: Union[Dict, CloudEvent, InferRequest],
  -                   headers: Dict[str, str] = None) -> Union[Dict, InferRequest]:
  +    async def preprocess(self, inputs: Union[Dict, CloudEvent, InferRequest],
  +                         headers: Dict[str, str] = None) -> Union[Dict, InferRequest]:
  +        logging.info("Received inputs %s", inputs)
           if inputs['EventName'] == 's3:ObjectCreated:Put':
               bucket = inputs['Records'][0]['s3']['bucket']['name']
               key = inputs['Records'][0]['s3']['object']['key']
  @@ -54,8 +57,10 @@
   
       def postprocess(self, response: Union[Dict, InferResponse, ModelInferResponse], headers: Dict[str, str] = None) \
               -> Union[Dict, ModelInferResponse]:
  -        logging.info(response)
  +        logging.info("response: %s", response)
           index = response["predictions"][0]["classes"]
           logging.info("digit:" + str(index))
  -        client.upload_file('/tmp/' + self._key, 'digit-' + str(index), self._key)
  +        upload_path = f'digit-{index}/{self._key}'
  +        client.upload_file('/tmp/' + self._key, digits_bucket, upload_path)
  +        logging.info(f"Image {self._key} successfully uploaded to {upload_path}")
           return response
  diff --git a/docs/samples/kafka/setup.py b/docs/samples/kafka/setup.py
  --- a/docs/samples/kafka/setup.py
  +++ b/docs/samples/kafka/setup.py
  @@ -10,22 +10,17 @@
   # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   # See the License for the specific language governing permissions and
   # limitations under the License.
  -import os
   
   from setuptools import setup, find_packages
   
   tests_require = [
       'pytest',
  -    'pytest-tornasync',
       'mypy'
   ]
   
  -with open(os.path.join(os.getcwd(), '../../../python/VERSION')) as version_file:
  -    version = version_file.read().strip()
  -
   setup(
       name='transformer',
  -    version='0.1.0',
  +    version='0.2.0',
       author_email='dsun20@bloomberg.net',
       license='../../LICENSE.txt',
       url='https://github.com/kserve/kserve/tree/master/docs/samples/kafka',
  @@ -34,9 +29,9 @@
       python_requires='>=3.7',
       packages=find_packages("transformer"),
       install_requires=[
  -        f"kserve>={version}",
  +        "kserve>0.10.0",
           "pandas>=0.24.2",
  -        "opencv-python-headless==4.2.0.32",
  +        "opencv-python-headless==4.7.0.72",
       ],
       tests_require=tests_require,
       extras_require={'test': tests_require}
  
verification_info: {"golden_diff": "diff --git a/docs/samples/kafka/image_transformer/image_transformer.py b/docs/samples/kafka/image_transformer/image_transformer.py\n--- a/docs/samples/kafka/image_transformer/image_transformer.py\n+++ b/docs/samples/kafka/image_transformer/image_transformer.py\n@@ -11,13 +11,14 @@\n # See the License for the specific language governing permissions and\n # limitations under the License.\n \n-import kserve\n-from typing import Dict, Union\n import logging\n+from typing import Dict, Union\n+\n import boto3\n import cv2\n from cloudevents.http import CloudEvent\n \n+import kserve\n from kserve import InferRequest, InferResponse\n from kserve.protocol.grpc.grpc_predict_v2_pb2 import ModelInferResponse\n \n@@ -26,6 +27,7 @@\n session = boto3.Session()\n client = session.client('s3', endpoint_url='http://minio-service:9000', aws_access_key_id='minio',\n                         aws_secret_access_key='minio123')\n+digits_bucket = 'digits'\n \n \n def image_transform(image):\n@@ -41,8 +43,9 @@\n         self.predictor_host = predictor_host\n         self._key = None\n \n-    def preprocess(self, inputs: Union[Dict, CloudEvent, InferRequest],\n-                   headers: Dict[str, str] = None) -> Union[Dict, InferRequest]:\n+    async def preprocess(self, inputs: Union[Dict, CloudEvent, InferRequest],\n+                         headers: Dict[str, str] = None) -> Union[Dict, InferRequest]:\n+        logging.info(\"Received inputs %s\", inputs)\n         if inputs['EventName'] == 's3:ObjectCreated:Put':\n             bucket = inputs['Records'][0]['s3']['bucket']['name']\n             key = inputs['Records'][0]['s3']['object']['key']\n@@ -54,8 +57,10 @@\n \n     def postprocess(self, response: Union[Dict, InferResponse, ModelInferResponse], headers: Dict[str, str] = None) \\\n             -> Union[Dict, ModelInferResponse]:\n-        logging.info(response)\n+        logging.info(\"response: %s\", response)\n         index = response[\"predictions\"][0][\"classes\"]\n         logging.info(\"digit:\" + str(index))\n-        client.upload_file('/tmp/' + self._key, 'digit-' + str(index), self._key)\n+        upload_path = f'digit-{index}/{self._key}'\n+        client.upload_file('/tmp/' + self._key, digits_bucket, upload_path)\n+        logging.info(f\"Image {self._key} successfully uploaded to {upload_path}\")\n         return response\ndiff --git a/docs/samples/kafka/setup.py b/docs/samples/kafka/setup.py\n--- a/docs/samples/kafka/setup.py\n+++ b/docs/samples/kafka/setup.py\n@@ -10,22 +10,17 @@\n # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n # See the License for the specific language governing permissions and\n # limitations under the License.\n-import os\n \n from setuptools import setup, find_packages\n \n tests_require = [\n     'pytest',\n-    'pytest-tornasync',\n     'mypy'\n ]\n \n-with open(os.path.join(os.getcwd(), '../../../python/VERSION')) as version_file:\n-    version = version_file.read().strip()\n-\n setup(\n     name='transformer',\n-    version='0.1.0',\n+    version='0.2.0',\n     author_email='dsun20@bloomberg.net',\n     license='../../LICENSE.txt',\n     url='https://github.com/kserve/kserve/tree/master/docs/samples/kafka',\n@@ -34,9 +29,9 @@\n     python_requires='>=3.7',\n     packages=find_packages(\"transformer\"),\n     install_requires=[\n-        f\"kserve>={version}\",\n+        \"kserve>0.10.0\",\n         \"pandas>=0.24.2\",\n-        \"opencv-python-headless==4.2.0.32\",\n+        \"opencv-python-headless==4.7.0.72\",\n     ],\n     tests_require=tests_require,\n     extras_require={'test': tests_require}\n", "issue": "Knative KafaSource detects wrong URL to serve events\n/kind bug\r\n\r\n**What steps did you take and what happened:**\r\n[A clear and concise description of what the bug is.]\r\n- Deployed knative-eventing and kafkasource.\r\n- Added https://github.com/kserve/kserve/blob/master/docs/samples/kafka/addressable-resolver.yaml\r\n- knative eventing is able to read the kafka source.\r\n- The service name created by inferenceservice is \\<isvc-name>-predictor-default. However the kafkasource sends the events to http://\\<isvc-name>.\\<namespace>.svc.cluster.local\r\n\r\n**What did you expect to happen:**\r\n- I expected the requests to be sent to http://\\<isvc-name>-predictor-default.\\<namespace>.svc.cluster.local\r\n\r\n**What's the InferenceService yaml:**\r\n```\r\napiVersion: \"serving.kserve.io/v1beta1\"\r\nkind: \"InferenceService\"\r\nmetadata:\r\n  name: \"<inference-name>\"\r\n  namespace: \"\\<namespace>\"\r\n  annotations:\r\n    prometheus.io/scrape: 'true'\r\n    prometheus.io/port: '8082'\r\n  labels:\r\n    name: \"\\<label>\"\r\nspec:\r\n  predictor:\r\n    minReplicas: 3\r\n    maxReplicas: 100\r\n    pytorch:\r\n      name: \\<name>\r\n      storageUri: gs://<storage>\r\n      resources:\r\n        limits:\r\n          cpu: 3000m\r\n          memory: 3Gi\r\n        requests:\r\n          cpu: 2000m\r\n          memory: 3Gi\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\ningress: |-\r\n    {\r\n        \"ingressGateway\" : \"knative-serving/knative-ingress-gateway\",\r\n        \"ingressService\" : \"istio-ingressgateway.istio-system.svc.cluster.local\",\r\n        \"localGateway\" : \"knative-serving/knative-local-gateway\",\r\n        \"localGatewayService\" : \"knative-local-gateway.istio-system.svc.cluster.local\",\r\n        \"ingressDomain\"  : \"example.com\",\r\n        \"ingressClassName\" : \"kong\",\r\n        \"domainTemplate\": \"{{ .Name }}-{{ .Namespace }}.{{ .IngressDomain }}\",\r\n        \"urlScheme\": \"http\"\r\n    }\r\n```\r\n\r\n**Environment:**\r\n Using Kong\r\n RawDeployment\r\nTorchserve version : 0.6.1\r\n- Istio Version: Istio not installed\r\n- Knative Version: knative serving not installled. knative eventing v1.8.2\r\n- KServe Version: 0.9.0\r\n- Kubeflow version: N/A\r\n- Cloud Environment: GKE\r\n- Minikube/Kind version:\r\n- Kubernetes version: (use `kubectl version`): 1.23\r\n- OS (e.g. from `/etc/os-release`): GKE\r\n\n", "before_files": [{"content": "#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport kserve\nfrom typing import Dict, Union\nimport logging\nimport boto3\nimport cv2\nfrom cloudevents.http import CloudEvent\n\nfrom kserve import InferRequest, InferResponse\nfrom kserve.protocol.grpc.grpc_predict_v2_pb2 import ModelInferResponse\n\nlogging.basicConfig(level=kserve.constants.KSERVE_LOGLEVEL)\n\nsession = boto3.Session()\nclient = session.client('s3', endpoint_url='http://minio-service:9000', aws_access_key_id='minio',\n                        aws_secret_access_key='minio123')\n\n\ndef image_transform(image):\n    img = cv2.imread(image, cv2.IMREAD_GRAYSCALE)\n    g = cv2.resize(255 - img, (28, 28))\n    g = g.flatten() / 255.0\n    return g.tolist()\n\n\nclass ImageTransformer(kserve.Model):\n    def __init__(self, name: str, predictor_host: str):\n        super().__init__(name)\n        self.predictor_host = predictor_host\n        self._key = None\n\n    def preprocess(self, inputs: Union[Dict, CloudEvent, InferRequest],\n                   headers: Dict[str, str] = None) -> Union[Dict, InferRequest]:\n        if inputs['EventName'] == 's3:ObjectCreated:Put':\n            bucket = inputs['Records'][0]['s3']['bucket']['name']\n            key = inputs['Records'][0]['s3']['object']['key']\n            self._key = key\n            client.download_file(bucket, key, '/tmp/' + key)\n            request = image_transform('/tmp/' + key)\n            return {\"instances\": [request]}\n        raise Exception(\"unknown event\")\n\n    def postprocess(self, response: Union[Dict, InferResponse, ModelInferResponse], headers: Dict[str, str] = None) \\\n            -> Union[Dict, ModelInferResponse]:\n        logging.info(response)\n        index = response[\"predictions\"][0][\"classes\"]\n        logging.info(\"digit:\" + str(index))\n        client.upload_file('/tmp/' + self._key, 'digit-' + str(index), self._key)\n        return response\n", "path": "docs/samples/kafka/image_transformer/image_transformer.py"}, {"content": "#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport os\n\nfrom setuptools import setup, find_packages\n\ntests_require = [\n    'pytest',\n    'pytest-tornasync',\n    'mypy'\n]\n\nwith open(os.path.join(os.getcwd(), '../../../python/VERSION')) as version_file:\n    version = version_file.read().strip()\n\nsetup(\n    name='transformer',\n    version='0.1.0',\n    author_email='dsun20@bloomberg.net',\n    license='../../LICENSE.txt',\n    url='https://github.com/kserve/kserve/tree/master/docs/samples/kafka',\n    description='Transformer',\n    long_description=open('README.md').read(),\n    python_requires='>=3.7',\n    packages=find_packages(\"transformer\"),\n    install_requires=[\n        f\"kserve>={version}\",\n        \"pandas>=0.24.2\",\n        \"opencv-python-headless==4.2.0.32\",\n    ],\n    tests_require=tests_require,\n    extras_require={'test': tests_require}\n)\n", "path": "docs/samples/kafka/setup.py"}], "after_files": [{"content": "#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport logging\nfrom typing import Dict, Union\n\nimport boto3\nimport cv2\nfrom cloudevents.http import CloudEvent\n\nimport kserve\nfrom kserve import InferRequest, InferResponse\nfrom kserve.protocol.grpc.grpc_predict_v2_pb2 import ModelInferResponse\n\nlogging.basicConfig(level=kserve.constants.KSERVE_LOGLEVEL)\n\nsession = boto3.Session()\nclient = session.client('s3', endpoint_url='http://minio-service:9000', aws_access_key_id='minio',\n                        aws_secret_access_key='minio123')\ndigits_bucket = 'digits'\n\n\ndef image_transform(image):\n    img = cv2.imread(image, cv2.IMREAD_GRAYSCALE)\n    g = cv2.resize(255 - img, (28, 28))\n    g = g.flatten() / 255.0\n    return g.tolist()\n\n\nclass ImageTransformer(kserve.Model):\n    def __init__(self, name: str, predictor_host: str):\n        super().__init__(name)\n        self.predictor_host = predictor_host\n        self._key = None\n\n    async def preprocess(self, inputs: Union[Dict, CloudEvent, InferRequest],\n                         headers: Dict[str, str] = None) -> Union[Dict, InferRequest]:\n        logging.info(\"Received inputs %s\", inputs)\n        if inputs['EventName'] == 's3:ObjectCreated:Put':\n            bucket = inputs['Records'][0]['s3']['bucket']['name']\n            key = inputs['Records'][0]['s3']['object']['key']\n            self._key = key\n            client.download_file(bucket, key, '/tmp/' + key)\n            request = image_transform('/tmp/' + key)\n            return {\"instances\": [request]}\n        raise Exception(\"unknown event\")\n\n    def postprocess(self, response: Union[Dict, InferResponse, ModelInferResponse], headers: Dict[str, str] = None) \\\n            -> Union[Dict, ModelInferResponse]:\n        logging.info(\"response: %s\", response)\n        index = response[\"predictions\"][0][\"classes\"]\n        logging.info(\"digit:\" + str(index))\n        upload_path = f'digit-{index}/{self._key}'\n        client.upload_file('/tmp/' + self._key, digits_bucket, upload_path)\n        logging.info(f\"Image {self._key} successfully uploaded to {upload_path}\")\n        return response\n", "path": "docs/samples/kafka/image_transformer/image_transformer.py"}, {"content": "#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom setuptools import setup, find_packages\n\ntests_require = [\n    'pytest',\n    'mypy'\n]\n\nsetup(\n    name='transformer',\n    version='0.2.0',\n    author_email='dsun20@bloomberg.net',\n    license='../../LICENSE.txt',\n    url='https://github.com/kserve/kserve/tree/master/docs/samples/kafka',\n    description='Transformer',\n    long_description=open('README.md').read(),\n    python_requires='>=3.7',\n    packages=find_packages(\"transformer\"),\n    install_requires=[\n        \"kserve>0.10.0\",\n        \"pandas>=0.24.2\",\n        \"opencv-python-headless==4.7.0.72\",\n    ],\n    tests_require=tests_require,\n    extras_require={'test': tests_require}\n)\n", "path": "docs/samples/kafka/setup.py"}]}