Skip to content

Commit 01e0dac

Browse files
Deprecate Trainer.should_rank_save_checkpoint property (#11068)
Co-authored-by: Carlos Mocholí <[email protected]>
1 parent 3c4d06b commit 01e0dac

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
147147
- Deprecated `ModelIO.on_hpc_{save/load}` in favor of `CheckpointHooks.on_{save/load}_checkpoint` ([#10911](https://github.com/PyTorchLightning/pytorch-lightning/pull/10911))
148148

149149

150+
- Deprecated `Trainer.should_rank_save_checkpoint` Trainer property ([#11068](https://github.com/PyTorchLightning/pytorch-lightning/pull/11068))
151+
152+
150153
### Removed
151154

152155
- Removed deprecated parameter `method` in `pytorch_lightning.utilities.model_helpers.is_overridden` ([#10507](https://github.com/PyTorchLightning/pytorch-lightning/pull/10507))
@@ -611,7 +614,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
611614
- Removed `TrainerProperties` mixin and moved property definitions directly into `Trainer` ([#9495](https://github.com/PyTorchLightning/pytorch-lightning/pull/9495))
612615
- Removed a redundant warning with `ModelCheckpoint(monitor=None)` callback ([#9875](https://github.com/PyTorchLightning/pytorch-lightning/pull/9875))
613616
- Remove `epoch` from `trainer.logged_metrics` ([#9904](https://github.com/PyTorchLightning/pytorch-lightning/pull/9904))
614-
- Removed `should_rank_save_checkpoint` property from Trainer ([#9433](https://github.com/PyTorchLightning/pytorch-lightning/pull/9433))
615617
- Remove deprecated `distributed_backend` from `Trainer` ([#10017](https://github.com/PyTorchLightning/pytorch-lightning/pull/10017))
616618
- Removed `process_idx` from the `{DDPSpawnPlugin,TPUSpawnPlugin}.new_process` methods ([#10022](https://github.com/PyTorchLightning/pytorch-lightning/pull/10022))
617619
- Removed automatic patching of `{train,val,test,predict}_dataloader()` on the `LightningModule` ([#9764](https://github.com/PyTorchLightning/pytorch-lightning/pull/9764))

pytorch_lightning/trainer/trainer.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,6 +1699,13 @@ def world_size(self) -> int:
16991699
# some training types define a world size
17001700
return getattr(self.training_type_plugin, "world_size", 1)
17011701

1702+
@property
1703+
def should_rank_save_checkpoint(self) -> bool:
1704+
rank_zero_deprecation(
1705+
"`Trainer.should_rank_save_checkpoint` is deprecated in v1.6 and will be removed in 1.8.", stacklevel=5
1706+
)
1707+
return self.training_type_plugin.should_rank_save_checkpoint
1708+
17021709
@property
17031710
def _distrib_type(self) -> _StrategyType:
17041711
return self._accelerator_connector._distrib_type

tests/deprecated_api/test_remove_1-8.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,11 @@ def on_hpc_load(self):
106106
match=r"Method `LightningModule.on_hpc_load` is deprecated in v1.6 and will be removed in v1.8."
107107
):
108108
trainer.fit(load_model)
109+
110+
111+
def test_v1_8_0_deprecated_trainer_should_rank_save_checkpoint(tmpdir):
112+
trainer = Trainer()
113+
with pytest.deprecated_call(
114+
match=r"`Trainer.should_rank_save_checkpoint` is deprecated in v1.6 and will be removed in 1.8."
115+
):
116+
_ = trainer.should_rank_save_checkpoint

0 commit comments

Comments
 (0)