prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Support other common names for SKLearn runtime
  Add support for models named `model.pickle` and `model.pkl`
  
  </issue>
  <code>
  [start of runtimes/sklearn/mlserver_sklearn/sklearn.py]
  1 import joblib
  2 
  3 from typing import List
  4 
  5 from mlserver import types
  6 from mlserver.model import MLModel
  7 from mlserver.errors import InferenceError
  8 from mlserver.utils import get_model_uri, to_ndarray
  9 
  10 
  11 PREDICT_OUTPUT = "predict"
  12 PREDICT_PROBA_OUTPUT = "predict_proba"
  13 VALID_OUTPUTS = [PREDICT_OUTPUT, PREDICT_PROBA_OUTPUT]
  14 
  15 WELLKNOWN_MODEL_FILENAMES = ["model.joblib"]
  16 
  17 
  18 class SKLearnModel(MLModel):
  19     """
  20     Implementation of the MLModel interface to load and serve `scikit-learn`
  21     models persisted with `joblib`.
  22     """
  23 
  24     async def load(self) -> bool:
  25         # TODO: Log info message
  26         model_uri = await get_model_uri(
  27             self._settings, wellknown_filenames=WELLKNOWN_MODEL_FILENAMES
  28         )
  29         self._model = joblib.load(model_uri)
  30 
  31         self.ready = True
  32         return self.ready
  33 
  34     async def predict(self, payload: types.InferenceRequest) -> types.InferenceResponse:
  35         payload = self._check_request(payload)
  36 
  37         return types.InferenceResponse(
  38             model_name=self.name,
  39             model_version=self.version,
  40             outputs=self._predict_outputs(payload),
  41         )
  42 
  43     def _check_request(self, payload: types.InferenceRequest) -> types.InferenceRequest:
  44         if len(payload.inputs) != 1:
  45             raise InferenceError(
  46                 "SKLearnModel only supports a single input tensor "
  47                 f"({len(payload.inputs)} were received)"
  48             )
  49 
  50         if not payload.outputs:
  51             # By default, only return the result of `predict()`
  52             payload.outputs = [types.RequestOutput(name=PREDICT_OUTPUT)]
  53         else:
  54             for request_output in payload.outputs:
  55                 if request_output.name not in VALID_OUTPUTS:
  56                     raise InferenceError(
  57                         f"SKLearnModel only supports '{PREDICT_OUTPUT}' and "
  58                         f"'{PREDICT_PROBA_OUTPUT}' as outputs "
  59                         f"({request_output.name} was received)"
  60                     )
  61 
  62         return payload
  63 
  64     def _predict_outputs(
  65         self, payload: types.InferenceRequest
  66     ) -> List[types.ResponseOutput]:
  67         model_input = payload.inputs[0]
  68         input_data = to_ndarray(model_input)
  69 
  70         outputs = []
  71         for request_output in payload.outputs:  # type: ignore
  72             predict_fn = getattr(self._model, request_output.name)
  73             y = predict_fn(input_data)
  74 
  75             # TODO: Set datatype (cast from numpy?)
  76             outputs.append(
  77                 types.ResponseOutput(
  78                     name=request_output.name,
  79                     shape=y.shape,
  80                     datatype="FP32",
  81                     data=y.tolist(),
  82                 )
  83             )
  84 
  85         return outputs
  86
  [end of runtimes/sklearn/mlserver_sklearn/sklearn.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/runtimes/sklearn/mlserver_sklearn/sklearn.py b/runtimes/sklearn/mlserver_sklearn/sklearn.py
  --- a/runtimes/sklearn/mlserver_sklearn/sklearn.py
  +++ b/runtimes/sklearn/mlserver_sklearn/sklearn.py
  @@ -12,7 +12,7 @@
   PREDICT_PROBA_OUTPUT = "predict_proba"
   VALID_OUTPUTS = [PREDICT_OUTPUT, PREDICT_PROBA_OUTPUT]
   
  -WELLKNOWN_MODEL_FILENAMES = ["model.joblib"]
  +WELLKNOWN_MODEL_FILENAMES = ["model.joblib", "model.pickle", "model.pkl"]
   
   
   class SKLearnModel(MLModel):
  
verification_info: {"golden_diff": "diff --git a/runtimes/sklearn/mlserver_sklearn/sklearn.py b/runtimes/sklearn/mlserver_sklearn/sklearn.py\n--- a/runtimes/sklearn/mlserver_sklearn/sklearn.py\n+++ b/runtimes/sklearn/mlserver_sklearn/sklearn.py\n@@ -12,7 +12,7 @@\n PREDICT_PROBA_OUTPUT = \"predict_proba\"\n VALID_OUTPUTS = [PREDICT_OUTPUT, PREDICT_PROBA_OUTPUT]\n \n-WELLKNOWN_MODEL_FILENAMES = [\"model.joblib\"]\n+WELLKNOWN_MODEL_FILENAMES = [\"model.joblib\", \"model.pickle\", \"model.pkl\"]\n \n \n class SKLearnModel(MLModel):\n", "issue": "Support other common names for SKLearn runtime\nAdd support for models named `model.pickle` and `model.pkl`\n", "before_files": [{"content": "import joblib\n\nfrom typing import List\n\nfrom mlserver import types\nfrom mlserver.model import MLModel\nfrom mlserver.errors import InferenceError\nfrom mlserver.utils import get_model_uri, to_ndarray\n\n\nPREDICT_OUTPUT = \"predict\"\nPREDICT_PROBA_OUTPUT = \"predict_proba\"\nVALID_OUTPUTS = [PREDICT_OUTPUT, PREDICT_PROBA_OUTPUT]\n\nWELLKNOWN_MODEL_FILENAMES = [\"model.joblib\"]\n\n\nclass SKLearnModel(MLModel):\n    \"\"\"\n    Implementation of the MLModel interface to load and serve `scikit-learn`\n    models persisted with `joblib`.\n    \"\"\"\n\n    async def load(self) -> bool:\n        # TODO: Log info message\n        model_uri = await get_model_uri(\n            self._settings, wellknown_filenames=WELLKNOWN_MODEL_FILENAMES\n        )\n        self._model = joblib.load(model_uri)\n\n        self.ready = True\n        return self.ready\n\n    async def predict(self, payload: types.InferenceRequest) -> types.InferenceResponse:\n        payload = self._check_request(payload)\n\n        return types.InferenceResponse(\n            model_name=self.name,\n            model_version=self.version,\n            outputs=self._predict_outputs(payload),\n        )\n\n    def _check_request(self, payload: types.InferenceRequest) -> types.InferenceRequest:\n        if len(payload.inputs) != 1:\n            raise InferenceError(\n                \"SKLearnModel only supports a single input tensor \"\n                f\"({len(payload.inputs)} were received)\"\n            )\n\n        if not payload.outputs:\n            # By default, only return the result of `predict()`\n            payload.outputs = [types.RequestOutput(name=PREDICT_OUTPUT)]\n        else:\n            for request_output in payload.outputs:\n                if request_output.name not in VALID_OUTPUTS:\n                    raise InferenceError(\n                        f\"SKLearnModel only supports '{PREDICT_OUTPUT}' and \"\n                        f\"'{PREDICT_PROBA_OUTPUT}' as outputs \"\n                        f\"({request_output.name} was received)\"\n                    )\n\n        return payload\n\n    def _predict_outputs(\n        self, payload: types.InferenceRequest\n    ) -> List[types.ResponseOutput]:\n        model_input = payload.inputs[0]\n        input_data = to_ndarray(model_input)\n\n        outputs = []\n        for request_output in payload.outputs:  # type: ignore\n            predict_fn = getattr(self._model, request_output.name)\n            y = predict_fn(input_data)\n\n            # TODO: Set datatype (cast from numpy?)\n            outputs.append(\n                types.ResponseOutput(\n                    name=request_output.name,\n                    shape=y.shape,\n                    datatype=\"FP32\",\n                    data=y.tolist(),\n                )\n            )\n\n        return outputs\n", "path": "runtimes/sklearn/mlserver_sklearn/sklearn.py"}]}