Skip to content

Commit 0becce8

Browse files
committed
test: stabilize experimental and observability tests
1 parent 441b1f2 commit 0becce8

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

tests/test_models.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import pytest
1515
from sklearn.model_selection import train_test_split
1616

17+
from deeptab import set_seed
1718
from deeptab.models import (
1819
ENODELSS,
1920
MLPLSS,
@@ -434,6 +435,8 @@ def test_tabtransformer_fit_predict(cls, task, classification_data_with_cat, reg
434435

435436
@pytest.mark.parametrize("cls", EXPERIMENTAL_CLASSIFIERS)
436437
def test_experimental_classifier_fit_predict_evaluate(cls, classification_data):
438+
# Experimental models are numerically less stable; seed for deterministic CI.
439+
set_seed(RANDOM_STATE)
437440
X_train, X_test, y_train, y_test = classification_data
438441
model = cls()
439442
model.fit(X_train, y_train, **FIT_KWARGS)
@@ -460,6 +463,8 @@ def test_experimental_classifier_fit_predict_evaluate(cls, classification_data):
460463

461464
@pytest.mark.parametrize("cls", EXPERIMENTAL_REGRESSORS)
462465
def test_experimental_regressor_fit_predict_evaluate(cls, regression_data):
466+
# Experimental models are numerically less stable; seed for deterministic CI.
467+
set_seed(RANDOM_STATE)
463468
X_train, X_test, y_train, y_test = regression_data
464469
model = cls()
465470
model.fit(X_train, y_train, **FIT_KWARGS)
@@ -476,6 +481,8 @@ def test_experimental_regressor_fit_predict_evaluate(cls, regression_data):
476481

477482
@pytest.mark.parametrize("cls", EXPERIMENTAL_LSS_MODELS)
478483
def test_experimental_lss_fit_predict_evaluate(cls, regression_data):
484+
# Experimental models are numerically less stable; seed for deterministic CI.
485+
set_seed(RANDOM_STATE)
479486
X_train, X_test, y_train, y_test = regression_data
480487
model = cls()
481488
model.fit(X_train, y_train, family="normal", **FIT_KWARGS)

tests/test_observability.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ def test_build_lightning_loggers_tensorboard_absent(monkeypatch):
177177
def test_build_lightning_loggers_user_logger_does_not_replace(monkeypatch):
178178
"""User-provided logger is appended alongside built-in trackers."""
179179
user_logger = _FakeLogger()
180+
# Stub the optional tensorboard import guard so the test does not depend on
181+
# the 'tensorboard' package being installed in the environment.
182+
fake_tb_mod = ModuleType("torch.utils.tensorboard")
183+
fake_tb_mod.SummaryWriter = MagicMock() # type: ignore[attr-defined]
184+
monkeypatch.setitem(sys.modules, "torch.utils.tensorboard", fake_tb_mod)
180185
# Mock TensorBoardLogger
181186
fake_tb = MagicMock()
182187
fake_lpl = MagicMock()

0 commit comments

Comments
 (0)