From 376502396f2f518218f404cb74ebdbd7247804c4 Mon Sep 17 00:00:00 2001 From: Clive Cox Date: Thu, 4 Apr 2019 10:30:00 +0100 Subject: [PATCH 1/4] Add tests for parameters --- .gitignore | 1 + python/.coverage | Bin 98304 -> 0 bytes python/seldon_core/microservice.py | 16 +++++++++++++++- python/tests/test_microservice.py | 18 ++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) delete mode 100644 python/.coverage diff --git a/.gitignore b/.gitignore index 8deb9719d1..4fe6a7a536 100644 --- a/.gitignore +++ b/.gitignore @@ -189,3 +189,4 @@ doc/source/_static/cluster-manager python/build/ python/dist/ testing/scripts/proto +python/.coverage \ No newline at end of file diff --git a/python/.coverage b/python/.coverage deleted file mode 100644 index 55b0da67e9157f1f0b706ebcc498deeb7cb2e3d5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 98304 zcmeFa2bdK_x2W9}y4LO;$vF%;=bW=5Ip+*R&L9E?*g2RnCsZT}V$L~WPADkm98pnJ zFrxpeu3G1O-t&LwIrsA2=Re1P^XSw&z4!EVt?7AZ*Q!;uM~@t`V0CH9++{15%v@d4 z&MD(C=JYNpaU3Uv|5w5P=^r3S`UG3{5B$$C&T*w)y9=)JKD(OS`b zWLe~B__oMEJY4)&j6g90#RwE5P>et^0>uavBT$S$F#`XiBQP-pm8(`|@yP0#vlf@G zUO97i=}Pl4+;7x?K4S)yjOo*N$bb@atfX@S zbtQ{R*EOeStu9@=x}-_Gf(Mn$muHEXf9{zpXXAgtznm2h{Kr!^FPXgzPri2bKYW|! zC39CUTe5T+eOvri%l`4RQR5kUeWY6_#qS*0F^6NWbp<5)h}MKv{e5e_{;U{BmdP7=;!`dFWEd7 zFSb!YRqj^tpIxke+VnR1qqo3?%GIm0coY9>Z2)bf{&LOsAYS%A`zg{h^v|Gqi4Cni zh}YCYsmgt-|Fdhd&zs)H0!$Jnj+Ol@(?22ozx>NJ=_CKi1udVsdVa}Yu0|ix;gSDY zc>KGejsE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3@MJmleQdFwVKvGmH&ft@9cUHp30hePb;4=7LzSsHi zozPN{04-Yr-^#Vc@Qu(S_*!To>=ar65*=pqL88NKHhd``odsVAodKTd zrocx+<1iH(ixPZNH66>f5vYZRBMJ>e5ITZJQuD70Dyb_%L$NG01S6rr@S#v&*df#& zJ`hUbeIX6+2_d{I1n?Ij1@8z|;BBEYyj9<>8T`3^DeVG(5b6wX3U!1xg!X{fg?5J* zg*w0sLha!tq21tlp?2_^P+NFTs0}KGOHe|{D1tn{*xK{n;aEzrIyuWW@uSGX1b2ThgWFXL#DJGzYkY0!tVlJi2n$< z3cn5L@SA`ZzYcgQ?hJS_eiiTnl)Yq5McGT{6qLPWrlRa6b27?aGP6lf_91m@H0;z+^d71}4jyLNHmT zl!D1Jr5H>$59MI81t|!VO-4zWY%+?%WNT3tCL4;vFxgO)hRKGaI7~Ja0vj5M_2j&g>@?HOS-GNCnA%``F5U&JR;}2c_PX`-7JP_=(v~1oTQ!a<)O#8K|9~fL$pyl h-_1j`K|9~hLv)>XzMqF^y>`B#hiIL4)9Un#{{=E0c2WQU diff --git a/python/seldon_core/microservice.py b/python/seldon_core/microservice.py index c6577e07ee..28d82e57cc 100644 --- a/python/seldon_core/microservice.py +++ b/python/seldon_core/microservice.py @@ -11,6 +11,7 @@ from seldon_core.flask_utils import ANNOTATIONS_FILE import seldon_core.wrapper as seldon_microservice from typing import Dict, Callable +from seldon_core.flask_utils import SeldonMicroserviceException logger = logging.getLogger(__name__) @@ -70,7 +71,16 @@ def parse_parameters(parameters: Dict) -> Dict: if type_ == "BOOL": parsed_parameters[name] = bool(strtobool(value)) else: - parsed_parameters[name] = type_dict[type_](value) + try: + parsed_parameters[name] = type_dict[type_](value) + except ValueError: + raise SeldonMicroserviceException( + "Bad model parameter: " + name + " with value " + value + " can't be parsed as a " + type_, + reason="MICROSERVICE_BAD_PARAMETER") + except KeyError: + raise SeldonMicroserviceException( + "Bad model parameter type: " + type_ + " valid are INT, FLOAT, DOUBLE, STRING, BOOL", + reason="MICROSERVICE_BAD_PARAMETER") return parsed_parameters @@ -167,6 +177,7 @@ def main(): log_level_num = getattr(logging, args.log_level.upper(), None) if not isinstance(log_level_num, int): raise ValueError('Invalid log level: %s', args.log_level) + logger.setLevel(log_level_num) logger.debug("Log level set to %s:%s", args.log_level, log_level_num) @@ -185,6 +196,9 @@ def main(): # set log level for the imported microservice type seldon_microservice.logger.setLevel(log_level_num) + logging.getLogger().setLevel(log_level_num) + for handler in logger.handlers: + handler.setLevel(log_level_num) port = int(os.environ.get(SERVICE_PORT_ENV_NAME, DEFAULT_PORT)) diff --git a/python/tests/test_microservice.py b/python/tests/test_microservice.py index 4a2d60cbdb..14f016305a 100644 --- a/python/tests/test_microservice.py +++ b/python/tests/test_microservice.py @@ -8,9 +8,12 @@ import pytest from seldon_core.proto import prediction_pb2 from seldon_core.proto import prediction_pb2_grpc +import seldon_core.microservice as microservice +from seldon_core.flask_utils import SeldonMicroserviceException import grpc import numpy as np import signal +import unittest @contextmanager def start_microservice(app_location,tracing=False,grpc=False,envs={}): @@ -116,6 +119,7 @@ def test_model_template_app_grpc(tracing): feedback = prediction_pb2.Feedback(request=request,reward=1.0) response = stub.SendFeedback(request=request) + def test_model_template_app_tracing_config(): envs = {"JAEGER_CONFIG_PATH":join(dirname(__file__), "tracing_config/tracing.yaml")} with start_microservice(join(dirname(__file__), "model-template-app"),tracing=True,envs=envs): @@ -133,3 +137,17 @@ def test_model_template_app_tracing_config(): "http://127.0.0.1:5000/send-feedback", params="json=%s" % data) response.raise_for_status() assert response.json() == {'data': {'ndarray': []}, 'meta': {}} + + +def test_model_template_bad_params(): + + params = [join(dirname(__file__), "model-template-app"),"seldon-core-microservice","REST","--parameters",'[{"type":"FLOAT","name":"foo","value":"abc"}]'] + with unittest.mock.patch('sys.argv',params): + with pytest.raises(SeldonMicroserviceException): + microservice.main() + +def test_model_template_bad_params_type(): + params = [join(dirname(__file__), "model-template-app"),"seldon-core-microservice","REST","--parameters",'[{"type":"FOO","name":"foo","value":"abc"}]'] + with unittest.mock.patch('sys.argv',params): + with pytest.raises(SeldonMicroserviceException): + microservice.main() \ No newline at end of file From 7784e85db2d9f7b0295eadf6dd8109bded3b0b70 Mon Sep 17 00:00:00 2001 From: Clive Cox Date: Thu, 4 Apr 2019 15:40:43 +0100 Subject: [PATCH 2/4] Fix status update on failed deployments --- .../k8s/SeldonDeploymentStatusUpdateImpl.java | 2 +- .../k8s/SeldonDeploymentStatusUpdateTest.java | 29 ++++++++- .../src/test/resources/model_failed.json | 61 +++++++++++++++++++ 3 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 cluster-manager/src/test/resources/model_failed.json diff --git a/cluster-manager/src/main/java/io/seldon/clustermanager/k8s/SeldonDeploymentStatusUpdateImpl.java b/cluster-manager/src/main/java/io/seldon/clustermanager/k8s/SeldonDeploymentStatusUpdateImpl.java index fe8f1df7a5..192cad27a0 100644 --- a/cluster-manager/src/main/java/io/seldon/clustermanager/k8s/SeldonDeploymentStatusUpdateImpl.java +++ b/cluster-manager/src/main/java/io/seldon/clustermanager/k8s/SeldonDeploymentStatusUpdateImpl.java @@ -105,7 +105,7 @@ public void updateStatus(String mlDepName, String version, String depName, Integ { logger.info(String.format("UPDATE %s : %s %d %d",mlDepName,depName,replicas,replicasAvailable)); SeldonDeployment mlDep = crdHandler.getSeldonDeployment(mlDepName,version, namespace); - if (mlDep != null) + if (mlDep != null && !(mlDep.getStatus().hasState() && mlDep.getStatus().getState().equals(Constants.STATE_FAILED))) { SeldonDeployment.Builder mlBuilder = SeldonDeployment.newBuilder(mlDep); diff --git a/cluster-manager/src/test/java/io/seldon/clustermanager/k8s/SeldonDeploymentStatusUpdateTest.java b/cluster-manager/src/test/java/io/seldon/clustermanager/k8s/SeldonDeploymentStatusUpdateTest.java index f4e70e6372..cc4b551826 100644 --- a/cluster-manager/src/test/java/io/seldon/clustermanager/k8s/SeldonDeploymentStatusUpdateTest.java +++ b/cluster-manager/src/test/java/io/seldon/clustermanager/k8s/SeldonDeploymentStatusUpdateTest.java @@ -6,6 +6,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static org.mockito.Mockito.never; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -53,9 +54,32 @@ public void updateAvailableTest() throws IOException supdate.updateStatus(selDepName, version, "test-deployment-fx-market-predictor-8e1d76f", 1, 1, namespace); + verify(mockCrdHandler,times(1)).getSeldonDeployment(eq(selDepName), eq(version), eq(namespace)); + verify(mockCrdHandler,times(1)).updateSeldonDeploymentStatus(any(SeldonDeployment.class)); + + } + + @Test + public void updateAvailableOnFailedTest() throws IOException + { + createMocks(); + + String jsonStr = readFile("src/test/resources/model_failed.json",StandardCharsets.UTF_8); + SeldonDeployment sDep = SeldonDeploymentUtils.jsonToSeldonDeployment(jsonStr); + + when(mockCrdHandler.getSeldonDeployment(any(String.class), any(String.class), any(String.class))).thenReturn(sDep); + + SeldonDeploymentStatusUpdate supdate = new SeldonDeploymentStatusUpdateImpl(mockCrdHandler, mockSeldonDeploymentController, props); + + final String selDepName = "SeldonDep1"; + final String version = "v1alpha1"; + final String namespace = "seldon"; + + supdate.updateStatus(selDepName, version, "test-deployment-fx-market-predictor-8e1d76f", 1, 1, namespace); + verify(mockCrdHandler,times(1)).getSeldonDeployment(eq(selDepName), eq(version), eq(namespace)); ArgumentCaptor argument = ArgumentCaptor.forClass(SeldonDeployment.class); - verify(mockCrdHandler,times(1)).updateSeldonDeploymentStatus(argument.capture()); + verify(mockCrdHandler,never()).updateSeldonDeploymentStatus(argument.capture()); SeldonDeployment sDepUpdated = argument.getAllValues().get(0); Assert.assertEquals(1, sDepUpdated.getStatus().getPredictorStatusCount()); @@ -63,6 +87,7 @@ public void updateAvailableTest() throws IOException Assert.assertEquals("Available", sDepUpdated.getStatus().getState()); } + @Test public void twoUpdatesTest() throws IOException { @@ -126,5 +151,7 @@ public void removeTest() throws IOException Assert.assertEquals("", sDepUpdated.getStatus().getState()); } + + } diff --git a/cluster-manager/src/test/resources/model_failed.json b/cluster-manager/src/test/resources/model_failed.json new file mode 100644 index 0000000000..0c0ed309ac --- /dev/null +++ b/cluster-manager/src/test/resources/model_failed.json @@ -0,0 +1,61 @@ +{ + "apiVersion": "machinelearning.seldon.io/v1alpha3", + "kind": "SeldonDeployment", + "metadata": { + "creationTimestamp": "2019-04-04T14:33:08Z", + "generation": 1, + "labels": { + "app": "seldon" + }, + "name": "seldon-model", + "namespace": "seldon", + "resourceVersion": "6700", + "selfLink": "/apis/machinelearning.seldon.io/v1alpha3/namespaces/seldon/seldondeployments/seldon-model", + "uid": "9101adcf-56e6-11e9-865f-ec5f8735c09f" + }, + "spec": { + "name": "test-deployment", + "oauth_key": "oauth-key", + "oauth_secret": "oauth-secret", + "predictors": [ + { + "componentSpecs": [ + { + "spec": { + "containers": [ + { + "imagePullPolicy": "IfNotPresent", + "image": "seldonio/mock_classifier:1.0", + "name": "classifier", + "resources": { + "requests": { + "memory": "1Mi" + } + } + } + ], + "terminationGracePeriodSeconds": 1 + } + } + ], + "graph": { + "children": [], + "endpoint": { + "type": "REST" + }, + "name": "classifier", + "type": "MODEL" + }, + "labels": { + "version": "v1" + }, + "name": "example", + "replicas": 1 + } + ] + }, + "status": { + "description": "Cannot find field: imagename in message k8s.io.api.core.v1.Container", + "state": "Failed" + } +} From 55e48496f3b710a3550f955591f699aece266258 Mon Sep 17 00:00:00 2001 From: Clive Cox Date: Thu, 4 Apr 2019 15:49:48 +0100 Subject: [PATCH 3/4] fixes bad principal in apife #454 --- .../java/io/seldon/apife/deployments/DeploymentStore.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api-frontend/src/main/java/io/seldon/apife/deployments/DeploymentStore.java b/api-frontend/src/main/java/io/seldon/apife/deployments/DeploymentStore.java index c0da1f76d1..f0e37ae96f 100644 --- a/api-frontend/src/main/java/io/seldon/apife/deployments/DeploymentStore.java +++ b/api-frontend/src/main/java/io/seldon/apife/deployments/DeploymentStore.java @@ -60,7 +60,10 @@ private void init() throws Exception{ public SeldonDeployment getDeployment(String clientId) { - return deploymentStore.get(clientId); + if (clientId != null) + return deploymentStore.get(clientId); + else + return null; } @Override From 0df7c981a39d8daf2240556bb448653911bac7fe Mon Sep 17 00:00:00 2001 From: Clive Cox Date: Thu, 4 Apr 2019 16:06:40 +0100 Subject: [PATCH 4/4] fic status update tests --- .../k8s/SeldonDeploymentStatusUpdateTest.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/cluster-manager/src/test/java/io/seldon/clustermanager/k8s/SeldonDeploymentStatusUpdateTest.java b/cluster-manager/src/test/java/io/seldon/clustermanager/k8s/SeldonDeploymentStatusUpdateTest.java index cc4b551826..d9d81eb218 100644 --- a/cluster-manager/src/test/java/io/seldon/clustermanager/k8s/SeldonDeploymentStatusUpdateTest.java +++ b/cluster-manager/src/test/java/io/seldon/clustermanager/k8s/SeldonDeploymentStatusUpdateTest.java @@ -78,13 +78,7 @@ public void updateAvailableOnFailedTest() throws IOException supdate.updateStatus(selDepName, version, "test-deployment-fx-market-predictor-8e1d76f", 1, 1, namespace); verify(mockCrdHandler,times(1)).getSeldonDeployment(eq(selDepName), eq(version), eq(namespace)); - ArgumentCaptor argument = ArgumentCaptor.forClass(SeldonDeployment.class); - verify(mockCrdHandler,never()).updateSeldonDeploymentStatus(argument.capture()); - - SeldonDeployment sDepUpdated = argument.getAllValues().get(0); - Assert.assertEquals(1, sDepUpdated.getStatus().getPredictorStatusCount()); - Assert.assertEquals(1, sDepUpdated.getStatus().getPredictorStatus(0).getReplicasAvailable()); - Assert.assertEquals("Available", sDepUpdated.getStatus().getState()); + verify(mockCrdHandler,never()).updateSeldonDeploymentStatus(any(SeldonDeployment.class)); }