From 666bced900193bc7b8d834129ef74b87eb1c3abf Mon Sep 17 00:00:00 2001 From: Adrian Gonzalez-Martin Date: Thu, 5 Aug 2021 15:18:13 +0200 Subject: [PATCH 1/5] Bump mlserver to 0.4.0 --- conda/tempo-examples.yaml | 2 +- tempo/seldon/constants.py | 2 +- tempo/serve/constants.py | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/conda/tempo-examples.yaml b/conda/tempo-examples.yaml index 4da7b189..c88edc55 100644 --- a/conda/tempo-examples.yaml +++ b/conda/tempo-examples.yaml @@ -14,7 +14,7 @@ dependencies: - alibi==0.5.7 - alibi-detect==0.6.0 - dill - - mlserver==0.3.2 + - mlserver==0.4.0 - xgboost - ansible - openshift diff --git a/tempo/seldon/constants.py b/tempo/seldon/constants.py index 5fabb12f..3e9877fa 100644 --- a/tempo/seldon/constants.py +++ b/tempo/seldon/constants.py @@ -1,2 +1,2 @@ -MLSERVER_IMAGE = "seldonio/mlserver:0.3.2" +MLSERVER_IMAGE = "seldonio/mlserver:0.4.0" TRITON_IMAGE = "nvcr.io/nvidia/tritonserver:20.08-py3" diff --git a/tempo/serve/constants.py b/tempo/serve/constants.py index d2493fa7..de9e2354 100644 --- a/tempo/serve/constants.py +++ b/tempo/serve/constants.py @@ -8,7 +8,7 @@ DefaultRemoteFilename = "remote.pickle" DefaultEnvFilename = "environment.tar.gz" -MLServerEnvDeps = ["mlserver==0.3.2"] +MLServerEnvDeps = ["mlserver==0.4.0"] DefaultCondaFile = "conda.yaml" ENV_K8S_SERVICE_HOST = "KUBERNETES_SERVICE_HOST" @@ -23,7 +23,9 @@ DefaultInsightsLocalEndpoint = "http://0.0.0.0:8080" DefaultInsightsDockerEndpoint = f"http://{DefaultInsightsServiceName}:8080" DefaultSeldonSystemNamespace = "seldon-system" -DefaultInsightsK8sEndpoint = f"http://{DefaultInsightsServiceName}.{DefaultSeldonSystemNamespace}:8080" +DefaultInsightsK8sEndpoint = ( + f"http://{DefaultInsightsServiceName}.{DefaultSeldonSystemNamespace}:8080" +) DefaultRedisServiceName = "redis-master" From b50a2154c849c921400dd2aaa1168000836ffb25 Mon Sep 17 00:00:00 2001 From: Adrian Gonzalez-Martin Date: Thu, 5 Aug 2021 15:44:49 +0200 Subject: [PATCH 2/5] Bump mlserver to 0.4.0 on most examples --- docs/examples/asyncio/artifacts/classifier/conda.yaml | 2 +- docs/examples/custom-model/artifacts/conda.yaml | 2 +- docs/examples/explainer/artifacts/explainer/conda.yaml | 2 +- docs/examples/kfserving/artifacts/classifier/conda.yaml | 2 +- docs/examples/logging-insights/artifacts/conda.yaml | 2 +- docs/examples/logging-insights/conda.yaml | 2 +- docs/examples/multi-model/artifacts/classifier/conda.yaml | 2 +- docs/examples/outlier/artifacts/outlier/conda.yaml | 2 +- docs/examples/outlier/artifacts/svc/conda.yaml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/examples/asyncio/artifacts/classifier/conda.yaml b/docs/examples/asyncio/artifacts/classifier/conda.yaml index 7d087c21..69817b85 100644 --- a/docs/examples/asyncio/artifacts/classifier/conda.yaml +++ b/docs/examples/asyncio/artifacts/classifier/conda.yaml @@ -5,4 +5,4 @@ dependencies: - python=3.7.9 - pip: - mlops-tempo - - mlserver==0.3.2 + - mlserver==0.4.0 diff --git a/docs/examples/custom-model/artifacts/conda.yaml b/docs/examples/custom-model/artifacts/conda.yaml index e5918643..15bdc931 100644 --- a/docs/examples/custom-model/artifacts/conda.yaml +++ b/docs/examples/custom-model/artifacts/conda.yaml @@ -5,5 +5,5 @@ dependencies: - python=3.7.9 - pip: - mlops-tempo - - mlserver==0.3.2 + - mlserver==0.4.0 - numpyro==0.6.0 diff --git a/docs/examples/explainer/artifacts/explainer/conda.yaml b/docs/examples/explainer/artifacts/explainer/conda.yaml index ce1dbf05..875f212f 100644 --- a/docs/examples/explainer/artifacts/explainer/conda.yaml +++ b/docs/examples/explainer/artifacts/explainer/conda.yaml @@ -7,4 +7,4 @@ dependencies: - alibi==0.5.8 - dill - mlops-tempo - - mlserver==0.3.2 + - mlserver==0.4.0 diff --git a/docs/examples/kfserving/artifacts/classifier/conda.yaml b/docs/examples/kfserving/artifacts/classifier/conda.yaml index 9fc2310e..7dd962e5 100644 --- a/docs/examples/kfserving/artifacts/classifier/conda.yaml +++ b/docs/examples/kfserving/artifacts/classifier/conda.yaml @@ -5,4 +5,4 @@ dependencies: - python=3.7.9 - pip: - mlops-tempo - - mlserver==0.3.2 + - mlserver==0.4.0 diff --git a/docs/examples/logging-insights/artifacts/conda.yaml b/docs/examples/logging-insights/artifacts/conda.yaml index 5e18f36a..89301d60 100644 --- a/docs/examples/logging-insights/artifacts/conda.yaml +++ b/docs/examples/logging-insights/artifacts/conda.yaml @@ -6,4 +6,4 @@ dependencies: - python=3.7.9 - pip: - mlops-tempo @ file:///home/clive/work/mlops/fork-tempo - - mlserver==0.3.2 + - mlserver==0.4.0 diff --git a/docs/examples/logging-insights/conda.yaml b/docs/examples/logging-insights/conda.yaml index c45fc00e..bf715059 100644 --- a/docs/examples/logging-insights/conda.yaml +++ b/docs/examples/logging-insights/conda.yaml @@ -6,4 +6,4 @@ dependencies: - python=3.7.9 - pip: - mlops-tempo @ file:///home/alejandro/Programming/kubernetes/seldon/tempo - - mlserver==0.3.1.dev7 + - mlserver==0.4.0 diff --git a/docs/examples/multi-model/artifacts/classifier/conda.yaml b/docs/examples/multi-model/artifacts/classifier/conda.yaml index 9fc2310e..7dd962e5 100644 --- a/docs/examples/multi-model/artifacts/classifier/conda.yaml +++ b/docs/examples/multi-model/artifacts/classifier/conda.yaml @@ -5,4 +5,4 @@ dependencies: - python=3.7.9 - pip: - mlops-tempo - - mlserver==0.3.2 + - mlserver==0.4.0 diff --git a/docs/examples/outlier/artifacts/outlier/conda.yaml b/docs/examples/outlier/artifacts/outlier/conda.yaml index c649ccc6..031ec8b6 100644 --- a/docs/examples/outlier/artifacts/outlier/conda.yaml +++ b/docs/examples/outlier/artifacts/outlier/conda.yaml @@ -8,4 +8,4 @@ dependencies: - dill==0.3.2 - opencv-python-headless - mlops-tempo - - mlserver==0.3.2 + - mlserver==0.4.0 diff --git a/docs/examples/outlier/artifacts/svc/conda.yaml b/docs/examples/outlier/artifacts/svc/conda.yaml index 9fc2310e..7dd962e5 100644 --- a/docs/examples/outlier/artifacts/svc/conda.yaml +++ b/docs/examples/outlier/artifacts/svc/conda.yaml @@ -5,4 +5,4 @@ dependencies: - python=3.7.9 - pip: - mlops-tempo - - mlserver==0.3.2 + - mlserver==0.4.0 From 03352654055397c702170c42c2af50893d9e079f Mon Sep 17 00:00:00 2001 From: Adrian Gonzalez-Martin Date: Thu, 5 Aug 2021 16:18:42 +0200 Subject: [PATCH 3/5] Fix linter --- tempo/serve/constants.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tempo/serve/constants.py b/tempo/serve/constants.py index de9e2354..8c55ab0e 100644 --- a/tempo/serve/constants.py +++ b/tempo/serve/constants.py @@ -23,9 +23,7 @@ DefaultInsightsLocalEndpoint = "http://0.0.0.0:8080" DefaultInsightsDockerEndpoint = f"http://{DefaultInsightsServiceName}:8080" DefaultSeldonSystemNamespace = "seldon-system" -DefaultInsightsK8sEndpoint = ( - f"http://{DefaultInsightsServiceName}.{DefaultSeldonSystemNamespace}:8080" -) +DefaultInsightsK8sEndpoint = f"http://{DefaultInsightsServiceName}.{DefaultSeldonSystemNamespace}:8080" DefaultRedisServiceName = "redis-master" From 6eb964d3de1663d385576da1f06f9d9b8dc1f700 Mon Sep 17 00:00:00 2001 From: Adrian Gonzalez-Martin Date: Thu, 5 Aug 2021 16:27:30 +0200 Subject: [PATCH 4/5] Fix tests --- tests/test_mlserver.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/test_mlserver.py b/tests/test_mlserver.py index 624134ba..934c9bb6 100644 --- a/tests/test_mlserver.py +++ b/tests/test_mlserver.py @@ -4,7 +4,7 @@ import pytest from mlserver.settings import ModelSettings from mlserver.types import InferenceRequest, RequestInput -from mlserver.utils import to_ndarray +from mlserver.codecs import NumpyCodec from pytest_cases import fixture, parametrize_with_cases from pytest_cases.common_pytest_lazy_values import is_lazy @@ -16,7 +16,11 @@ @pytest.fixture def inference_request() -> InferenceRequest: - return InferenceRequest(inputs=[RequestInput(name="payload", shape=[4], data=[1, 2, 3, 4], datatype="FP32")]) + return InferenceRequest( + inputs=[ + RequestInput(name="payload", shape=[4], data=[1, 2, 3, 4], datatype="FP32") + ] + ) @fixture @@ -40,7 +44,9 @@ async def test_load(mlserver_runtime: InferenceRuntime): assert isinstance(mlserver_runtime._model, BaseModel) -async def test_predict(mlserver_runtime: InferenceRuntime, inference_request: InferenceRequest): +async def test_predict( + mlserver_runtime: InferenceRuntime, inference_request: InferenceRequest +): # NOTE: pytest-cases doesn't wait for async fixtures # TODO: Raise issue in pytest-cases repo mlserver_runtime = await mlserver_runtime @@ -48,7 +54,8 @@ async def test_predict(mlserver_runtime: InferenceRuntime, inference_request: In assert len(res.outputs) == 1 - pipeline_input = to_ndarray(inference_request.inputs[0]) + codec = NumpyCodec() + pipeline_input = codec.decode(inference_request.inputs[0]) custom_model = copy.copy(mlserver_runtime._model) # Ensure direct call to class does not try to do remote custom_model.set_remote(False) @@ -58,11 +65,14 @@ async def test_predict(mlserver_runtime: InferenceRuntime, inference_request: In pipeline_output = res.outputs[0].data - assert expected_output.tolist() == pipeline_output + assert expected_output.tolist() == pipeline_output.__root__ -async def test_load_wrapped_class(inference_pipeline_class, inference_request: InferenceRequest): - pipeline_input = to_ndarray(inference_request.inputs[0]) +async def test_load_wrapped_class( + inference_pipeline_class, inference_request: InferenceRequest +): + codec = NumpyCodec() + pipeline_input = codec.decode(inference_request.inputs[0]) inference_pipeline_class(pipeline_input) assert inference_pipeline_class.counter == 1 From 7fbc38ff47afdfdc07cebaf9e5f21fd291ddd790 Mon Sep 17 00:00:00 2001 From: Adrian Gonzalez-Martin Date: Thu, 5 Aug 2021 16:35:22 +0200 Subject: [PATCH 5/5] Fix linter --- tests/test_mlserver.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/tests/test_mlserver.py b/tests/test_mlserver.py index 934c9bb6..7c70ee0a 100644 --- a/tests/test_mlserver.py +++ b/tests/test_mlserver.py @@ -2,9 +2,9 @@ from inspect import iscoroutine import pytest +from mlserver.codecs import NumpyCodec from mlserver.settings import ModelSettings from mlserver.types import InferenceRequest, RequestInput -from mlserver.codecs import NumpyCodec from pytest_cases import fixture, parametrize_with_cases from pytest_cases.common_pytest_lazy_values import is_lazy @@ -16,11 +16,7 @@ @pytest.fixture def inference_request() -> InferenceRequest: - return InferenceRequest( - inputs=[ - RequestInput(name="payload", shape=[4], data=[1, 2, 3, 4], datatype="FP32") - ] - ) + return InferenceRequest(inputs=[RequestInput(name="payload", shape=[4], data=[1, 2, 3, 4], datatype="FP32")]) @fixture @@ -44,9 +40,7 @@ async def test_load(mlserver_runtime: InferenceRuntime): assert isinstance(mlserver_runtime._model, BaseModel) -async def test_predict( - mlserver_runtime: InferenceRuntime, inference_request: InferenceRequest -): +async def test_predict(mlserver_runtime: InferenceRuntime, inference_request: InferenceRequest): # NOTE: pytest-cases doesn't wait for async fixtures # TODO: Raise issue in pytest-cases repo mlserver_runtime = await mlserver_runtime @@ -68,9 +62,7 @@ async def test_predict( assert expected_output.tolist() == pipeline_output.__root__ -async def test_load_wrapped_class( - inference_pipeline_class, inference_request: InferenceRequest -): +async def test_load_wrapped_class(inference_pipeline_class, inference_request: InferenceRequest): codec = NumpyCodec() pipeline_input = codec.decode(inference_request.inputs[0])