diff --git a/src/pytorch_lightning/CHANGELOG.md b/src/pytorch_lightning/CHANGELOG.md index 653e73a269a0f..6ed9b7f648701 100644 --- a/src/pytorch_lightning/CHANGELOG.md +++ b/src/pytorch_lightning/CHANGELOG.md @@ -245,6 +245,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Removed the deprecated `Trainer.call_hook` in favor of `Trainer._call_callback_hooks`, `Trainer._call_lightning_module_hook`, `Trainer._call_ttp_hook`, and `Trainer._call_accelerator_hook` ([#14869](https://github.com/Lightning-AI/lightning/pull/14869)) +- Removed the deprecated `Trainer.{validated,tested,predicted}_ckpt_path` ([#14897](https://github.com/Lightning-AI/lightning/pull/14897)) + ### Fixed diff --git a/src/pytorch_lightning/trainer/trainer.py b/src/pytorch_lightning/trainer/trainer.py index 9113210c7779a..6343865ae8a42 100644 --- a/src/pytorch_lightning/trainer/trainer.py +++ b/src/pytorch_lightning/trainer/trainer.py @@ -441,12 +441,6 @@ def __init__( # set when a checkpoint is loaded via `Trainer.{fit,validate,test,predict}`. self._ckpt_path: Optional[str] = None - # .validate(), predict() and .test() set these when they load a checkpoint. They will be removed in favor of - # the unified read-only `Trainer.ckpt_path` attribute in v1.8 - self._validated_ckpt_path: Optional[str] = None # TODO: remove in v1.8 - self._tested_ckpt_path: Optional[str] = None # TODO: remove in v1.8 - self._predicted_ckpt_path: Optional[str] = None # TODO: remove in v1.8 - # init callbacks # Declare attributes to be set in _callback_connector on_trainer_init self._callback_connector.on_trainer_init( @@ -1899,66 +1893,6 @@ def ckpt_path(self) -> Optional[str]: :meth:`~pytorch_lightning.trainer.trainer.Trainer.predict`. ``None`` otherwise.""" return self._ckpt_path - @property - def validated_ckpt_path(self) -> Optional[str]: - rank_zero_deprecation( - "The `Trainer.validated_ckpt_path` attribute was deprecated in v1.6 and will be removed in v1.8. The" - " path of a checkpoint loaded via `Trainer.{fit,validate,test,predict}` should be accessed via" - " `Trainer.ckpt_path` instead.", - stacklevel=5, - ) - return self._validated_ckpt_path - - @validated_ckpt_path.setter - def validated_ckpt_path(self, ckpt_path: Optional[str]) -> None: - rank_zero_deprecation( - "The `Trainer.validated_ckpt_path` attribute was deprecated in v1.6 and will be removed in v1.8. The" - " path of a checkpoint loaded via `Trainer.{fit,validate,test,predict}` should be accessed via the" - " read-only `Trainer.ckpt_path`.", - stacklevel=5, - ) - self._validated_ckpt_path = ckpt_path - - @property - def tested_ckpt_path(self) -> Optional[str]: - rank_zero_deprecation( - "The `Trainer.tested_ckpt_path` attribute was deprecated in v1.6 and will be removed in v1.8. The" - " path of a checkpoint loaded via `Trainer.{fit,validate,test,predict}` should be accessed via" - " `Trainer.ckpt_path` instead.", - stacklevel=5, - ) - return self._tested_ckpt_path - - @tested_ckpt_path.setter - def tested_ckpt_path(self, ckpt_path: Optional[str]) -> None: - rank_zero_deprecation( - "The `Trainer.tested_ckpt_path` attribute was deprecated in v1.6 and will be removed in v1.8. The" - " path of a checkpoint loaded via `Trainer.{fit,validate,test,predict}` should be accessed via the" - " read-only `Trainer.ckpt_path` instead.", - stacklevel=5, - ) - self._tested_ckpt_path = ckpt_path - - @property - def predicted_ckpt_path(self) -> Optional[str]: - rank_zero_deprecation( - "The `Trainer.predicted_ckpt_path` attribute was deprecated in v1.6 and will be removed in v1.8. The" - " path of a checkpoint loaded via `Trainer.{fit,validate,test,predict}` should be accessed via" - " `Trainer.ckpt_path` instead.", - stacklevel=5, - ) - return self._predicted_ckpt_path - - @predicted_ckpt_path.setter - def predicted_ckpt_path(self, ckpt_path: Optional[str]) -> None: - rank_zero_deprecation( - "The `Trainer.predicted_ckpt_path` attribute was deprecated in v1.6 and will be removed in v1.8. The" - " path of a checkpoint loaded via `Trainer.{fit,validate,test,predict}` should be accessed via the" - " read-only `Trainer.ckpt_path` instead.", - stacklevel=5, - ) - self._predicted_ckpt_path = ckpt_path - def save_checkpoint( self, filepath: _PATH, weights_only: bool = False, storage_options: Optional[Any] = None ) -> None: diff --git a/tests/tests_pytorch/deprecated_api/test_remove_1-8.py b/tests/tests_pytorch/deprecated_api/test_remove_1-8.py index 168ac6339f146..15b206b0fea04 100644 --- a/tests/tests_pytorch/deprecated_api/test_remove_1-8.py +++ b/tests/tests_pytorch/deprecated_api/test_remove_1-8.py @@ -52,16 +52,6 @@ def on_init_end(self, trainer): trainer.validate(model) -@pytest.mark.parametrize("fn_prefix", ["validated", "tested", "predicted"]) -def test_v1_8_0_trainer_ckpt_path_attributes(fn_prefix: str): - test_attr = f"{fn_prefix}_ckpt_path" - trainer = Trainer() - with pytest.deprecated_call(match=f"{test_attr}` attribute was deprecated in v1.6 and will be removed in v1.8"): - _ = getattr(trainer, test_attr) - with pytest.deprecated_call(match=f"{test_attr}` attribute was deprecated in v1.6 and will be removed in v1.8"): - setattr(trainer, test_attr, "v") - - def test_v_1_8_0_deprecated_device_stats_monitor_prefix_metric_keys(): from pytorch_lightning.callbacks.device_stats_monitor import prefix_metric_keys