internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: kserve/kserve

Issue:
Azure Blob Storage to support shared access signatures(SAS)
/kind feature

**Describe the solution you'd like**
[A clear and concise description of what you want to happen.]

1. Able to access Azure Storage resources using shared access signatures([SAS](https://docs.microsoft.com/en-us/azure/storage/common/storage-sas-overview)), as our user only have `container_uri` and `SAS token` as credentials.

**Anything else you would like to add:**
[Miscellaneous information that will assist in solving the issue.]

1. [example](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/storage/azure-storage-blob/samples/blob_samples_authentication.py#L39) of using `SAS token` from azure.
2. KServe has `AZURE_STORAGE_ACCESS_KEY` [environment variable](https://github.com/kserve/kserve/blob/master/python/kserve/kserve/storage.py#L465-L466), but it is only used for [Azure File Share](https://github.com/kserve/kserve/blob/master/python/kserve/kserve/storage.py#L394). To support it, just reuse it to pass the `SAS token` similar to the their [example](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/storage/azure-storage-blob/samples/blob_samples_authentication.py#L39).


Discussion:

Resolving patch:
diff --git a/python/kserve/kserve/storage.py b/python/kserve/kserve/storage.py
--- a/python/kserve/kserve/storage.py
+++ b/python/kserve/kserve/storage.py
@@ -345,9 +345,9 @@ def _download_azure_blob(uri, out_dir: str):  # pylint: disable=too-many-locals
                      account_name,
                      container_name,
                      prefix)
-        token = Storage._get_azure_storage_token()
+        token = Storage._get_azure_storage_token() or Storage._get_azure_storage_access_key()
         if token is None:
-            logging.warning("Azure credentials not found, retrying anonymous access")
+            logging.warning("Azure credentials or shared access signature token not found, retrying anonymous access")
 
         blob_service_client = BlobServiceClient(account_url, credential=token)
         container_client = blob_service_client.get_container_client(container_name)


Test patch:
Repository: kserve/kserve

Issue:
GPL License Violation in the kserve python package
The version of the `kserve` package that is currently on PyPI (version `0.10`) violates the GPL license because it depends on [`table-logger`](https://github.com/AleksTk/table-logger), distributed under GPLv2 (you'll see that the library is now MIT, the author updated the license just a few days ago, but hasn't released a new version with the new license yet). No GPLv2 packages should be imported given that `kserve` has an Apache 2 license.


This was recently fixed by this PR https://github.com/kserve/kserve/pull/2673, which accidentally resolved the issue by replacing `table-logger` with `tabulate` (MIT License)

cc @yuzisun @cliveseldon @jinchihe @ellistarn 

Is it possible to quickly release a patch release `0.10.1` to include the above patch and make sure `kserve` is compliant with the Apache license? As it stands, any distribution and vendor using `kserve` is liable for a license violation.






Discussion:

Resolving patch:
diff --git a/python/kserve/kserve/api/watch.py b/python/kserve/kserve/api/watch.py
--- a/python/kserve/kserve/api/watch.py
+++ b/python/kserve/kserve/api/watch.py
@@ -13,9 +13,10 @@
 # limitations under the License.
 
 import time
+
 from kubernetes import client
 from kubernetes import watch as k8s_watch
-from table_logger import TableLogger
+from tabulate import tabulate
 
 from ..constants import constants
 from ..utils import utils
@@ -27,10 +28,8 @@ def isvc_watch(name=None, namespace=None, timeout_seconds=600, generation=0):
     if namespace is None:
         namespace = utils.get_default_target_namespace()
 
-    tbl = TableLogger(
-        columns='NAME,READY,PREV,LATEST,URL',
-        colwidth={'NAME': 20, 'READY': 10, 'PREV': 25, 'LATEST': 25, 'URL': 65},
-        border=False)
+    headers = ['NAME', 'READY', 'PREV', 'LATEST', 'URL']
+    table_fmt = 'plain'
 
     stream = k8s_watch.Watch().stream(
         client.CustomObjectsApi().list_namespaced_custom_object,
@@ -63,12 +62,13 @@ def isvc_watch(name=None, namespace=None, timeout_seconds=600, generation=0):
                     for condition in isvc['status'].get('conditions', {}):
                         if condition.get('type', '') == 'Ready':
                             status = condition.get('status', 'Unknown')
-                    tbl(isvc_name, status, 100-traffic_percent, traffic_percent, url)
+                    print(tabulate([[isvc_name, status, 100 - traffic_percent, traffic_percent, url]],
+                                   headers=headers, tablefmt=table_fmt))
                     if status == 'True':
                         break
 
             else:
-                tbl(isvc_name, status, '', '', '')
+                print(tabulate([[isvc_name, status, '', '', '']], headers=headers, tablefmt=table_fmt))
                 # Sleep 2 to avoid status section is not generated within a very short time.
                 time.sleep(2)
                 continue


Test patch:
Repository: kserve/kserve

Issue:
Knative installation keeps failing in e2e tests
/kind bug

**What steps did you take and what happened:**
[A clear and concise description of what the bug is.]
The e2e tests are failing every now and then while running the knative installation step, more specifically while patching the configmap. A solution has to be provided so that the installation completes successfully using some kind of retry mechanism.

**What did you expect to happen:**
All e2e tests to run without any issues.


**Environment:**

e2e environment



Discussion:

Resolving patch:
diff --git a/python/kserve/setup.py b/python/kserve/setup.py
--- a/python/kserve/setup.py
+++ b/python/kserve/setup.py
@@ -21,7 +21,7 @@
     'pytest-cov',
     'pytest-asyncio',
     'mypy',
-    'portforward',
+    'portforward==0.4.0',
 ]
 
 with open('requirements.txt') as f:


Test patch:
diff --git a/test/scripts/gh-actions/setup-deps.sh b/test/scripts/gh-actions/setup-deps.sh
--- a/test/scripts/gh-actions/setup-deps.sh
+++ b/test/scripts/gh-actions/setup-deps.sh
@@ -71,11 +71,16 @@ for i in 1 2 3 ; do kubectl apply -k test/overlays/knative && break || sleep 15;
 echo "Waiting for Knative to be ready ..."
 kubectl wait --for=condition=Ready pods --all --timeout=300s -n knative-serving -l 'app in (webhook, activator,autoscaler,autoscaler-hpa,controller,net-istio-controller,net-istio-webhook)'
 
-echo "Add knative hpa..."
+# echo "Add knative hpa..."
 # kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.0.0/serving-hpa.yaml
 
 # Skip tag resolution for certain domains
-kubectl patch cm config-deployment --patch '{"data":{"registries-skipping-tag-resolving":"nvcr.io,index.docker.io"}}' -n knative-serving
+# sleep to avoid knative webhook timeout error
+sleep 5
+# Retry if configmap patch fails
+for i in 1 2 3; do
+  kubectl patch cm config-deployment --patch '{"data":{"registries-skipping-tag-resolving":"nvcr.io,index.docker.io"}}' -n knative-serving && break || sleep 15
+done
 
 echo "Installing cert-manager ..."
 kubectl create namespace cert-manager
Repository: kserve/kserve

Issue:
storage-initializer error os.symlink(src, dest_path) 11FileExistsError: [Errno 17] File exists:
Our inference service pods occasionally run into an init error so the storage-initializer container restarts and gets stuck in an Init:CrashLoopBackOff when attempting to run the following:

```
[I 220726 13:08:23 storage:284] Linking: /mnt/pvc/junk-news/models/2021-09-14T00:56:33.734729/pytorch_model.bin to /mnt/models/pytorch_model.bin
4Traceback (most recent call last):
5  File "/storage-initializer/scripts/initializer-entrypoint", line 14, in <module>
6    kserve.Storage.download(src_uri, dest_path)
7  File "/usr/local/lib/python3.7/site-packages/kserve/storage.py", line 78, in download
8    return Storage._download_local(uri, out_dir)
9  File "/usr/local/lib/python3.7/site-packages/kserve/storage.py", line 285, in _download_local
10    os.symlink(src, dest_path)
11FileExistsError: [Errno 17] File exists: '/mnt/pvc/junk-news/models/2021-09-14T00:56:33.734729/pytorch_model.bin' -> '/mnt/models/pytorch_model.bin'
```

I think the `storage.py code` should handle `FileExistsError` when running `os.symlink`. Otherwise, we would have to manually delete the pod and have another one get created to fix the `Init:CrashLoopBackOff`

This can probably be accomplished by wrapping the code that calls `os.symlink` in a try-except block and pass when `FileExistsError` occurs.
I think this is the responsible line of code: 
https://github.com/kserve/kserve/blob/master/python/kserve/kserve/storage.py#L487


Discussion:
I have the same problem.

![image](https://user-images.githubusercontent.com/60999693/206647300-32550859-23a1-4148-8f59-fef5638ab52e.png)


Resolving patch:
diff --git a/python/kserve/kserve/storage/storage.py b/python/kserve/kserve/storage/storage.py
--- a/python/kserve/kserve/storage/storage.py
+++ b/python/kserve/kserve/storage/storage.py
@@ -486,7 +486,7 @@ def _download_local(uri, out_dir=None):
         if out_dir is None:
             return local_path
         elif not os.path.isdir(out_dir):
-            os.makedirs(out_dir)
+            os.makedirs(out_dir, exist_ok=True)
 
         if os.path.isdir(local_path):
             local_path = os.path.join(local_path, "*")
@@ -496,7 +496,10 @@ def _download_local(uri, out_dir=None):
             _, tail = os.path.split(src)
             dest_path = os.path.join(out_dir, tail)
             logging.info("Linking: %s to %s", src, dest_path)
-            os.symlink(src, dest_path)
+            if not os.path.exists(dest_path):
+                os.symlink(src, dest_path)
+            else:
+                logging.info("File %s already exist", dest_path)
             count = count + 1
         if count == 0:
             raise RuntimeError(


Test patch:
Repository: kserve/kserve

Issue:
Make poetry version plugin to update the pyproject.toml as well not just the build
/kind bug

**What steps did you take and what happened:**
[A clear and concise description of what the bug is.]
Currently the poetry plugin updates the version during the build, install phases but does not update the pyproject.toml
This makes it harder to easily decipher the version of the package.

**What did you expect to happen:**
Running poetry build or install should set the version of the package in pyproject.toml




Discussion:

Resolving patch:
diff --git a/python/plugin/poetry-version-plugin/poetry_version_plugin/plugin.py b/python/plugin/poetry-version-plugin/poetry_version_plugin/plugin.py
--- a/python/plugin/poetry-version-plugin/poetry_version_plugin/plugin.py
+++ b/python/plugin/poetry-version-plugin/poetry_version_plugin/plugin.py
@@ -37,6 +37,13 @@ def activate(self, poetry: Poetry, io: IO) -> None:
                     "version is updated from given file "
                     f"version is: <b>{version}</b>"
                 )
+                content: dict[str, Any] = poetry.file.read()
+                poetry_content = content["tool"]["poetry"]
+                poetry_content["version"] = version
+                poetry.file.write(content)
+                io.write_line(
+                    "<b>poetry-version-plugin</b>: New version updated in toml file"
+                )
 
         if version_source == "init":
             packages = poetry.local_config.get("packages")


Test patch:
Repository: kserve/kserve

Issue:
Load kubeconfig from dict
/kind feature

**Allow loading of kubeconfig from dictionary in KServe python client**
The Kubernetes python client has a function to load kubeconfigs from dict which is quite handy in somecases compared to the kubecfg file. Currently the `KServeClient` supports only loading from kubeconfig i.e, `config.load_kube_config()`.

I have verified that the [KServeClient](https://github.com/kserve/kserve/blob/master/python/kserve/kserve/api/kserve_client.py#L40) in the master branch does not have it.




Discussion:
@yuzisun 
Let me know if it makes sense. I would be happy to work on adding this functionality.

Resolving patch:
diff --git a/python/kserve/kserve/api/kserve_client.py b/python/kserve/kserve/api/kserve_client.py
--- a/python/kserve/kserve/api/kserve_client.py
+++ b/python/kserve/kserve/api/kserve_client.py
@@ -43,7 +43,7 @@ def __init__(self, config_file=None, config_dict=None, context=None,  # pylint:
                     config_dict=config_dict,
                     context=context,
                     client_configuration=None,
-                    persist_config=True
+                    persist_config=persist_config
                 )
             else:
                 config.load_kube_config(


Test patch:
Repository: kserve/kserve

Issue:
response id in response should return request id if present
/kind bug

**What steps did you take and what happened:**
[A clear and concise description of what the bug is.]

When a request is sent with request id, the response should contain the request id so that the response and request can be easily co-related. Most frameworks and applications return the request id as the response id.

**What did you expect to happen:**
Return a generated uuid as response id if no request id is sent but return the request id if available.

**Environment:**

- KServe Version: 0.10.1




Discussion:

Resolving patch:
diff --git a/python/kserve/kserve/utils/utils.py b/python/kserve/kserve/utils/utils.py
--- a/python/kserve/kserve/utils/utils.py
+++ b/python/kserve/kserve/utils/utils.py
@@ -203,7 +203,7 @@ def get_predict_response(payload: Union[Dict, InferRequest], result: Union[np.nd
         return InferResponse(
             model_name=model_name,
             infer_outputs=infer_outputs,
-            response_id=generate_uuid()
+            response_id=payload.id if payload.id else generate_uuid()
         )
 
 


Test patch:
Repository: kserve/kserve

Issue:
Kserve ModelServer().start(list_of_models) fails on Windows
/kind bug

**What steps did you take and what happened:**
When ModelServer().start(list_of_models) is called, exception is raised at this location: https://github.com/kserve/kserve/blob/0ba642f9b6fa40b38fe272d04c8dfde3598bfb05/python/kserve/kserve/model_server.py#L154

**What did you expect to happen:**

This simple workaround makes it possible to run the code on Windows:
```
            # SIGQUIT is not available on Windows
            try:
                sig_list = [signal.SIGINT, signal.SIGTERM, signal.SIGQUIT]
            except:
                sig_list = [signal.SIGINT, signal.SIGTERM]

            # add_signal_handler may not have been implemented
            try:
                for sig in sig_list:
                    loop.add_signal_handler(
                        sig, lambda s=sig: asyncio.create_task(self.stop(sig=s))
                    )
            except:
                pass
```

Even though Windows-based containers are very unlikely to be used for deploying KServe inference services, the ability to run kserve-based code locally on Windows-based machines for development/debugging purposes often comes very handy. I suggest fixing the Windows incompatibility issue in the next release of the kserve Python package.

**Environment:**

- OS (e.g. from `/etc/os-release`): Windows 10



Discussion:

Resolving patch:
diff --git a/python/kserve/kserve/model_server.py b/python/kserve/kserve/model_server.py
--- a/python/kserve/kserve/model_server.py
+++ b/python/kserve/kserve/model_server.py
@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import sys
 import argparse
 import asyncio
 import concurrent.futures
@@ -153,7 +154,12 @@ def start(self, models: Union[List[Model], Dict[str, Deployment]]) -> None:
         async def serve():
             logger.info(f"Starting uvicorn with {self.workers} workers")
             loop = asyncio.get_event_loop()
-            for sig in [signal.SIGINT, signal.SIGTERM, signal.SIGQUIT]:
+            if sys.platform not in ['win32', 'win64']:
+                sig_list = [signal.SIGINT, signal.SIGTERM, signal.SIGQUIT]
+            else:
+                sig_list = [signal.SIGINT, signal.SIGTERM]
+
+            for sig in sig_list:
                 loop.add_signal_handler(
                     sig, lambda s=sig: asyncio.create_task(self.stop(sig=s))
                 )


Test patch:
Repository: kserve/kserve

Issue:
Make post_process async in kserve sdk.
/kind feature

**Describe the solution you'd like**
For [pre_process](https://github.com/kserve/kserve/blob/master/python/kserve/kserve/model.py#L103), [predict](https://github.com/kserve/kserve/blob/master/python/kserve/kserve/model.py#L116) and [explain](https://github.com/kserve/kserve/blob/master/python/kserve/kserve/model.py#L110) , kserve python package supports async by supporting them as coroutines. But it’s not the same for [post_process](https://github.com/kserve/kserve/blob/master/python/kserve/kserve/model.py#L124).

**Use case:**
If anyone is making a call to any other service URL, say to push some metrics or for logging outputs to say some central kafka topic (exposed via API), then that’s 1 use case.


**Anything else you would like to add:**
[Miscellaneous information that will assist in solving the issue.]



Discussion:

Resolving patch:
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
@@ -54,8 +54,11 @@ async def preprocess(self, inputs: Union[Dict, InferRequest],
             return {"instances": [request]}
         raise Exception("unknown event")
 
-    def postprocess(self, response: Union[Dict, InferResponse, ModelInferResponse], headers: Dict[str, str] = None) \
-            -> Union[Dict, ModelInferResponse]:
+    async def postprocess(
+            self,
+            response: Union[Dict, InferResponse, ModelInferResponse],
+            headers: Dict[str, str] = None
+    ) -> Union[Dict, ModelInferResponse]:
         logging.info("response: %s", response)
         index = response["predictions"][0]["classes"]
         logging.info("digit:" + str(index))
diff --git a/python/kserve/kserve/model.py b/python/kserve/kserve/model.py
--- a/python/kserve/kserve/model.py
+++ b/python/kserve/kserve/model.py
@@ -126,7 +126,8 @@ async def __call__(self, body: Union[Dict, CloudEvent, InferRequest],
 
         with POST_HIST_TIME.labels(**prom_labels).time():
             start = time.time()
-            response = self.postprocess(response, headers)
+            response = await self.postprocess(response, headers) if inspect.iscoroutinefunction(self.postprocess) \
+                else self.postprocess(response, headers)
             postprocess_ms = get_latency_ms(start, time.time())
 
         if self.enable_latency_logging is True:
@@ -212,7 +213,7 @@ async def preprocess(self, payload: Union[Dict, InferRequest],
 
         return payload
 
-    def postprocess(self, response: Union[Dict, InferResponse], headers: Dict[str, str] = None) \
+    async def postprocess(self, response: Union[Dict, InferResponse], headers: Dict[str, str] = None) \
             -> Union[Dict, InferResponse]:
         """The postprocess handler can be overridden for inference response transformation.
 


Test patch:
Repository: spyder-ide/spyder

Issue:
Add missing methods to SpyderPluginMixin
_From [contrebasse](https://code.google.com/u/contrebasse/) on 2015-01-15T04:44:22Z_

Spyder Version:  2.4.0dev (4711+: rb5a5ef2bb4d5 )
Python Version:  3.4.2
Qt Version    :  4.8.6, PyQt4 (API v2) 4.11.3 on Linux
pyflakes >=0.6.0:  0.7.3 (OK)
pep8 >=0.6      :  1.5.7 (OK)
IPython >=1.0   :  2.3.1 (OK)
zmq >=2.1.11    :  14.4.1 (OK)
pygments >=1.6  :  2.0.1 (OK)
pandas >=0.13.1 :  0.15.2 (OK)
sphinx >=0.6.6  :  1.2.3 (OK)
psutil >=0.3    :  2.1.3 (OK)
jedi >=0.8.1    :  0.8.1-final0 (OK)
rope >=0.9.2    :  0.9.4-1 (OK)
matplotlib >=1.0:  1.4.2 (OK)
sympy >=0.7.0   :  0.7.6 (OK)
pylint >=0.25   :  1.4.0 (OK) 

What steps will reproduce the problem?
1. open or close files in the editor
   1. quit spyder
   2. start spyder 

What is the expected output? What do you see instead?

 I expect to have the same files opened as before closing spyder. Instead, I see the files that were open when starting spyder the previous time.

I tried to remove the .spuder2-py3 directory, and now each time I start spyder, I see only the dummy temp.py.

Please provide any additional information below

.
Same problem with pyqt and pyside.

_Original issue: http://code.google.com/p/spyderlib/issues/detail?id=2117_



Discussion:
_From [contrebasse](https://code.google.com/u/contrebasse/) on 2015-01-15T02:18:28Z_

OK, looks like it's because of my autopep8 plugin which doesn't have a closing_plugin method, wich is called since https://bitbucket.org/spyder-ide/spyderlib/commits/68b63205844b00e492c69ec8cdc0cd62a246f417 .

So, is this attribute mandatory for plugins ?

_From [contrebasse](https://code.google.com/u/contrebasse/) on 2015-01-15T02:22:47Z_

Adding the method to the plugin fixes the problem.

This should be added to SpyderPluginMixin so definig the method is optional. Same with apply_plugin_settings for example, which should be a no-op by default.

_From [ccordoba12](https://code.google.com/u/ccordoba12/) on 2015-02-08T11:20:25Z_

Could you create a pull request or at least upload a patch with your suggested changes?

I don't exactly understand what I need to do :-)

**Labels:** MS-v2.3.4 Cat-Settings  


Resolving patch:
diff --git a/spyderlib/plugins/__init__.py b/spyderlib/plugins/__init__.py
--- a/spyderlib/plugins/__init__.py
+++ b/spyderlib/plugins/__init__.py
@@ -458,7 +458,7 @@ def closing_plugin(self, cancelable=False):
         Return True or False whether the plugin may be closed immediately or not
         Note: returned value is ignored if *cancelable* is False
         """
-        raise NotImplementedError
+        return True
         
     def refresh_plugin(self):
         """Refresh widget"""


Test patch: