diff --git a/go.mod b/go.mod index 9ad10c636e1..326217cfe73 100644 --- a/go.mod +++ b/go.mod @@ -18,8 +18,8 @@ require ( github.com/google/uuid v1.1.1 github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8 github.com/json-iterator/go v1.1.10 - github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a // indirect github.com/kelseyhightower/envconfig v1.4.0 + github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a // indirect github.com/onsi/ginkgo v1.14.0 github.com/onsi/gomega v1.10.2 github.com/pkg/errors v0.9.1 @@ -39,6 +39,7 @@ require ( istio.io/gogo-genproto v0.0.0-20191029161641-f7d19ec0141d // indirect k8s.io/api v0.18.8 k8s.io/apimachinery v0.18.8 + k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible k8s.io/klog v1.0.0 k8s.io/kube-openapi v0.0.0-20200410145947-bcb3869e6f29 knative.dev/networking v0.0.0-20200922180040-a71b40c69b15 diff --git a/python/kfserving/kfserving/api/kf_serving_client.py b/python/kfserving/kfserving/api/kf_serving_client.py index 1205dafa17f..784f34542cb 100644 --- a/python/kfserving/kfserving/api/kf_serving_client.py +++ b/python/kfserving/kfserving/api/kf_serving_client.py @@ -373,6 +373,30 @@ def wait_isvc_ready(self, name, namespace=None, # pylint:disable=too-many-argum raise RuntimeError("Timeout to start the InferenceService {}. \ The InferenceService is as following: {}".format(name, current_isvc)) + def create_trained_model(self, trainedmodel, namespace): + """ + Create a trained model + :param trainedmodel: trainedmodel object + :param namespace: defaults to current or default namespace + :return: + """ + + if trainedmodel.api_version == constants.KFSERVING_V1ALPHA2: + logging.warning("The version v1alpha2 will be deprecated from KFServing 0.6 release.") + version = trainedmodel.api_version.split("/")[1] + + try: + outputs = self.api_instance.create_namespaced_custom_object( + constants.KFSERVING_GROUP, + version, + namespace, + constants.KFSERVING_PLURAL_TRAINEDMODEL, + trainedmodel) + except client.rest.ApiException as e: + raise RuntimeError( + "Exception when calling CustomObjectsApi->create_namespaced_custom_object:\ + %s\n" % e) + def wait_model_ready(self, service_name, model_name, isvc_namespace=None, # pylint:disable=too-many-arguments isvc_version=constants.KFSERVING_V1BETA1_VERSION, cluster_ip=None, diff --git a/test/e2e/predictor/test_multi_model_serving.py b/test/e2e/predictor/test_multi_model_serving.py index c1ea59c5370..558414324e7 100644 --- a/test/e2e/predictor/test_multi_model_serving.py +++ b/test/e2e/predictor/test_multi_model_serving.py @@ -32,7 +32,6 @@ from ..common.utils import predict, get_cluster_ip from ..common.utils import KFSERVING_TEST_NAMESPACE -api_v1alpha1_version = constants.KFSERVING_GROUP + "/v1alpha1" api_v1beta1_version = constants.KFSERVING_GROUP + "/" + constants.KFSERVING_V1BETA1_VERSION KFServing = KFServingClient(config_file=os.environ.get("KUBECONFIG", "~/.kube/config")) @@ -50,7 +49,7 @@ def test_mms_sklearn_kfserving(): ) ) - service_name = "isvc-sklearn" + service_name = "isvc-sklearn-mms" isvc = V1beta1InferenceService( api_version=api_v1beta1_version, kind=constants.KFSERVING_KIND, @@ -77,7 +76,7 @@ def test_mms_sklearn_kfserving(): model1_name = "model1-sklearn" model2_name = "model2-sklearn" model1 = V1alpha1TrainedModel( - api_version=api_v1alpha1_version, + api_version=constants.KFSERVING_V1ALPHA1, kind=constants.KFSERVING_KIND_TRAINEDMODEL, metadata=client.V1ObjectMeta( name=model1_name, @@ -90,7 +89,7 @@ def test_mms_sklearn_kfserving(): ) model2 = V1alpha1TrainedModel( - api_version=api_v1alpha1_version, + api_version=constants.KFSERVING_V1ALPHA1, kind=constants.KFSERVING_KIND_TRAINEDMODEL, metadata=client.V1ObjectMeta( name=model2_name, @@ -103,14 +102,12 @@ def test_mms_sklearn_kfserving(): ) # Create an instance of inference service with isvc - KFServing.create(isvc, version=constants.KFSERVING_V1BETA1_VERSION) + KFServing.create(isvc) KFServing.wait_isvc_ready(service_name, namespace=KFSERVING_TEST_NAMESPACE) # Create instances of trained models using model1 and model2 - KFServing.create(model1, namespace=KFSERVING_TEST_NAMESPACE, version=constants.KFSERVING_V1ALPHA1_VERSION, - plural=constants.KFSERVING_PLURAL_TRAINEDMODEL) - KFServing.create(model2, namespace=KFSERVING_TEST_NAMESPACE, version=constants.KFSERVING_V1ALPHA1_VERSION, - plural=constants.KFSERVING_PLURAL_TRAINEDMODEL) + KFServing.create_trained_model(model1, KFSERVING_TEST_NAMESPACE) + KFServing.create_trained_model(model2, KFSERVING_TEST_NAMESPACE) cluster_ip = get_cluster_ip() @@ -142,7 +139,7 @@ def test_mms_xgboost_kfserving(): ) ) - service_name = "isvc-xgboost" + service_name = "isvc-xgboost-mms" isvc = V1beta1InferenceService( api_version=api_v1beta1_version, kind=constants.KFSERVING_KIND, @@ -169,7 +166,7 @@ def test_mms_xgboost_kfserving(): model1_name = "model1-xgboost" model2_name = "model2-xgboost" model1 = V1alpha1TrainedModel( - api_version=api_v1alpha1_version, + api_version=constants.KFSERVING_V1ALPHA1, kind=constants.KFSERVING_KIND_TRAINEDMODEL, metadata=client.V1ObjectMeta( name=model1_name, @@ -182,7 +179,7 @@ def test_mms_xgboost_kfserving(): ) model2 = V1alpha1TrainedModel( - api_version=api_v1alpha1_version, + api_version=constants.KFSERVING_V1ALPHA1, kind=constants.KFSERVING_KIND_TRAINEDMODEL, metadata=client.V1ObjectMeta( name=model2_name, @@ -195,14 +192,12 @@ def test_mms_xgboost_kfserving(): ) # Create an instance of inference service with isvc - KFServing.create(isvc, version=constants.KFSERVING_V1BETA1_VERSION) + KFServing.create(isvc) KFServing.wait_isvc_ready(service_name, namespace=KFSERVING_TEST_NAMESPACE) # Create instances of trained models using model1 and model2 - KFServing.create(model1, namespace=KFSERVING_TEST_NAMESPACE, version=constants.KFSERVING_V1ALPHA1_VERSION, - plural=constants.KFSERVING_PLURAL_TRAINEDMODEL) - KFServing.create(model2, namespace=KFSERVING_TEST_NAMESPACE, version=constants.KFSERVING_V1ALPHA1_VERSION, - plural=constants.KFSERVING_PLURAL_TRAINEDMODEL) + KFServing.create_trained_model(model1, KFSERVING_TEST_NAMESPACE) + KFServing.create_trained_model(model2, KFSERVING_TEST_NAMESPACE) cluster_ip = get_cluster_ip()