Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Deprecated default value of `monitor` argument in EarlyStopping callback to enforce `monitor` as a required argument ([#7907](https://github.com/PyTorchLightning/pytorch-lightning/pull/7907))


- Deprecated importing `rank_zero_{warn,deprecation}` directly from `pytorch_lightning.utilities.distributed` ([#8085](https://github.com/PyTorchLightning/pytorch-lightning/pull/8085))


- Deprecated the use of `CheckpointConnector.hpc_load()` in favor of `CheckpointConnector.restore()` ([#7652](https://github.com/PyTorchLightning/pytorch-lightning/pull/7652))


Expand Down
18 changes: 18 additions & 0 deletions pytorch_lightning/utilities/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ def _get_rank() -> int:
rank_zero_only.rank = getattr(rank_zero_only, 'rank', _get_rank())


def rank_zero_warn(*args, stacklevel: int = 5, **kwargs):
from pytorch_lightning.utilities.warnings import rank_zero_deprecation, rank_zero_warn
rank_zero_deprecation(
'`pytorch_lightning.utilities.distributed.rank_zero_warn` has been moved to'
' `pytorch_lightning.utilities.rank_zero_warn` in v1.3.7 and will be removed in v1.6'
)
return rank_zero_warn(*args, stacklevel=stacklevel, **kwargs)


def rank_zero_deprecation(*args, stacklevel: int = 5, **kwargs):
from pytorch_lightning.utilities.warnings import rank_zero_deprecation
rank_zero_deprecation(
'`pytorch_lightning.utilities.distributed.rank_zero_deprecation` has been moved to'
' `pytorch_lightning.utilities.rank_zero_deprecation` in v1.3.7 and will be removed in v1.6'
)
return rank_zero_deprecation(*args, stacklevel=stacklevel, **kwargs)


def _info(*args, stacklevel: int = 2, **kwargs):
if python_version() >= "3.8.0":
kwargs['stacklevel'] = stacklevel
Expand Down
8 changes: 8 additions & 0 deletions tests/deprecated_api/test_remove_1-6.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from pytorch_lightning import Trainer
from pytorch_lightning.callbacks.early_stopping import EarlyStopping
from pytorch_lightning.plugins.training_type import DDPPlugin, DDPSpawnPlugin
from pytorch_lightning.utilities.distributed import rank_zero_deprecation, rank_zero_warn
from pytorch_lightning.utilities.model_helpers import is_overridden
from tests.helpers import BoringDataModule, BoringModel

Expand Down Expand Up @@ -235,3 +236,10 @@ def test_v1_6_0_train_loop(tmpdir):
match=r"`Trainer.train_loop` has been renamed to `Trainer.fit_loop` and will be removed in v1.6."
):
_ = trainer.train_loop


def test_v1_6_0_rank_zero_warnings_moved():
with pytest.deprecated_call(match='in v1.3.7 and will be removed in v1.6'):
rank_zero_warn('test')
with pytest.deprecated_call(match='in v1.3.7 and will be removed in v1.6'):
rank_zero_deprecation('test')