Skip to content

Commit 7121770

Browse files
Jake VanderPlascopybara-github
Jake VanderPlas
authored andcommitted
fix: avoid hard-coding the LinearRegression class name in tests
PiperOrigin-RevId: 728769030
1 parent e729a59 commit 7121770

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tests/unit/aiplatform/test_metadata_models.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
)
7777

7878

79+
_LINEAR_REGRESSION_CLASS = f"{LinearRegression.__module__}.LinearRegression"
80+
81+
7982
@pytest.fixture
8083
def mock_datetime_now(monkeypatch):
8184
class DateTime(datetime.datetime):
@@ -205,7 +208,7 @@ def mock_load_tensorflow_module_model():
205208
"frameworkName": "sklearn",
206209
"frameworkVersion": "1.0",
207210
"modelFile": "model.pkl",
208-
"modelClass": "sklearn.linear_model._base.LinearRegression",
211+
"modelClass": _LINEAR_REGRESSION_CLASS,
209212
},
210213
)
211214

@@ -380,7 +383,7 @@ def test_save_model_sklearn(
380383
"frameworkName": "sklearn",
381384
"frameworkVersion": sklearn.__version__,
382385
"modelFile": "model.pkl",
383-
"modelClass": "sklearn.linear_model._base.LinearRegression",
386+
"modelClass": _LINEAR_REGRESSION_CLASS,
384387
},
385388
state=GapicArtifact.State.LIVE,
386389
)
@@ -433,7 +436,7 @@ def test_save_model_with_all_args(
433436
"frameworkName": "sklearn",
434437
"frameworkVersion": sklearn.__version__,
435438
"modelFile": "model.pkl",
436-
"modelClass": "sklearn.linear_model._base.LinearRegression",
439+
"modelClass": _LINEAR_REGRESSION_CLASS,
437440
"predictSchemata": {"instanceSchemaUri": f"{_TEST_URI}/instance.yaml"},
438441
},
439442
state=GapicArtifact.State.LIVE,
@@ -879,7 +882,7 @@ def test_get_experiment_model_info(self):
879882
model_info = experiment_model.get_model_info()
880883

881884
expected_model_info = {
882-
"model_class": "sklearn.linear_model._base.LinearRegression",
885+
"model_class": _LINEAR_REGRESSION_CLASS,
883886
"framework_name": "sklearn",
884887
"framework_version": "1.0",
885888
"input_example": {

0 commit comments

Comments
 (0)