Skip to content

Commit

Permalink
πŸš§πŸš€ Prepare 0.7.0 release (#1250)
Browse files Browse the repository at this point in the history
* πŸš€ 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
  • Loading branch information
s-weigand authored Mar 27, 2023
1 parent b7af7fe commit 9adf4a4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 286 deletions.
4 changes: 1 addition & 3 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

(changes-0_7_0)=

## πŸš€ 0.7.0 (Unreleased)
## πŸš€ 0.7.0 (2023-03-27)

### πŸ’₯ BREAKING CHANGE

Expand Down Expand Up @@ -48,8 +48,6 @@

- πŸ“š Update quickstart guide to use Project API (#1241)

### πŸ—‘οΈ Deprecations (due in 0.9.0)

### πŸ—‘οΈ Deprecations (due in 0.8.0)

- `<model_file>.clp_area_penalties` -> `<model_file>.clp_penalties`
Expand Down
2 changes: 1 addition & 1 deletion glotaran/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

load_plugins()

__version__ = "0.7.0.dev0"
__version__ = "0.7.0"

examples = deprecate_submodule(
deprecated_module_name="glotaran.examples",
Expand Down
2 changes: 0 additions & 2 deletions glotaran/builtin/io/yml/yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
143 changes: 0 additions & 143 deletions glotaran/deprecation/modules/builtin_io_yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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: <number>",
new_usage="maximum_number_function_evaluations: <number>",
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=("<model_file>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,
)
8 changes: 6 additions & 2 deletions glotaran/deprecation/modules/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
136 changes: 1 addition & 135 deletions glotaran/deprecation/modules/test/test_builtin_io_yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
"""
Expand All @@ -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,
Expand All @@ -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

0 comments on commit 9adf4a4

Please sign in to comment.