You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@submarine.apache.org by wc...@apache.org on 2021/05/10 13:13:34 UTC
[submarine] branch master updated: SUBMARINE-813. Add mock test to
pysubmarine models
This is an automated email from the ASF dual-hosted git repository.
wcjtw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git
The following commit(s) were added to refs/heads/master by this push:
new f0bfa55 SUBMARINE-813. Add mock test to pysubmarine models
f0bfa55 is described below
commit f0bfa55066d5e9520cdbee632d52f8997d2175c9
Author: jeff-901 <54...@users.noreply.github.com>
AuthorDate: Mon May 10 21:13:25 2021 +0800
SUBMARINE-813. Add mock test to pysubmarine models
* SUBMARINE-813. Add mock test to pysubmarine models.
* SUBMARINE-813. Add mock test to pysubmarine models.
* SUBMARINE-813. Fix coding style.
* SUBMARINE-813. Fix coding style.
* SUBMARINE-813. Fix coding style.
* SUBMARINE-813. Fix coding style.
* SUBMARINE-813. Fix coding style.
* SUBMARINE-812. Install local tfjob chart via helm golang API
### What is this PR for?
Install local notebook-controller chart via Helm golang API.
tfjob chart: https://github.com/apache/submarine/tree/master/helm-charts/submarine/charts/tfjob
Helm golang API: https://github.com/apache/submarine/blob/master/submarine-cloud-v2/pkg/helm/helm.go
### What type of PR is it?
Feature
### Todos
### What is the Jira issue?
https://issues.apache.org/jira/projects/SUBMARINE/issues/SUBMARINE-812
### How should this be tested?
https://travis-ci.org/github/noidname01/submarine/builds/769329103
-->
### Screenshots (if appropriate)
Helm install
![helm_all](https://imgur.com/zWGCjhx.png)
In-cluster operator
![operator_all](https://imgur.com/orZLGjj.png)
### Questions:
* Do the license files need updating? No
* Are there breaking changes for older versions? No
* Does this need new documentation? No
Author: noidname01 <ti...@gmail.com>
Signed-off-by: Liu Xun <li...@apache.org>
Closes #578 from noidname01/SUBMARINE-812 and squashes the following commits:
4797fce [noidname01] SUBMARINE-812. Install local tfjob chart via helm golang API
* SUBMARINE-813. Add mock test to pysubmarine models.
* SUBMARINE-813. Add mock test to pysubmarine models.
* SUBMARINE-813. Fix coding style.
* SUBMARINE-813. Fix coding style.
* SUBMARINE-813. Fix coding style.
* SUBMARINE-813. Fix coding style.
* SUBMARINE-813. Fix coding style.
* fix style
* delete unused comments
Co-authored-by: noidname01 <ti...@gmail.com>
---
.../pysubmarine/tests/models/test_model.py | 28 +++++++++++++++-------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/submarine-sdk/pysubmarine/tests/models/test_model.py b/submarine-sdk/pysubmarine/tests/models/test_model.py
index 30fb254..6d4cb8e 100644
--- a/submarine-sdk/pysubmarine/tests/models/test_model.py
+++ b/submarine-sdk/pysubmarine/tests/models/test_model.py
@@ -15,17 +15,15 @@
under the License.
"""
+import mlflow
import numpy as np
import pytest
+from mlflow.tracking import MlflowClient
from pytorch import LinearNNModel
from submarine import ModelsClient
-# Temporarily skip these tests after the following is solved:
-# TODO: Setup cluster by helm in CI/CD to enable mlflow server connection
-# TODO: Set an cooldown time between each test case
-@pytest.mark.skip(reason="no way of currently testing this")
class TestSubmarineModelsClient():
def setUp(self):
@@ -34,29 +32,43 @@ class TestSubmarineModelsClient():
def tearDown(self):
pass
- def test_log_model(self):
+ @pytest.mark.skip(reason="Developing")
+ def test_log_model(self, mocker):
+ mock_method = mocker.patch.object(ModelsClient, "log_model")
client = ModelsClient()
model = LinearNNModel()
name = "simple-nn-model"
client.log_model(name, model)
+ mock_method.assert_called_once_with("simple-nn-model", model)
- def test_update_model(self):
+ def test_update_model(self, mocker):
+ mock_method = mocker.patch.object(MlflowClient,
+ "rename_registered_model")
client = ModelsClient()
name = "simple-nn-model"
new_name = "new-simple-nn-model"
client.update_model(name, new_name)
+ mock_method.assert_called_once_with(name="simple-nn-model",
+ new_name="new-simple-nn-model")
- def test_load_model(self):
+ def test_load_model(self, mocker):
+ mock_method = mocker.patch.object(mlflow.pyfunc, "load_model")
+ mock_method.return_value = mlflow.pytorch._PyTorchWrapper(
+ LinearNNModel())
client = ModelsClient()
name = "simple-nn-model"
version = "1"
model = client.load_model(name, version)
+ mock_method.assert_called_once_with(
+ model_uri="models:/simple-nn-model/1")
x = np.float32([[1.0], [2.0]])
y = model.predict(x)
assert y.shape[0] == 2
assert y.shape[1] == 1
- def test_delete_model(self):
+ def test_delete_model(self, mocker):
+ mock_method = mocker.patch.object(MlflowClient, "delete_model_version")
client = ModelsClient()
name = "simple-nn-model"
client.delete_model(name, '1')
+ mock_method.assert_called_once_with(name="simple-nn-model", version="1")
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@submarine.apache.org
For additional commands, e-mail: dev-help@submarine.apache.org