From 048c5ba6643492a73dd02fdcf55f580f1b1d855e Mon Sep 17 00:00:00 2001 From: Kishan Savant Date: Sat, 24 Sep 2022 18:38:14 +0530 Subject: [PATCH 1/2] Remove deprecated trainer.should_rank_save_checkpoint --- src/pytorch_lightning/CHANGELOG.md | 1 + src/pytorch_lightning/trainer/trainer.py | 10 ---------- tests/tests_pytorch/deprecated_api/test_remove_1-8.py | 8 -------- 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/pytorch_lightning/CHANGELOG.md b/src/pytorch_lightning/CHANGELOG.md index 6085c026f9553..d09c95ef7ef35 100644 --- a/src/pytorch_lightning/CHANGELOG.md +++ b/src/pytorch_lightning/CHANGELOG.md @@ -224,6 +224,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Removed the deprecated `SimpleProfiler.profile_iterable` and `AdvancedProfiler.profile_iterable` attributes ([#14864](https://github.com/Lightning-AI/lightning/pull/14864)) +- Remove the deprecated `Trainer.should_rank_save_checkpoint` ### Fixed diff --git a/src/pytorch_lightning/trainer/trainer.py b/src/pytorch_lightning/trainer/trainer.py index c438b2f767d91..6f3e0d4ce7c4c 100644 --- a/src/pytorch_lightning/trainer/trainer.py +++ b/src/pytorch_lightning/trainer/trainer.py @@ -1755,16 +1755,6 @@ def world_size(self) -> int: # some strategies define a world size return getattr(self.strategy, "world_size", 1) - @property - def should_rank_save_checkpoint(self) -> bool: - rank_zero_deprecation( - "`Trainer.should_rank_save_checkpoint` is deprecated in v1.6 and will be removed in v1.8.", stacklevel=5 - ) - strategy = self.strategy - return ( - isinstance(strategy, pl.strategies.TPUSpawnStrategy) and strategy.local_rank == 0 or strategy.is_global_zero - ) - @property def num_nodes(self) -> int: return getattr(self.strategy, "num_nodes", 1) 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 a7ba047b05c7f..aa25c1cdda8ed 100644 --- a/tests/tests_pytorch/deprecated_api/test_remove_1-8.py +++ b/tests/tests_pytorch/deprecated_api/test_remove_1-8.py @@ -91,14 +91,6 @@ def test_v1_8_0_trainer_ckpt_path_attributes(fn_prefix: str): setattr(trainer, test_attr, "v") -def test_v1_8_0_deprecated_trainer_should_rank_save_checkpoint(tmpdir): - trainer = Trainer() - with pytest.deprecated_call( - match=r"`Trainer.should_rank_save_checkpoint` is deprecated in v1.6 and will be removed in v1.8." - ): - _ = trainer.should_rank_save_checkpoint - - def test_v1_8_0_trainer_optimizers_mixin(): trainer = Trainer() model = BoringModel() From 86be9a837c2a88c1f7282b8730150f466aa93ac0 Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Sat, 24 Sep 2022 19:15:43 +0530 Subject: [PATCH 2/2] Update src/pytorch_lightning/CHANGELOG.md --- src/pytorch_lightning/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytorch_lightning/CHANGELOG.md b/src/pytorch_lightning/CHANGELOG.md index d09c95ef7ef35..c12ea445e1b5a 100644 --- a/src/pytorch_lightning/CHANGELOG.md +++ b/src/pytorch_lightning/CHANGELOG.md @@ -224,7 +224,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Removed the deprecated `SimpleProfiler.profile_iterable` and `AdvancedProfiler.profile_iterable` attributes ([#14864](https://github.com/Lightning-AI/lightning/pull/14864)) -- Remove the deprecated `Trainer.should_rank_save_checkpoint` +- Remove the deprecated `Trainer.should_rank_save_checkpoint` ([#14885](https://github.com/Lightning-AI/lightning/pull/14885)) ### Fixed