diff --git a/CHANGELOG.md b/CHANGELOG.md index 645a1a0c5..6dae454d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - ### Changed -- +- Change warning condition on loading object saved under different library version ([#31](https://github.com/etna-team/etna/issues/31)) - - - diff --git a/etna/core/mixins.py b/etna/core/mixins.py index a18589be5..ce1160f63 100644 --- a/etna/core/mixins.py +++ b/etna/core/mixins.py @@ -285,7 +285,7 @@ def _validate_metadata(cls, metadata: Dict[str, Any]): saved_etna_version = tuple(metadata["etna_version"]) # if major version is different give a warning - if current_etna_version[0] != saved_etna_version[0] or current_etna_version[:2] < saved_etna_version[:2]: + if current_etna_version != saved_etna_version: current_etna_version_str = ".".join([str(x) for x in current_etna_version]) saved_etna_version_str = ".".join([str(x) for x in saved_etna_version]) warnings.warn( diff --git a/tests/test_core/test_mixins.py b/tests/test_core/test_mixins.py index 7bf283b79..3a27b0d4e 100644 --- a/tests/test_core/test_mixins.py +++ b/tests/test_core/test_mixins.py @@ -65,7 +65,14 @@ def test_save_mixin_load_ok(recwarn, tmp_path): @pytest.mark.parametrize( - "save_version, load_version", [((1, 5, 0), (2, 5, 0)), ((2, 5, 0), (1, 5, 0)), ((1, 5, 0), (1, 3, 0))] + "save_version, load_version", + [ + ((1, 5, 0), (2, 5, 0)), + ((2, 5, 0), (1, 5, 0)), + ((1, 5, 0), (1, 3, 0)), + ((1, 5, 0), (1, 5, 1)), + ((1, 5, 1), (1, 5, 0)), + ], ) @patch("etna.core.mixins.get_etna_version") def test_save_mixin_load_warning(get_version_mock, save_version, load_version, tmp_path): diff --git a/tests/test_ensembles/test_mixins.py b/tests/test_ensembles/test_mixins.py index 95a4d7c1c..93eb19bd3 100644 --- a/tests/test_ensembles/test_mixins.py +++ b/tests/test_ensembles/test_mixins.py @@ -117,7 +117,14 @@ def test_save_mixin_load_ok_with_ts(example_tsds, recwarn, tmp_path): @pytest.mark.parametrize( - "save_version, load_version", [((1, 5, 0), (2, 5, 0)), ((2, 5, 0), (1, 5, 0)), ((1, 5, 0), (1, 3, 0))] + "save_version, load_version", + [ + ((1, 5, 0), (2, 5, 0)), + ((2, 5, 0), (1, 5, 0)), + ((1, 5, 0), (1, 3, 0)), + ((1, 5, 0), (1, 5, 1)), + ((1, 5, 1), (1, 5, 0)), + ], ) @patch("etna.core.mixins.get_etna_version") def test_save_mixin_load_warning(get_version_mock, save_version, load_version, example_tsds, tmp_path): diff --git a/tests/test_experimental/test_prediction_intervals/test_mixins.py b/tests/test_experimental/test_prediction_intervals/test_mixins.py index efb4c8b4e..5d73c49fb 100644 --- a/tests/test_experimental/test_prediction_intervals/test_mixins.py +++ b/tests/test_experimental/test_prediction_intervals/test_mixins.py @@ -76,7 +76,14 @@ def test_load_without_ts(naive_pipeline_with_transforms, recwarn, tmp_path): @pytest.mark.parametrize( - "save_version, load_version", [((1, 5, 0), (2, 5, 0)), ((2, 5, 0), (1, 5, 0)), ((1, 5, 0), (1, 3, 0))] + "save_version, load_version", + [ + ((1, 5, 0), (2, 5, 0)), + ((2, 5, 0), (1, 5, 0)), + ((1, 5, 0), (1, 3, 0)), + ((1, 5, 0), (1, 5, 1)), + ((1, 5, 1), (1, 5, 0)), + ], ) @patch("etna.core.mixins.get_etna_version") def test_save_mixin_load_warning( diff --git a/tests/test_models/test_mixins.py b/tests/test_models/test_mixins.py index eb164aff4..a97f20753 100644 --- a/tests/test_models/test_mixins.py +++ b/tests/test_models/test_mixins.py @@ -316,7 +316,14 @@ def test_save_pf_mixin_with_model_load_ok(recwarn, tmp_path): ], ) @pytest.mark.parametrize( - "save_version, load_version", [((1, 5, 0), (2, 5, 0)), ((2, 5, 0), (1, 5, 0)), ((1, 5, 0), (1, 3, 0))] + "save_version, load_version", + [ + ((1, 5, 0), (2, 5, 0)), + ((2, 5, 0), (1, 5, 0)), + ((1, 5, 0), (1, 3, 0)), + ((1, 5, 0), (1, 5, 1)), + ((1, 5, 1), (1, 5, 0)), + ], ) @patch("etna.core.mixins.get_etna_version") def test_save_mixin_load_warning(get_version_mock, save_version, load_version, dummy, tmp_path): diff --git a/tests/test_pipeline/test_mixins.py b/tests/test_pipeline/test_mixins.py index fb26ef93a..d4ea952aa 100644 --- a/tests/test_pipeline/test_mixins.py +++ b/tests/test_pipeline/test_mixins.py @@ -345,7 +345,14 @@ def test_save_mixin_load_ok_with_ts(example_tsds, recwarn, tmp_path): @pytest.mark.parametrize( - "save_version, load_version", [((1, 5, 0), (2, 5, 0)), ((2, 5, 0), (1, 5, 0)), ((1, 5, 0), (1, 3, 0))] + "save_version, load_version", + [ + ((1, 5, 0), (2, 5, 0)), + ((2, 5, 0), (1, 5, 0)), + ((1, 5, 0), (1, 3, 0)), + ((1, 5, 0), (1, 5, 1)), + ((1, 5, 1), (1, 5, 0)), + ], ) @patch("etna.core.mixins.get_etna_version") def test_save_mixin_load_warning(get_version_mock, save_version, load_version, example_tsds, tmp_path):