Skip to content

Commit

Permalink
➕ ➖ Upgrade pytest to 8.0.0 and migrate from pytest-lazy-fixture to p…
Browse files Browse the repository at this point in the history
…ytest-lazy-fixtures (#524)
  • Loading branch information
Galileo-Galilei committed Oct 23, 2024
1 parent 09a550b commit e5472d0
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 52 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

### Added

- :sparkles: Implement missing PipelineML filtering functionalities to let kedro display resume hints and avoid breaking kedro-viz ([#377, Calychas](https://github.com/Galileo-Galilei/kedro-mlflow/pull/377), [#601, Calychas](https://github.com/Galileo-Galilei/kedro-mlflow/pull/601))
- :sparkles: Sanitize parameters name with unsupported characters to avoid mlflow errors when logging ([#595, pascalwhoop](https://github.com/Galileo-Galilei/kedro-mlflow/pull/595))
- :sparkles: Implement missing ``PipelineML`` filtering functionalities to let ``kedro`` display resume hints and avoid breaking ``kedro-viz`` ([#377](https://github.com/Galileo-Galilei/kedro-mlflow/pull/377), [#601, Calychas](https://github.com/Galileo-Galilei/kedro-mlflow/pull/601))
- :sparkles: Sanitize parameters name with unsupported characters to avoid ``mlflow`` errors when logging ([#595, pascalwhoop](https://github.com/Galileo-Galilei/kedro-mlflow/pull/595))

### Changed

- :pushpin: :sparkles: Removed lower and upper bounds for ``python`` versions of to be constantly in sync with ``kedro`` and make migrations faster [#603](https://github.com/Galileo-Galilei/kedro-mlflow/issues/603)
- :pushpin: :sparkles: Removed lower and upper bounds for ``python`` versions of to be constantly in sync with ``kedro`` and make migrations faster ([#603](https://github.com/Galileo-Galilei/kedro-mlflow/issues/603))
- :heavy_plus_sign: :heavy_minus_sign: Removed [``pytest-lazy-fixture``](https://pypi.org/project/pytest-lazy-fixture/) in favor of [``pytest-lazy-fixtures``](https://pypi.org/project/pytest-lazy-fixtures/) which has less reputation but is more up to date. The former has [not been updated in two years](https://github.com/TvoroG/pytest-lazy-fixture/issues/63) and is [not compatible with recent pytest](https://github.com/TvoroG/pytest-lazy-fixture/issues). ([#524](https://github.com/Galileo-Galilei/kedro-mlflow/issues/524), [#604](https://github.com/Galileo-Galilei/kedro-mlflow/issues/604))

## [0.13.2] - 2024-10-15

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def _parse_requirements(path, encoding="utf-8"):
"myst-parser>=0.17.2,<4.1.0",
],
"test": [
"pytest>=5.4.0, <8.0.0", # pytest==8.0.0 breaks pytest-lazy-fixture : https://github.com/TvoroG/pytest-lazy-fixture/issues/65
"pytest>=5.4.0, <9.0.0", # pytest==8.0.0 breaks pytest-lazy-fixture : https://github.com/TvoroG/pytest-lazy-fixture/issues/65
"pytest-cov>=2.8.0, <6.0.0",
"pytest-lazy-fixture>=0.6.0, <1.0.0",
"pytest-lazy-fixtures>=1.0.0, <2.0.0",
"pytest-mock>=3.1.0, <4.0.0",
"ruff>=0.5.0,<0.8.0", # ensure consistency with pre-commit
"scikit-learn>=0.23.0, <1.6.0",
Expand Down
3 changes: 2 additions & 1 deletion tests/config/test_get_mlflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from kedro.framework.project import _IsSubclassValidator, _ProjectSettings
from kedro.framework.session import KedroSession
from kedro.framework.startup import bootstrap_project
from pytest_lazy_fixtures import lf


def _write_yaml(filepath, config):
Expand Down Expand Up @@ -199,7 +200,7 @@ def fake_project(tmp_path, local_logging_config):
"project_settings",
[
"",
pytest.lazy_fixture("mock_settings_omega_config_loader_class"),
lf("mock_settings_omega_config_loader_class"),
],
)
def test_mlflow_config_correctly_set(kedro_project, project_settings):
Expand Down
7 changes: 4 additions & 3 deletions tests/framework/cli/test_cli_modelify.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from kedro.framework.cli.starters import TEMPLATE_PATH
from kedro.framework.session import KedroSession
from kedro.framework.startup import bootstrap_project
from pytest_lazy_fixtures import lf

from kedro_mlflow.framework.cli.cli import (
modelify as cli_modelify, # import after changing the path to avoid registering the project, else import pippeliens does not work!
Expand Down Expand Up @@ -228,10 +229,10 @@ def register_pipelines():
@pytest.mark.parametrize(
"example_repo,artifacts_list,inside_subdirectory",
[
(pytest.lazy_fixture("kp_for_modelify"), ["trained_model"], False),
(pytest.lazy_fixture("kp_for_modelify"), ["trained_model"], True),
(lf("kp_for_modelify"), ["trained_model"], False),
(lf("kp_for_modelify"), ["trained_model"], True),
(
pytest.lazy_fixture("kp_for_modelify_with_parameters"),
lf("kp_for_modelify_with_parameters"),
["trained_model", "params:my_param"],
False,
),
Expand Down
11 changes: 6 additions & 5 deletions tests/framework/hooks/test_hook_pipeline_ml.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from kedro_datasets.pickle import PickleDataset
from mlflow.models import infer_signature
from mlflow.tracking import MlflowClient
from pytest_lazy_fixtures import lf

from kedro_mlflow.framework.hooks.mlflow_hook import MlflowHook
from kedro_mlflow.pipeline import pipeline_ml_factory
Expand Down Expand Up @@ -236,8 +237,8 @@ def dummy_catalog_dataset_factory(tmp_path):
@pytest.mark.parametrize(
"pipeline_to_run",
[
(pytest.lazy_fixture("dummy_pipeline")),
(pytest.lazy_fixture("dummy_pipeline_ml")),
(lf("dummy_pipeline")),
(lf("dummy_pipeline_ml")),
],
)
def test_mlflow_hook_save_pipeline_ml(
Expand Down Expand Up @@ -502,10 +503,10 @@ def test_mlflow_hook_save_pipeline_ml_with_parameters(
"model_signature,expected_signature",
(
[None, None],
["auto", pytest.lazy_fixture("dummy_signature")],
["auto", lf("dummy_signature")],
[
pytest.lazy_fixture("dummy_signature"),
pytest.lazy_fixture("dummy_signature"),
lf("dummy_signature"),
lf("dummy_signature"),
],
),
)
Expand Down
18 changes: 9 additions & 9 deletions tests/io/artifacts/test_mlflow_artifact_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from kedro_datasets.pandas import CSVDataset
from kedro_datasets.partitions import PartitionedDataset
from kedro_datasets.pickle import PickleDataset
from pytest_lazyfixture import lazy_fixture
from pytest_lazy_fixtures import lf

from kedro_mlflow.io.artifacts import MlflowArtifactDataset

Expand All @@ -28,17 +28,17 @@ def df2():
@pytest.mark.parametrize(
"dataset,extension,data,artifact_path",
[
(CSVDataset, ".csv", lazy_fixture("df1"), None),
("pandas.CSVDataset", ".csv", lazy_fixture("df1"), None),
(PickleDataset, ".pkl", lazy_fixture("df1"), None),
("pickle.PickleDataset", ".pkl", lazy_fixture("df1"), None),
(CSVDataset, ".csv", lazy_fixture("df1"), "artifact_dir"),
("pandas.CSVDataset", ".csv", lazy_fixture("df1"), "artifact_dir"),
(PickleDataset, ".pkl", lazy_fixture("df1"), "artifact_dir"),
(CSVDataset, ".csv", lf("df1"), None),
("pandas.CSVDataset", ".csv", lf("df1"), None),
(PickleDataset, ".pkl", lf("df1"), None),
("pickle.PickleDataset", ".pkl", lf("df1"), None),
(CSVDataset, ".csv", lf("df1"), "artifact_dir"),
("pandas.CSVDataset", ".csv", lf("df1"), "artifact_dir"),
(PickleDataset, ".pkl", lf("df1"), "artifact_dir"),
(
"pickle.PickleDataset",
".pkl",
lazy_fixture("df1"),
lf("df1"),
"artifact_dir",
),
],
Expand Down
14 changes: 7 additions & 7 deletions tests/io/metrics/test_mlflow_metrics_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
from kedro.io import DatasetError
from mlflow.tracking import MlflowClient
from pytest_lazyfixture import lazy_fixture
from pytest_lazy_fixtures import lf

from kedro_mlflow.io.metrics import MlflowMetricsHistoryDataset

Expand Down Expand Up @@ -67,12 +67,12 @@ def metrics3():
@pytest.mark.parametrize(
"data, prefix",
[
(lazy_fixture("metrics"), None),
(lazy_fixture("metrics"), "test"),
(lazy_fixture("metrics2"), None),
(lazy_fixture("metrics2"), "test"),
(lazy_fixture("metrics3"), None),
(lazy_fixture("metrics3"), "test"),
(lf("metrics"), None),
(lf("metrics"), "test"),
(lf("metrics2"), None),
(lf("metrics2"), "test"),
(lf("metrics3"), None),
(lf("metrics3"), "test"),
],
)
def test_mlflow_metrics_dataset_saved_and_logged(mlflow_client, data, prefix):
Expand Down
5 changes: 3 additions & 2 deletions tests/io/models/test_mlflow_model_local_filesystem_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from kedro.io import DataCatalog, MemoryDataset
from kedro.pipeline import Pipeline, node
from kedro_datasets.pickle import PickleDataset
from pytest_lazy_fixtures import lf
from sklearn.linear_model import LinearRegression

from kedro_mlflow.io.models import MlflowModelLocalFileSystemDataset
Expand Down Expand Up @@ -150,8 +151,8 @@ def test_save_load_local(linreg_path, linreg_model, versioned):
@pytest.mark.parametrize(
"pipeline",
[
(pytest.lazy_fixture("pipeline_ml_obj")), # must work for PipelineML
(pytest.lazy_fixture("pipeline_inference")), # must work for Pipeline
(lf("pipeline_ml_obj")), # must work for PipelineML
(lf("pipeline_inference")), # must work for Pipeline
],
)
def test_pyfunc_flavor_python_model_save_and_load(
Expand Down
5 changes: 3 additions & 2 deletions tests/io/models/test_mlflow_model_tracking_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from kedro.io.core import DatasetError
from kedro.pipeline import Pipeline, node
from kedro_datasets.pickle import PickleDataset
from pytest_lazy_fixtures import lf
from sklearn.linear_model import LinearRegression

from kedro_mlflow.io.models import MlflowModelTrackingDataset
Expand Down Expand Up @@ -265,8 +266,8 @@ def test_load_without_run_id_nor_active_run(tracking_uri):
@pytest.mark.parametrize(
"pipeline",
[
(pytest.lazy_fixture("pipeline_ml_obj")), # must work for PipelineML
(pytest.lazy_fixture("pipeline_inference")), # must work for Pipeline
(lf("pipeline_ml_obj")), # must work for PipelineML
(lf("pipeline_inference")), # must work for Pipeline
],
)
def test_pyfunc_flavor_python_model_save_and_load(
Expand Down
33 changes: 17 additions & 16 deletions tests/mlflow/test_kedro_pipeline_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from kedro.io import DataCatalog, MemoryDataset
from kedro.pipeline import Pipeline, node
from kedro_datasets.pickle import PickleDataset
from pytest_lazy_fixtures import lf
from sklearn.linear_model import LinearRegression

from kedro_mlflow.io.models import MlflowModelLocalFileSystemDataset
Expand Down Expand Up @@ -475,26 +476,26 @@ def predict_fun(model, data):
"pipeline,catalog,input_name,result",
[
(
pytest.lazy_fixture("pipeline_inference_dummy"),
pytest.lazy_fixture("dummy_catalog"),
lf("pipeline_inference_dummy"),
lf("dummy_catalog"),
"raw_data",
{"raw_data", "model"},
),
(
pytest.lazy_fixture("pipeline_inference_with_intermediary_artifacts"),
pytest.lazy_fixture("catalog_with_encoder"),
lf("pipeline_inference_with_intermediary_artifacts"),
lf("catalog_with_encoder"),
"raw_data",
{"raw_data", "model", "encoder"},
),
(
pytest.lazy_fixture("pipeline_inference_with_inputs_artifacts"),
pytest.lazy_fixture("catalog_with_stopwords"),
lf("pipeline_inference_with_inputs_artifacts"),
lf("catalog_with_stopwords"),
"data",
{"data", "model", "stopwords_from_nltk"},
),
(
pytest.lazy_fixture("pipeline_inference_with_parameters"),
pytest.lazy_fixture("catalog_with_parameters"),
lf("pipeline_inference_with_parameters"),
lf("catalog_with_parameters"),
"data",
{
"data",
Expand Down Expand Up @@ -548,26 +549,26 @@ def test_catalog_extraction_unpersisted_inference_input(pipeline_inference_dummy
"pipeline,catalog,input_name,result",
[
(
pytest.lazy_fixture("pipeline_inference_dummy"),
pytest.lazy_fixture("dummy_catalog"),
lf("pipeline_inference_dummy"),
lf("dummy_catalog"),
"raw_data",
pd.DataFrame([1, 2, 3]),
),
(
pytest.lazy_fixture("pipeline_inference_with_intermediary_artifacts"),
pytest.lazy_fixture("catalog_with_encoder"),
lf("pipeline_inference_with_intermediary_artifacts"),
lf("catalog_with_encoder"),
"raw_data",
pd.DataFrame([1, 2, 3]),
),
(
pytest.lazy_fixture("pipeline_inference_with_inputs_artifacts"),
pytest.lazy_fixture("catalog_with_stopwords"),
lf("pipeline_inference_with_inputs_artifacts"),
lf("catalog_with_stopwords"),
"data",
pd.DataFrame([1, 2, 3]),
),
(
pytest.lazy_fixture("pipeline_inference_with_parameters"),
pytest.lazy_fixture("catalog_with_parameters"),
lf("pipeline_inference_with_parameters"),
lf("catalog_with_parameters"),
"data",
pd.DataFrame([0, 1, 1]),
),
Expand Down
5 changes: 3 additions & 2 deletions tests/pipeline/test_pipeline_ml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from kedro.io import DataCatalog, MemoryDataset
from kedro.pipeline import Pipeline, node, pipeline
from kedro_datasets.pandas import CSVDataset
from pytest_lazy_fixtures import lf

from kedro_mlflow.pipeline import pipeline_ml_factory
from kedro_mlflow.pipeline.pipeline_ml import KedroMlflowPipelineMLError, PipelineML
Expand Down Expand Up @@ -475,8 +476,8 @@ def test_pipeline_ml_filtering(
@pytest.mark.parametrize(
"pipeline_ml_obj",
[
pytest.lazy_fixture("pipeline_ml_with_tag"),
pytest.lazy_fixture("pipeline_ml_with_intermediary_artifacts"),
lf("pipeline_ml_with_tag"),
lf("pipeline_ml_with_intermediary_artifacts"),
],
)
@pytest.mark.parametrize(
Expand Down

0 comments on commit e5472d0

Please sign in to comment.