Skip to content

Commit

Permalink
Wait for model to be ready in mlserver e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Sivanantham Chinnaiyan <[email protected]>
  • Loading branch information
sivanantha321 committed Feb 13, 2024
1 parent b912981 commit 4cd7a6f
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 10 deletions.
13 changes: 11 additions & 2 deletions test/e2e/helm/test_kserve_sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@
constants
)

from ..common.utils import KSERVE_TEST_NAMESPACE, predict
from ..common.utils import KSERVE_TEST_NAMESPACE, predict, get_cluster_ip


@pytest.mark.helm
def test_sklearn_kserve():
service_name = "isvc-sklearn-helm"
protocol_version = "v2"

predictor = V1beta1PredictorSpec(
min_replicas=1,
Expand All @@ -43,7 +44,7 @@ def test_sklearn_kserve():
),
runtime="kserve-mlserver",
storage_uri="gs://seldon-models/sklearn/mms/lr_model",
protocol_version="v2",
protocol_version=protocol_version,
resources=V1ResourceRequirements(
requests={"cpu": "50m", "memory": "128Mi"},
limits={"cpu": "100m", "memory": "512Mi"},
Expand All @@ -65,6 +66,14 @@ def test_sklearn_kserve():
kserve_client.create(isvc)
kserve_client.wait_isvc_ready(
service_name, namespace=KSERVE_TEST_NAMESPACE)
kserve_client.wait_model_ready(
service_name,
model_name=service_name,
isvc_namespace=KSERVE_TEST_NAMESPACE,
isvc_version=constants.KSERVE_V1BETA1_VERSION,
protocol_version=protocol_version,
cluster_ip=get_cluster_ip(),
)

res = predict(service_name, "./data/iris_input_v2.json",
protocol_version="v2")
Expand Down
13 changes: 11 additions & 2 deletions test/e2e/predictor/test_lightgbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
V1beta1ModelFormat, V1beta1ModelSpec, V1beta1PredictorSpec,
constants)

from ..common.utils import KSERVE_TEST_NAMESPACE, predict, predict_grpc
from ..common.utils import KSERVE_TEST_NAMESPACE, predict, predict_grpc, get_cluster_ip


@pytest.mark.fast
Expand Down Expand Up @@ -104,6 +104,7 @@ def test_lightgbm_runtime_kserve():
@pytest.mark.fast
def test_lightgbm_v2_runtime_mlserver():
service_name = "isvc-lightgbm-v2-runtime"
protocol_version = "v2"

predictor = V1beta1PredictorSpec(
min_replicas=1,
Expand All @@ -113,7 +114,7 @@ def test_lightgbm_v2_runtime_mlserver():
),
runtime="kserve-mlserver",
storage_uri="gs://kfserving-examples/models/lightgbm/v2/iris",
protocol_version="v2",
protocol_version=protocol_version,
resources=V1ResourceRequirements(
requests={"cpu": "50m", "memory": "128Mi"},
limits={"cpu": "1", "memory": "1Gi"},
Expand All @@ -135,6 +136,14 @@ def test_lightgbm_v2_runtime_mlserver():
kserve_client.create(isvc)
kserve_client.wait_isvc_ready(
service_name, namespace=KSERVE_TEST_NAMESPACE)
kserve_client.wait_model_ready(
service_name,
model_name=service_name,
isvc_namespace=KSERVE_TEST_NAMESPACE,
isvc_version=constants.KSERVE_V1BETA1_VERSION,
protocol_version=protocol_version,
cluster_ip=get_cluster_ip(),
)

res = predict(service_name, "./data/iris_input_v2.json",
protocol_version="v2")
Expand Down
25 changes: 22 additions & 3 deletions test/e2e/predictor/test_sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import kserve.protocol.grpc.grpc_predict_v2_pb2 as inference_pb2

from ..common.utils import KSERVE_TEST_NAMESPACE, predict, predict_grpc
from ..common.utils import KSERVE_TEST_NAMESPACE, predict, predict_grpc, get_cluster_ip


@pytest.mark.slow
Expand Down Expand Up @@ -62,11 +62,13 @@ def test_sklearn_kserve():
@pytest.mark.slow
def test_sklearn_v2_mlserver():
service_name = "sklearn-v2-mlserver"
protocol_version = "v2"

predictor = V1beta1PredictorSpec(
min_replicas=1,
sklearn=V1beta1SKLearnSpec(
storage_uri="gs://seldon-models/sklearn/mms/lr_model",
protocol_version="v2",
protocol_version=protocol_version,
resources=V1ResourceRequirements(
requests={"cpu": "50m", "memory": "128Mi"},
limits={"cpu": "100m", "memory": "512Mi"},
Expand All @@ -86,6 +88,14 @@ def test_sklearn_v2_mlserver():
kserve_client = KServeClient(config_file=os.environ.get("KUBECONFIG", "~/.kube/config"))
kserve_client.create(isvc)
kserve_client.wait_isvc_ready(service_name, namespace=KSERVE_TEST_NAMESPACE)
kserve_client.wait_model_ready(
service_name,
model_name=service_name,
isvc_namespace=KSERVE_TEST_NAMESPACE,
isvc_version=constants.KSERVE_V1BETA1_VERSION,
protocol_version=protocol_version,
cluster_ip=get_cluster_ip(),
)

res = predict(service_name, "./data/iris_input_v2.json", protocol_version="v2")
assert res["outputs"][0]["data"] == [1, 1]
Expand Down Expand Up @@ -131,6 +141,7 @@ def test_sklearn_runtime_kserve():
@pytest.mark.slow
def test_sklearn_v2_runtime_mlserver():
service_name = "isvc-sklearn-v2-runtime"
protocol_version = "v2"

predictor = V1beta1PredictorSpec(
min_replicas=1,
Expand All @@ -140,7 +151,7 @@ def test_sklearn_v2_runtime_mlserver():
),
runtime="kserve-mlserver",
storage_uri="gs://seldon-models/sklearn/mms/lr_model",
protocol_version="v2",
protocol_version=protocol_version,
resources=V1ResourceRequirements(
requests={"cpu": "50m", "memory": "128Mi"},
limits={"cpu": "100m", "memory": "512Mi"},
Expand All @@ -160,6 +171,14 @@ def test_sklearn_v2_runtime_mlserver():
kserve_client = KServeClient(config_file=os.environ.get("KUBECONFIG", "~/.kube/config"))
kserve_client.create(isvc)
kserve_client.wait_isvc_ready(service_name, namespace=KSERVE_TEST_NAMESPACE)
kserve_client.wait_model_ready(
service_name,
model_name=service_name,
isvc_namespace=KSERVE_TEST_NAMESPACE,
isvc_version=constants.KSERVE_V1BETA1_VERSION,
protocol_version=protocol_version,
cluster_ip=get_cluster_ip(),
)

res = predict(service_name, "./data/iris_input_v2.json", protocol_version="v2")
assert res["outputs"][0]["data"] == [1, 1]
Expand Down
25 changes: 22 additions & 3 deletions test/e2e/predictor/test_xgboost.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
V1beta1ModelSpec, V1beta1PredictorSpec, V1beta1XGBoostSpec,
constants)

from ..common.utils import KSERVE_TEST_NAMESPACE, predict, predict_grpc
from ..common.utils import KSERVE_TEST_NAMESPACE, predict, predict_grpc, get_cluster_ip


@pytest.mark.fast
Expand Down Expand Up @@ -62,12 +62,14 @@ def test_xgboost_kserve():
@pytest.mark.fast
def test_xgboost_v2_mlserver():
service_name = "isvc-xgboost-v2-mlserver"
protocol_version = "v2"

predictor = V1beta1PredictorSpec(
min_replicas=1,
xgboost=V1beta1XGBoostSpec(
storage_uri="gs://kfserving-examples/models/xgboost/iris",
env=[V1EnvVar(name="MLSERVER_MODEL_PARALLEL_WORKERS", value="0")],
protocol_version="v2",
protocol_version=protocol_version,
resources=V1ResourceRequirements(
requests={"cpu": "50m", "memory": "128Mi"},
limits={"cpu": "100m", "memory": "1024Mi"},
Expand All @@ -89,6 +91,14 @@ def test_xgboost_v2_mlserver():
kserve_client.create(isvc)
kserve_client.wait_isvc_ready(
service_name, namespace=KSERVE_TEST_NAMESPACE)
kserve_client.wait_model_ready(
service_name,
model_name=service_name,
isvc_namespace=KSERVE_TEST_NAMESPACE,
isvc_version=constants.KSERVE_V1BETA1_VERSION,
protocol_version=protocol_version,
cluster_ip=get_cluster_ip(),
)

res = predict(service_name, "./data/iris_input_v2.json",
protocol_version="v2")
Expand Down Expand Up @@ -136,6 +146,7 @@ def test_xgboost_runtime_kserve():
@pytest.mark.fast
def test_xgboost_v2_runtime_mlserver():
service_name = "isvc-xgboost-v2-runtime"
protocol_version = "v2"

predictor = V1beta1PredictorSpec(
min_replicas=1,
Expand All @@ -145,7 +156,7 @@ def test_xgboost_v2_runtime_mlserver():
),
runtime="kserve-mlserver",
storage_uri="gs://kfserving-examples/models/xgboost/iris",
protocol_version="v2",
protocol_version=protocol_version,
resources=V1ResourceRequirements(
requests={"cpu": "50m", "memory": "128Mi"},
limits={"cpu": "100m", "memory": "1024Mi"},
Expand All @@ -167,6 +178,14 @@ def test_xgboost_v2_runtime_mlserver():
kserve_client.create(isvc)
kserve_client.wait_isvc_ready(
service_name, namespace=KSERVE_TEST_NAMESPACE)
kserve_client.wait_model_ready(
service_name,
model_name=service_name,
isvc_namespace=KSERVE_TEST_NAMESPACE,
isvc_version=constants.KSERVE_V1BETA1_VERSION,
protocol_version=protocol_version,
cluster_ip=get_cluster_ip(),
)

res = predict(service_name, "./data/iris_input_v2.json",
protocol_version="v2")
Expand Down

0 comments on commit 4cd7a6f

Please sign in to comment.