Skip to content

Commit 9cdcecb

Browse files
Fix image building test for batch job (#579)
<!-- Thanks for sending a pull request! Here are some tips for you: 1. Run unit tests and ensure that they are passing 2. If your change introduces any API changes, make sure to update the e2e tests 3. Make sure documentation is updated for your PR! --> # Description <!-- Briefly describe the motivation for the change. Please include illustrations where appropriate. --> The image building test for batch job requires the model artifact to be available first (trained and saved in a path). This PR fixes the missing step training and saving the model artifact mentioned above. # Modifications <!-- Summarize the key code changes. --> Add model training step first before image building test. # Tests <!-- Besides the existing / updated automated tests, what specific scenarios should be tested? Consider the backward compatibility of the changes, whether corner cases are covered, etc. Please describe the tests and check the ones that have been completed. Eg: - [x] Deploying new and existing standard models - [ ] Deploying PyFunc models --> # Checklist - [ ] Added PR label - [ ] Added unit test, integration, and/or e2e tests - [x] Tested locally - [ ] Updated documentation - [ ] Update Swagger spec if the PR introduce API changes - [ ] Regenerated Golang and Python client if the PR introduces API changes # Release Notes <!-- Does this PR introduce a user-facing change? If no, just write "NONE" in the release-note block below. If yes, a release note is required. Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required". For more information about release notes, see kubernetes' guide here: http://git.k8s.io/community/contributors/guide/release-notes.md --> ```release-note ```
1 parent f83200e commit 9cdcecb

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

python/sdk/test/build_image_integration_test.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
from test.batch_integration_test import IrisClassifier
1+
from test.batch_integration_test import (
2+
MODEL_PATH,
3+
MODEL_PATH_ARTIFACT_KEY,
4+
IrisClassifier,
5+
)
26
from test.pyfunc_integration_test import EnvVarModel
37

4-
import merlin
8+
import joblib
59
import pytest
10+
from sklearn import svm
11+
from sklearn.datasets import load_iris
12+
13+
import merlin
614
from merlin.model import ModelType
715

816

@@ -34,12 +42,18 @@ def test_build_image_batch(integration_test_url, project_name, use_google_oauth)
3442
merlin.set_project(project_name)
3543
merlin.set_model("build-image-batch", ModelType.PYFUNC_V2)
3644

45+
clf = svm.SVC(gamma="scale")
46+
iris = load_iris()
47+
X, y = iris.data, iris.target
48+
clf.fit(X, y)
49+
joblib.dump(clf, MODEL_PATH)
50+
3751
with merlin.new_model_version() as v:
3852
v.log_pyfunc_model(
3953
model_instance=IrisClassifier(),
4054
conda_env="test/batch/model/env.yaml",
4155
code_dir=["test"],
42-
artifacts={"model_path": "test/batch/model/model.joblib"},
56+
artifacts={MODEL_PATH_ARTIFACT_KEY: MODEL_PATH},
4357
)
4458

4559
image = merlin.build_image(v)

0 commit comments

Comments
 (0)