diff --git a/tests/integration/pipelines/test_rank_and_validate.py b/tests/integration/pipelines/test_rank_and_validate.py index b1f9362..c128d5c 100644 --- a/tests/integration/pipelines/test_rank_and_validate.py +++ b/tests/integration/pipelines/test_rank_and_validate.py @@ -3,11 +3,6 @@ import numpy as np import pandas as pd import pytest -from hydra.core.config_store import ConfigStore -from hydra.utils import instantiate -from omegaconf import DictConfig, open_dict -from sklearn.base import BaseEstimator - from fseval.config import ( CrossValidatorConfig, DatasetConfig, @@ -16,8 +11,13 @@ ResampleConfig, ) from fseval.pipeline.dataset import Dataset, DatasetLoader -from fseval.types import AbstractAdapter, IncompatibilityError, Task +from fseval.types import AbstractAdapter, Task from fseval.utils.hydra_utils import get_config +from hydra.core.config_store import ConfigStore +from hydra.errors import InstantiationException +from hydra.utils import instantiate +from omegaconf import DictConfig, open_dict +from sklearn.base import BaseEstimator cs = ConfigStore.instance() @@ -206,7 +206,7 @@ def test_with_ranker_gt_no_importances_substitution(cfg: PipelineConfig): def test_validator_incompatibility_check(cfg: PipelineConfig): - with pytest.raises(IncompatibilityError): + with pytest.raises(InstantiationException): cfg.dataset.n = 5 cfg.dataset.p = 5 cfg.dataset.multioutput = False @@ -215,7 +215,7 @@ def test_validator_incompatibility_check(cfg: PipelineConfig): def test_ranker_incompatibility_check(cfg: PipelineConfig): - with pytest.raises(IncompatibilityError): + with pytest.raises(InstantiationException): cfg.dataset.n = 5 cfg.dataset.p = 5 cfg.dataset.multioutput = False diff --git a/tests/integration/test_main.py b/tests/integration/test_main.py index d389580..81d64c8 100644 --- a/tests/integration/test_main.py +++ b/tests/integration/test_main.py @@ -7,6 +7,7 @@ from fseval.types import IncompatibilityError from fseval.utils.hydra_utils import get_config from hydra.conf import ConfigStore +from hydra.errors import InstantiationException @pytest.fixture @@ -66,7 +67,7 @@ def test_pipeline_incompatibility(incompatible_cfg: PipelineConfig): """Pipeline should throw IncompatibilityError when trying to run a classification method on a regression dataset.""" - with pytest.raises(IncompatibilityError): + with pytest.raises(InstantiationException): run_pipeline(incompatible_cfg, raise_incompatibility_errors=True) diff --git a/tests/unit/pipeline/test_estimator.py b/tests/unit/pipeline/test_estimator.py index 280f79f..f2cc031 100644 --- a/tests/unit/pipeline/test_estimator.py +++ b/tests/unit/pipeline/test_estimator.py @@ -3,13 +3,14 @@ import pytest from hydra.utils import instantiate +from hydra.errors import InstantiationException from omegaconf import OmegaConf from sklearn.base import BaseEstimator from fseval.config import EstimatorConfig from fseval.pipeline.estimator import Estimator from fseval.storage.local import LocalStorage -from fseval.types import CacheUsage, IncompatibilityError, Task +from fseval.types import CacheUsage, Task @pytest.fixture @@ -79,7 +80,7 @@ def test_incompatibility(estimator_cfg: EstimatorConfig): # classification estimator, but regression task estimator_cfg._estimator_type = "classifier" estimator_cfg.task = Task.regression - with pytest.raises(IncompatibilityError): + with pytest.raises(InstantiationException): instantiate(estimator_cfg) # multioutput, but estimator does not support it (`multioutput=False`) @@ -87,7 +88,7 @@ def test_incompatibility(estimator_cfg: EstimatorConfig): estimator_cfg.task = Task.classification estimator_cfg.multioutput = False estimator_cfg.is_multioutput_dataset = True - with pytest.raises(IncompatibilityError): + with pytest.raises(InstantiationException): instantiate(estimator_cfg) # multioutput only, but @@ -95,7 +96,7 @@ def test_incompatibility(estimator_cfg: EstimatorConfig): estimator_cfg.task = Task.classification estimator_cfg.multioutput_only = True estimator_cfg.is_multioutput_dataset = False - with pytest.raises(IncompatibilityError): + with pytest.raises(InstantiationException): instantiate(estimator_cfg)