Skip to content

Commit 9fd951b

Browse files
authored
Remove the deprecated trainer.*_ckpt_path (#14897)
1 parent d7404c7 commit 9fd951b

File tree

3 files changed

+2
-76
lines changed

3 files changed

+2
-76
lines changed

src/pytorch_lightning/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
245245

246246
- 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))
247247

248+
- Removed the deprecated `Trainer.{validated,tested,predicted}_ckpt_path` ([#14897](https://github.com/Lightning-AI/lightning/pull/14897))
249+
248250

249251
### Fixed
250252

src/pytorch_lightning/trainer/trainer.py

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -441,12 +441,6 @@ def __init__(
441441
# set when a checkpoint is loaded via `Trainer.{fit,validate,test,predict}`.
442442
self._ckpt_path: Optional[str] = None
443443

444-
# .validate(), predict() and .test() set these when they load a checkpoint. They will be removed in favor of
445-
# the unified read-only `Trainer.ckpt_path` attribute in v1.8
446-
self._validated_ckpt_path: Optional[str] = None # TODO: remove in v1.8
447-
self._tested_ckpt_path: Optional[str] = None # TODO: remove in v1.8
448-
self._predicted_ckpt_path: Optional[str] = None # TODO: remove in v1.8
449-
450444
# init callbacks
451445
# Declare attributes to be set in _callback_connector on_trainer_init
452446
self._callback_connector.on_trainer_init(
@@ -1899,66 +1893,6 @@ def ckpt_path(self) -> Optional[str]:
18991893
:meth:`~pytorch_lightning.trainer.trainer.Trainer.predict`. ``None`` otherwise."""
19001894
return self._ckpt_path
19011895

1902-
@property
1903-
def validated_ckpt_path(self) -> Optional[str]:
1904-
rank_zero_deprecation(
1905-
"The `Trainer.validated_ckpt_path` attribute was deprecated in v1.6 and will be removed in v1.8. The"
1906-
" path of a checkpoint loaded via `Trainer.{fit,validate,test,predict}` should be accessed via"
1907-
" `Trainer.ckpt_path` instead.",
1908-
stacklevel=5,
1909-
)
1910-
return self._validated_ckpt_path
1911-
1912-
@validated_ckpt_path.setter
1913-
def validated_ckpt_path(self, ckpt_path: Optional[str]) -> None:
1914-
rank_zero_deprecation(
1915-
"The `Trainer.validated_ckpt_path` attribute was deprecated in v1.6 and will be removed in v1.8. The"
1916-
" path of a checkpoint loaded via `Trainer.{fit,validate,test,predict}` should be accessed via the"
1917-
" read-only `Trainer.ckpt_path`.",
1918-
stacklevel=5,
1919-
)
1920-
self._validated_ckpt_path = ckpt_path
1921-
1922-
@property
1923-
def tested_ckpt_path(self) -> Optional[str]:
1924-
rank_zero_deprecation(
1925-
"The `Trainer.tested_ckpt_path` attribute was deprecated in v1.6 and will be removed in v1.8. The"
1926-
" path of a checkpoint loaded via `Trainer.{fit,validate,test,predict}` should be accessed via"
1927-
" `Trainer.ckpt_path` instead.",
1928-
stacklevel=5,
1929-
)
1930-
return self._tested_ckpt_path
1931-
1932-
@tested_ckpt_path.setter
1933-
def tested_ckpt_path(self, ckpt_path: Optional[str]) -> None:
1934-
rank_zero_deprecation(
1935-
"The `Trainer.tested_ckpt_path` attribute was deprecated in v1.6 and will be removed in v1.8. The"
1936-
" path of a checkpoint loaded via `Trainer.{fit,validate,test,predict}` should be accessed via the"
1937-
" read-only `Trainer.ckpt_path` instead.",
1938-
stacklevel=5,
1939-
)
1940-
self._tested_ckpt_path = ckpt_path
1941-
1942-
@property
1943-
def predicted_ckpt_path(self) -> Optional[str]:
1944-
rank_zero_deprecation(
1945-
"The `Trainer.predicted_ckpt_path` attribute was deprecated in v1.6 and will be removed in v1.8. The"
1946-
" path of a checkpoint loaded via `Trainer.{fit,validate,test,predict}` should be accessed via"
1947-
" `Trainer.ckpt_path` instead.",
1948-
stacklevel=5,
1949-
)
1950-
return self._predicted_ckpt_path
1951-
1952-
@predicted_ckpt_path.setter
1953-
def predicted_ckpt_path(self, ckpt_path: Optional[str]) -> None:
1954-
rank_zero_deprecation(
1955-
"The `Trainer.predicted_ckpt_path` attribute was deprecated in v1.6 and will be removed in v1.8. The"
1956-
" path of a checkpoint loaded via `Trainer.{fit,validate,test,predict}` should be accessed via the"
1957-
" read-only `Trainer.ckpt_path` instead.",
1958-
stacklevel=5,
1959-
)
1960-
self._predicted_ckpt_path = ckpt_path
1961-
19621896
def save_checkpoint(
19631897
self, filepath: _PATH, weights_only: bool = False, storage_options: Optional[Any] = None
19641898
) -> None:

tests/tests_pytorch/deprecated_api/test_remove_1-8.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,6 @@ def on_init_end(self, trainer):
5252
trainer.validate(model)
5353

5454

55-
@pytest.mark.parametrize("fn_prefix", ["validated", "tested", "predicted"])
56-
def test_v1_8_0_trainer_ckpt_path_attributes(fn_prefix: str):
57-
test_attr = f"{fn_prefix}_ckpt_path"
58-
trainer = Trainer()
59-
with pytest.deprecated_call(match=f"{test_attr}` attribute was deprecated in v1.6 and will be removed in v1.8"):
60-
_ = getattr(trainer, test_attr)
61-
with pytest.deprecated_call(match=f"{test_attr}` attribute was deprecated in v1.6 and will be removed in v1.8"):
62-
setattr(trainer, test_attr, "v")
63-
64-
6555
def test_v_1_8_0_deprecated_device_stats_monitor_prefix_metric_keys():
6656
from pytorch_lightning.callbacks.device_stats_monitor import prefix_metric_keys
6757

0 commit comments

Comments
 (0)