Skip to content

Commit

Permalink
Remove distutils from Python SDK (kubeflow#3010)
Browse files Browse the repository at this point in the history
* Remove distutils from Python SDK

Signed-off-by: Xin Fu <xfu83@bloomberg.net>

* Clean up extra bracket

Signed-off-by: Xin Fu <xfu83@bloomberg.net>

---------

Signed-off-by: Xin Fu <xfu83@bloomberg.net>
  • Loading branch information
xfu83 authored Jul 1, 2023
1 parent b60c7b1 commit 99a6e36
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
9 changes: 4 additions & 5 deletions python/kserve/kserve/model_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import multiprocessing
import signal
import socket
from distutils.util import strtobool
from multiprocessing import Process
from typing import Dict, List, Optional, Union

Expand Down Expand Up @@ -48,13 +47,13 @@
help="The number of max processing threads in each worker.")
parser.add_argument('--max_asyncio_workers', default=None, type=int,
help='Max number of asyncio workers to spawn')
parser.add_argument("--enable_grpc", default=True, type=lambda x: bool(strtobool(x)),
parser.add_argument("--enable_grpc", default=True, type=lambda x: utils.strtobool(x),
help="Enable gRPC for the model server")
parser.add_argument("--enable_docs_url", default=False, type=lambda x: bool(strtobool(x)),
parser.add_argument("--enable_docs_url", default=False, type=lambda x: utils.strtobool(x),
help="Enable docs url '/docs' to display Swagger UI.")
parser.add_argument("--enable_latency_logging", default=True, type=lambda x: bool(strtobool(x)),
parser.add_argument("--enable_latency_logging", default=True, type=lambda x: utils.strtobool(x),
help="Output a log per request with latency metrics.")
parser.add_argument("--configure_logging", default=True, type=lambda x: bool(strtobool(x)),
parser.add_argument("--configure_logging", default=True, type=lambda x: utils.strtobool(x),
help="Whether to configure KServe and Uvicorn logging")
parser.add_argument("--log_config_file", default=None, type=str,
help="File path containing UvicornServer's log config. Needs to be a yaml or json file.")
Expand Down
19 changes: 19 additions & 0 deletions python/kserve/kserve/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,22 @@ def get_predict_response(payload: Union[Dict, InferRequest], result: Union[np.nd
infer_outputs=infer_outputs,
response_id=generate_uuid()
)


def strtobool(val: str) -> bool:
"""Convert a string representation of truth to True or False.
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.
Adapted from deprecated `distutils`
https://github.com/python/cpython/blob/3.11/Lib/distutils/util.py
"""
val = val.lower()
if val in ('y', 'yes', 't', 'true', 'on', '1'):
return True
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
return False
else:
raise ValueError("invalid truth value %r" % (val,))

0 comments on commit 99a6e36

Please sign in to comment.