From 9adf4a4913cecf0acbc2ce35c2dfecb5b3530a59 Mon Sep 17 00:00:00 2001 From: Sebastian Weigand Date: Mon, 27 Mar 2023 23:13:31 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=F0=9F=9A=80=20Prepare=200.7.0=20re?= =?UTF-8?q?lease=20(#1250)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ๐Ÿš€ Changed version from 0.7.0.dev0 to 0.7.0 * ๐Ÿงช๐Ÿฉน Changed deprecation_warning_on_call_test_helper to always raise OverDueDeprecation * ๐Ÿ—‘๏ธ๐Ÿงน Removed deprecations due in 0.7.0 * ๐Ÿงน Cleanup changelog for release --- changelog.md | 4 +- glotaran/__init__.py | 2 +- glotaran/builtin/io/yml/yml.py | 2 - .../deprecation/modules/builtin_io_yml.py | 143 ------------------ glotaran/deprecation/modules/test/__init__.py | 8 +- .../modules/test/test_builtin_io_yml.py | 136 +---------------- 6 files changed, 9 insertions(+), 286 deletions(-) diff --git a/changelog.md b/changelog.md index 79269b23a..15013ae25 100644 --- a/changelog.md +++ b/changelog.md @@ -2,7 +2,7 @@ (changes-0_7_0)= -## ๐Ÿš€ 0.7.0 (Unreleased) +## ๐Ÿš€ 0.7.0 (2023-03-27) ### ๐Ÿ’ฅ BREAKING CHANGE @@ -48,8 +48,6 @@ - ๐Ÿ“š Update quickstart guide to use Project API (#1241) -### ๐Ÿ—‘๏ธ Deprecations (due in 0.9.0) - ### ๐Ÿ—‘๏ธ Deprecations (due in 0.8.0) - `.clp_area_penalties` -> `.clp_penalties` diff --git a/glotaran/__init__.py b/glotaran/__init__.py index 1a11b627e..c95ed36fd 100644 --- a/glotaran/__init__.py +++ b/glotaran/__init__.py @@ -4,7 +4,7 @@ load_plugins() -__version__ = "0.7.0.dev0" +__version__ = "0.7.0" examples = deprecate_submodule( deprecated_module_name="glotaran.examples", diff --git a/glotaran/builtin/io/yml/yml.py b/glotaran/builtin/io/yml/yml.py index ca1e51026..48d3da7c7 100644 --- a/glotaran/builtin/io/yml/yml.py +++ b/glotaran/builtin/io/yml/yml.py @@ -8,7 +8,6 @@ from glotaran.builtin.io.yml.utils import load_dict from glotaran.builtin.io.yml.utils import write_dict from glotaran.deprecation.modules.builtin_io_yml import model_spec_deprecations -from glotaran.deprecation.modules.builtin_io_yml import scheme_spec_deprecations from glotaran.io import SAVING_OPTIONS_DEFAULT from glotaran.io import ProjectIoInterface from glotaran.io import SavingOptions @@ -135,7 +134,6 @@ def load_scheme(self, file_name: str) -> Scheme: Scheme """ spec = self._load_yml(file_name) - scheme_spec_deprecations(spec) return fromdict(Scheme, spec, folder=Path(file_name).parent) def save_scheme(self, scheme: Scheme, file_name: str): diff --git a/glotaran/deprecation/modules/builtin_io_yml.py b/glotaran/deprecation/modules/builtin_io_yml.py index e2faac14c..3c36386b0 100644 --- a/glotaran/deprecation/modules/builtin_io_yml.py +++ b/glotaran/deprecation/modules/builtin_io_yml.py @@ -19,99 +19,6 @@ def model_spec_deprecations(spec: MutableMapping[Any, Any]) -> None: Model specification dictionary """ load_model_stack_level = 7 - deprecate_dict_entry( - dict_to_check=spec, - deprecated_usage="type: kinetic-spectrum", - new_usage="default_megacomplex: decay", - to_be_removed_in_version="0.7.0", - replace_rules=({"type": "kinetic-spectrum"}, {"default_megacomplex": "decay"}), - stacklevel=load_model_stack_level, - ) - - deprecate_dict_entry( - dict_to_check=spec, - deprecated_usage="type: spectral-model", - new_usage="default_megacomplex: spectral", - to_be_removed_in_version="0.7.0", - replace_rules=({"type": "spectral-model"}, {"default_megacomplex": "spectral"}), - stacklevel=load_model_stack_level, - ) - - deprecate_dict_entry( - dict_to_check=spec, - deprecated_usage="default-megacomplex", - new_usage="default_megacomplex", - to_be_removed_in_version="0.7.0", - swap_keys=("default-megacomplex", "default_megacomplex"), - stacklevel=load_model_stack_level, - ) - - deprecate_dict_entry( - dict_to_check=spec, - deprecated_usage="spectral_relations", - new_usage="clp_relations", - to_be_removed_in_version="0.7.0", - swap_keys=("spectral_relations", "clp_relations"), - stacklevel=load_model_stack_level, - ) - - deprecate_dict_entry( - dict_to_check=spec, - deprecated_usage="relations", - new_usage="clp_relations", - to_be_removed_in_version="0.7.0", - swap_keys=("relations", "clp_relations"), - stacklevel=load_model_stack_level, - ) - - if "clp_relations" in spec: - for relation in spec["clp_relations"]: - deprecate_dict_entry( - dict_to_check=relation, - deprecated_usage="clp_relations:\n - compartment", - new_usage="clp_relations:\n - source", - to_be_removed_in_version="0.7.0", - swap_keys=("compartment", "source"), - stacklevel=load_model_stack_level, - ) - - deprecate_dict_entry( - dict_to_check=spec, - deprecated_usage="spectral_constraints", - new_usage="clp_constraints", - to_be_removed_in_version="0.7.0", - swap_keys=("spectral_constraints", "clp_constraints"), - stacklevel=load_model_stack_level, - ) - - deprecate_dict_entry( - dict_to_check=spec, - deprecated_usage="constraints", - new_usage="clp_constraints", - to_be_removed_in_version="0.7.0", - swap_keys=("constraints", "clp_constraints"), - stacklevel=load_model_stack_level, - ) - - if "clp_constraints" in spec: - for constraint in spec["clp_constraints"]: - deprecate_dict_entry( - dict_to_check=constraint, - deprecated_usage="clp_constraints:\n - compartment", - new_usage="clp_constraints:\n - target", - to_be_removed_in_version="0.7.0", - swap_keys=("compartment", "target"), - stacklevel=load_model_stack_level, - ) - - deprecate_dict_entry( - dict_to_check=spec, - deprecated_usage="equal_area_penalties", - new_usage="clp_area_penalties", - to_be_removed_in_version="0.7.0", - swap_keys=("equal_area_penalties", "clp_area_penalties"), - stacklevel=load_model_stack_level, - ) deprecate_dict_entry( dict_to_check=spec, @@ -121,53 +28,3 @@ def model_spec_deprecations(spec: MutableMapping[Any, Any]) -> None: swap_keys=("clp_area_penalties", "clp_penalties"), stacklevel=load_model_stack_level, ) - - if "irf" in spec: - for _, irf in spec["irf"].items(): - deprecate_dict_entry( - dict_to_check=irf, - deprecated_usage="center_dispersion", - new_usage="center_dispersion_coefficients", - to_be_removed_in_version="0.7.0", - swap_keys=("center_dispersion", "center_dispersion_coefficients"), - stacklevel=load_model_stack_level, - ) - - for _, irf in spec["irf"].items(): - deprecate_dict_entry( - dict_to_check=irf, - deprecated_usage="width_dispersion", - new_usage="width_dispersion_coefficients", - to_be_removed_in_version="0.7.0", - swap_keys=("width_dispersion", "width_dispersion_coefficients"), - stacklevel=load_model_stack_level, - ) - - -def scheme_spec_deprecations(spec: MutableMapping[Any, Any]) -> None: - """Check deprecations in the scheme specification ``spec`` dict. - - Parameters - ---------- - spec : MutableMapping[Any, Any] - Scheme specification dictionary - """ - load_scheme_stack_level = 7 - - deprecate_dict_entry( - dict_to_check=spec, - deprecated_usage="maximum-number-function-evaluations: ", - new_usage="maximum_number_function_evaluations: ", - to_be_removed_in_version="0.7.0", - swap_keys=("maximum-number-function-evaluations", "maximum_number_function_evaluations"), - stacklevel=load_scheme_stack_level, - ) - - deprecate_dict_entry( - dict_to_check=spec, - deprecated_usage="non-negative-least-squares", - new_usage=("dataset_groups.default.residual_function"), - to_be_removed_in_version="0.7.0", - swap_keys=("non-negative-least-squares", "non_negative_least_squares"), - stacklevel=load_scheme_stack_level, - ) diff --git a/glotaran/deprecation/modules/test/__init__.py b/glotaran/deprecation/modules/test/__init__.py index 27f731866..cadf839bf 100644 --- a/glotaran/deprecation/modules/test/__init__.py +++ b/glotaran/deprecation/modules/test/__init__.py @@ -7,6 +7,7 @@ import pytest from glotaran.deprecation.deprecation_utils import GlotaranApiDeprecationWarning +from glotaran.deprecation.deprecation_utils import OverDueDeprecation if TYPE_CHECKING: from collections.abc import Callable @@ -65,7 +66,10 @@ def deprecation_warning_on_call_test_helper( return record, result - except Exception as e: + except OverDueDeprecation as error: + raise error + + except Exception as error: if raise_exception: - raise e + raise error return record, None diff --git a/glotaran/deprecation/modules/test/test_builtin_io_yml.py b/glotaran/deprecation/modules/test/test_builtin_io_yml.py index e42c9b632..344a7c659 100644 --- a/glotaran/deprecation/modules/test/test_builtin_io_yml.py +++ b/glotaran/deprecation/modules/test/test_builtin_io_yml.py @@ -8,7 +8,6 @@ import glotaran.builtin.io.yml.yml as yml_module from glotaran.deprecation.modules.test import deprecation_warning_on_call_test_helper from glotaran.io import load_model -from glotaran.io import load_scheme if TYPE_CHECKING: from typing import Any @@ -19,69 +18,6 @@ @pytest.mark.parametrize( "model_yml_str, expected_nr_of_warnings, expected_key, expected_value", ( - ("type: kinetic-spectrum", 1, "default_megacomplex", "decay"), - ("type: spectral-model", 1, "default_megacomplex", "spectral"), - ("default-megacomplex: decay", 1, "default_megacomplex", "decay"), - ("default-megacomplex: spectral", 1, "default_megacomplex", "spectral"), - ( - dedent( - """ - spectral_relations: - - compartment: s1 - - compartment: s2 - """ - ), - 3, - "clp_relations", - [{"source": "s1"}, {"source": "s2"}], - ), - ( - dedent( - """ - relations: - - compartment: s1 - - compartment: s2 - """ - ), - 3, - "clp_relations", - [{"source": "s1"}, {"source": "s2"}], - ), - ( - dedent( - """ - spectral_constraints: - - compartment: s1 - - compartment: s2 - """ - ), - 3, - "clp_constraints", - [{"target": "s1"}, {"target": "s2"}], - ), - ( - dedent( - """ - constraints: - - compartment: s1 - - compartment: s2 - """ - ), - 3, - "clp_constraints", - [{"target": "s1"}, {"target": "s2"}], - ), - ( - dedent( - """ - equal_area_penalties: - - type: equal_area - """ - ), - 2, - "clp_penalties", - [{"type": "equal_area"}], - ), ( dedent( """ @@ -93,47 +29,8 @@ "clp_penalties", [{"type": "equal_area"}], ), - ( - dedent( - """ - irf: - irf1: - center_dispersion: [cdc1] - - """ - ), - 1, - "irf", - {"irf1": {"center_dispersion_coefficients": ["cdc1"]}}, - ), - ( - dedent( - """ - irf: - irf1: - "width_dispersion": [wdc1] - - """ - ), - 1, - "irf", - {"irf1": {"width_dispersion_coefficients": ["wdc1"]}}, - ), - ), - ids=( - "type: kinetic-spectrum", - "type: spectral-model", - "default-megacomplex: decay", - "default-megacomplex: spectral", - "spectral_relations", - "relations", - "spectral_constraints", - "constraints", - "equal_area_penalties", - "clp_area_penalties", - "center_dispersion", - "width_dispersion", ), + ids=("clp_area_penalties",), ) def test_model_spec_deprecations( monkeypatch: MonkeyPatch, @@ -156,34 +53,3 @@ def test_model_spec_deprecations( assert return_dict[expected_key] == expected_value assert len(record) == expected_nr_of_warnings - - -@pytest.mark.parametrize( - "scheme_yml_str, expected_key, expected_value", - ( - ("maximum-number-function-evaluations: 12", "maximum_number_function_evaluations", 12), - ("non-negative-least-squares: true", "non_negative_least_squares", True), - ), -) -def test_scheme_spec_deprecations( - monkeypatch: MonkeyPatch, - scheme_yml_str: str, - expected_key: str, - expected_value: Any, -): - """Warning gets emitted by load_model""" - return_dicts = [] - with monkeypatch.context() as m: - m.setattr( - yml_module, "fromdict", lambda _, spec, *args, **kwargs: return_dicts.append(spec) - ) - record, _ = deprecation_warning_on_call_test_helper( - load_scheme, args=(scheme_yml_str,), kwargs={"format_name": "yml_str"} - ) - - return_dict = return_dicts[0] - - assert expected_key in return_dict - assert return_dict[expected_key] == expected_value - - assert len(record) == 1