Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve kserve protocol version handling #2957

Merged
5 changes: 4 additions & 1 deletion kubernetes/kserve/kserve_wrapper/TorchserveModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ def __init__(
self.inference_address = inference_address
self.management_address = management_address
self.model_dir = model_dir
self.protocol = protocol

# Validate the protocol value passed otherwise, the default value will be used
if protocol is not None:
self.protocol = PredictorProtocol(protocol).value

if self.protocol == PredictorProtocol.GRPC_V2.value:
self.predictor_host = grpc_inference_address
Expand Down
11 changes: 7 additions & 4 deletions kubernetes/kserve/kserve_wrapper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import kserve
from kserve.model_server import ModelServer
from TorchserveModel import TorchserveModel
from TorchserveModel import PredictorProtocol, TorchserveModel
from TSModelRepository import TSModelRepository

logging.basicConfig(level=kserve.constants.KSERVE_LOGLEVEL)
Expand All @@ -15,7 +15,7 @@
DEFAULT_GRPC_INFERENCE_PORT = "7070"

DEFAULT_MODEL_STORE = "/mnt/models/model-store"
CONFIG_PATH = "/mnt/models/config/config.properties"
DEFAULT_CONFIG_PATH = "/mnt/models/config/config.properties"


def parse_config():
Expand All @@ -29,8 +29,11 @@ def parse_config():
"""
separator = "="
keys = {}
config_path = os.environ.get("CONFIG_PATH", DEFAULT_CONFIG_PATH)

with open(CONFIG_PATH) as f:
logging.info(f"Wrapper: loading configuration from {config_path}")

with open(config_path) as f:
for line in f:
if separator in line:
# Find the name and value by splitting the string
Expand Down Expand Up @@ -99,7 +102,7 @@ def parse_config():
model_dir,
) = parse_config()

protocol = os.environ.get("PROTOCOL_VERSION")
protocol = os.environ.get("PROTOCOL_VERSION", PredictorProtocol.REST_V1.value)

models = []

Expand Down
Loading