From 20c385ab146e30fe63f90f7068fb1e5f12293a6d Mon Sep 17 00:00:00 2001 From: Jennifer Dai Date: Tue, 14 Dec 2021 16:30:38 -0800 Subject: [PATCH 1/5] first commit --- CHANGELOG.md | 4 +++- pytorch_lightning/trainer/trainer.py | 5 +++++ tests/deprecated_api/test_remove_1-8.py | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96a24f3dd1ba8..6e805ea9ed985 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -143,6 +143,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Deprecated `ModelIO.on_hpc_{save/load}` in favor of `CheckpointHooks.on_{save/load}_checkpoint` ([#10911](https://github.com/PyTorchLightning/pytorch-lightning/pull/10911)) +- Deprecated `Trainer.should_rank_save_checkpoint` Trainer property ([#123](https://github.com/PyTorchLightning/pytorch-lightning/pull/123)) + + ### Removed - Removed deprecated parameter `method` in `pytorch_lightning.utilities.model_helpers.is_overridden` ([#10507](https://github.com/PyTorchLightning/pytorch-lightning/pull/10507)) @@ -604,7 +607,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Removed `TrainerProperties` mixin and moved property definitions directly into `Trainer` ([#9495](https://github.com/PyTorchLightning/pytorch-lightning/pull/9495)) - Removed a redundant warning with `ModelCheckpoint(monitor=None)` callback ([#9875](https://github.com/PyTorchLightning/pytorch-lightning/pull/9875)) - Remove `epoch` from `trainer.logged_metrics` ([#9904](https://github.com/PyTorchLightning/pytorch-lightning/pull/9904)) -- Removed `should_rank_save_checkpoint` property from Trainer ([#9433](https://github.com/PyTorchLightning/pytorch-lightning/pull/9433)) - Remove deprecated `distributed_backend` from `Trainer` ([#10017](https://github.com/PyTorchLightning/pytorch-lightning/pull/10017)) - Removed `process_idx` from the `{DDPSpawnPlugin,TPUSpawnPlugin}.new_process` methods ([#10022](https://github.com/PyTorchLightning/pytorch-lightning/pull/10022)) - Removed automatic patching of `{train,val,test,predict}_dataloader()` on the `LightningModule` ([#9764](https://github.com/PyTorchLightning/pytorch-lightning/pull/9764)) diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py index 5bd0e131f0043..af33f407f4f24 100644 --- a/pytorch_lightning/trainer/trainer.py +++ b/pytorch_lightning/trainer/trainer.py @@ -1699,6 +1699,11 @@ def world_size(self) -> int: # some training types define a world size return getattr(self.training_type_plugin, "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 1.8.") + return self.training_type_plugin.should_rank_save_checkpoint + @property def _distrib_type(self) -> _StrategyType: return self._accelerator_connector._distrib_type diff --git a/tests/deprecated_api/test_remove_1-8.py b/tests/deprecated_api/test_remove_1-8.py index aa2dc6d04d750..315fefe34cbda 100644 --- a/tests/deprecated_api/test_remove_1-8.py +++ b/tests/deprecated_api/test_remove_1-8.py @@ -106,3 +106,8 @@ def on_hpc_load(self): match=r"Method `LightningModule.on_hpc_load` is deprecated in v1.6 and will be removed in v1.8." ): trainer.fit(load_model) + +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 1.8."): + _ = trainer.should_rank_save_checkpoint From ac0799574cdbfcdb895391856ea47705c5495576 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 15 Dec 2021 00:34:49 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/deprecated_api/test_remove_1-8.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/deprecated_api/test_remove_1-8.py b/tests/deprecated_api/test_remove_1-8.py index 315fefe34cbda..20c65ff81a1d6 100644 --- a/tests/deprecated_api/test_remove_1-8.py +++ b/tests/deprecated_api/test_remove_1-8.py @@ -107,7 +107,10 @@ def on_hpc_load(self): ): trainer.fit(load_model) + 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 1.8."): + with pytest.deprecated_call( + match=r"`Trainer.should_rank_save_checkpoint` is deprecated in v1.6 and will be removed in 1.8." + ): _ = trainer.should_rank_save_checkpoint From 25e73087e9afbb7bebaa6265ae397f0174790580 Mon Sep 17 00:00:00 2001 From: Jennifer Dai Date: Tue, 14 Dec 2021 17:16:59 -0800 Subject: [PATCH 3/5] changelog pr # --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e805ea9ed985..e64fb112768d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -143,7 +143,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Deprecated `ModelIO.on_hpc_{save/load}` in favor of `CheckpointHooks.on_{save/load}_checkpoint` ([#10911](https://github.com/PyTorchLightning/pytorch-lightning/pull/10911)) -- Deprecated `Trainer.should_rank_save_checkpoint` Trainer property ([#123](https://github.com/PyTorchLightning/pytorch-lightning/pull/123)) +- Deprecated `Trainer.should_rank_save_checkpoint` Trainer property ([#11068](https://github.com/PyTorchLightning/pytorch-lightning/pull/11068)) ### Removed From 705365809aab0ddd143b5dcc4690ae2e64354d36 Mon Sep 17 00:00:00 2001 From: jjenniferdai <89552168+jjenniferdai@users.noreply.github.com> Date: Wed, 15 Dec 2021 10:55:15 -0800 Subject: [PATCH 4/5] stacklevel=5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Carlos MocholĂ­ --- pytorch_lightning/trainer/trainer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py index af33f407f4f24..d819a5057926d 100644 --- a/pytorch_lightning/trainer/trainer.py +++ b/pytorch_lightning/trainer/trainer.py @@ -1701,7 +1701,7 @@ def world_size(self) -> int: @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 1.8.") + rank_zero_deprecation("`Trainer.should_rank_save_checkpoint` is deprecated in v1.6 and will be removed in 1.8.", stacklevel=5) return self.training_type_plugin.should_rank_save_checkpoint @property From 13b41f720bae7cea86b69c2ffca0d0e39ce02db8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 15 Dec 2021 18:56:30 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pytorch_lightning/trainer/trainer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py index d819a5057926d..0455de7c278bd 100644 --- a/pytorch_lightning/trainer/trainer.py +++ b/pytorch_lightning/trainer/trainer.py @@ -1701,7 +1701,9 @@ def world_size(self) -> int: @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 1.8.", stacklevel=5) + rank_zero_deprecation( + "`Trainer.should_rank_save_checkpoint` is deprecated in v1.6 and will be removed in 1.8.", stacklevel=5 + ) return self.training_type_plugin.should_rank_save_checkpoint @property