mirror of
https://github.com/hanzo-ml/kserve.git
synced 2026-10-30 20:53:49 +00:00
* Add client sdk for localmodelcache, localmodelnodegroup Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Add e2e test for modelcache Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Use docker driver and minikube tunnel Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Merge "Allow multiple node groups in the model cache CR (#4134)" Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Try mounting image dir Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Add local model agent to image scan Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Debug Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Create model root directory beforehand Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Restart kserve controller after patch Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Enablepvc direct mount in e2e test Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Reduce pv storage to 1GB Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Update modelcache test Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Update status-check to include modelcache logs Signed-off-by: Sivanantham Chinnaiyan <[email protected]> --------- Signed-off-by: Sivanantham Chinnaiyan <[email protected]>
105 lines
3.7 KiB
Python
105 lines
3.7 KiB
Python
# Copyright 2022 The KServe Authors.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import os
|
|
import numpy as np
|
|
from kubernetes import client
|
|
from kserve import KServeClient
|
|
from kserve import constants
|
|
from kserve import V1beta1PredictorSpec
|
|
from kserve import V1beta1TFServingSpec
|
|
from kserve import V1beta1InferenceServiceSpec
|
|
from kserve import V1beta1InferenceService
|
|
from kserve import V1beta1ModelSpec, V1beta1ModelFormat
|
|
from kubernetes.client import V1ResourceRequirements
|
|
import pytest
|
|
|
|
from ..common.utils import predict_isvc
|
|
from ..common.utils import KSERVE_TEST_NAMESPACE
|
|
|
|
|
|
@pytest.mark.predictor
|
|
@pytest.mark.asyncio(scope="session")
|
|
async def test_tensorflow_kserve(rest_v1_client):
|
|
service_name = "isvc-tensorflow"
|
|
predictor = V1beta1PredictorSpec(
|
|
min_replicas=1,
|
|
tensorflow=V1beta1TFServingSpec(
|
|
storage_uri="gs://kfserving-examples/models/tensorflow/flowers",
|
|
resources=V1ResourceRequirements(
|
|
requests={"cpu": "10m", "memory": "256Mi"},
|
|
limits={"cpu": "100m", "memory": "512Mi"},
|
|
),
|
|
),
|
|
)
|
|
|
|
isvc = V1beta1InferenceService(
|
|
api_version=constants.KSERVE_V1BETA1,
|
|
kind=constants.KSERVE_KIND_INFERENCESERVICE,
|
|
metadata=client.V1ObjectMeta(
|
|
name=service_name, namespace=KSERVE_TEST_NAMESPACE
|
|
),
|
|
spec=V1beta1InferenceServiceSpec(predictor=predictor),
|
|
)
|
|
|
|
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)
|
|
res = await predict_isvc(rest_v1_client, service_name, "./data/flower_input.json")
|
|
assert np.argmax(res["predictions"][0].get("scores")) == 0
|
|
|
|
# Delete the InferenceService
|
|
kserve_client.delete(service_name, namespace=KSERVE_TEST_NAMESPACE)
|
|
|
|
|
|
@pytest.mark.predictor
|
|
@pytest.mark.asyncio(scope="session")
|
|
async def test_tensorflow_runtime_kserve(rest_v1_client):
|
|
service_name = "isvc-tensorflow-runtime"
|
|
predictor = V1beta1PredictorSpec(
|
|
min_replicas=1,
|
|
model=V1beta1ModelSpec(
|
|
model_format=V1beta1ModelFormat(
|
|
name="tensorflow",
|
|
),
|
|
storage_uri="gs://kfserving-examples/models/tensorflow/flowers",
|
|
resources=V1ResourceRequirements(
|
|
requests={"cpu": "10m", "memory": "256Mi"},
|
|
limits={"cpu": "100m", "memory": "512Mi"},
|
|
),
|
|
),
|
|
)
|
|
|
|
isvc = V1beta1InferenceService(
|
|
api_version=constants.KSERVE_V1BETA1,
|
|
kind=constants.KSERVE_KIND_INFERENCESERVICE,
|
|
metadata=client.V1ObjectMeta(
|
|
name=service_name, namespace=KSERVE_TEST_NAMESPACE
|
|
),
|
|
spec=V1beta1InferenceServiceSpec(predictor=predictor),
|
|
)
|
|
|
|
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)
|
|
res = await predict_isvc(rest_v1_client, service_name, "./data/flower_input.json")
|
|
assert np.argmax(res["predictions"][0].get("scores")) == 0
|
|
|
|
# Delete the InferenceService
|
|
kserve_client.delete(service_name, namespace=KSERVE_TEST_NAMESPACE)
|