Deprecate moved warning functions (#8085)

This commit is contained in:
Carlos Mocholí 2021-06-23 00:09:42 +02:00 committed by GitHub
parent 8bce39431e
commit 6dd7797c97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 0 deletions

View File

@ -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))

View File

@ -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

View File

@ -17,6 +17,7 @@ import pytest
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
@ -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')