diff --git a/CHANGELOG.md b/CHANGELOG.md index c8b2390db13a0..f4623e03599c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -96,9 +96,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Raise an error if there are insufficient training batches when using a float value of `limit_train_batches` ([#12885](https://github.com/PyTorchLightning/pytorch-lightning/pull/12885)) - -- Changed `pytorch_lightning.core.lightning` to `pytorch_lightning.core.module` ([#12740](https://github.com/PyTorchLightning/pytorch-lightning/pull/12740)) - ### Deprecated - Deprecated `pytorch_lightning.loggers.base.LightningLoggerBase` in favor of `pytorch_lightning.loggers.logger.Logger`, and deprecated `pytorch_lightning.loggers.base` in favor of `pytorch_lightning.loggers.logger` ([#120148](https://github.com/PyTorchLightning/pytorch-lightning/pull/12014)) @@ -116,6 +113,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Deprecated `pytorch_lightning.core.lightning.LightningModule` in favor of `pytorch_lightning.core.module.LightningModule` ([#12740](https://github.com/PyTorchLightning/pytorch-lightning/pull/12740)) +- Deprecated `pytorch_lightning.loops.base.Loop` in favor of `pytorch_lightning.loops.loop.Loop` ([#13043](https://github.com/PyTorchLightning/pytorch-lightning/pull/13043)) + + - Deprecated `Trainer.reset_train_val_dataloaders()` in favor of `Trainer.reset_{train,val}_dataloader` ([#12184](https://github.com/PyTorchLightning/pytorch-lightning/pull/12184)) ### Removed diff --git a/pytorch_lightning/loops/__init__.py b/pytorch_lightning/loops/__init__.py index 1f473da07169c..3aa32809b8888 100644 --- a/pytorch_lightning/loops/__init__.py +++ b/pytorch_lightning/loops/__init__.py @@ -11,11 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - -from pytorch_lightning.loops.batch import ManualOptimization # noqa: F401 +from pytorch_lightning.loops.loop import Loop # noqa: F401 isort: skip (avoids circular imports) from pytorch_lightning.loops.batch import TrainingBatchLoop # noqa: F401 from pytorch_lightning.loops.dataloader import DataLoaderLoop, EvaluationLoop, PredictionLoop # noqa: F401 from pytorch_lightning.loops.epoch import EvaluationEpochLoop, PredictionEpochLoop, TrainingEpochLoop # noqa: F401 from pytorch_lightning.loops.fit_loop import FitLoop # noqa: F401 -from pytorch_lightning.loops.loop import Loop # noqa: F401 -from pytorch_lightning.loops.optimization.optimizer_loop import OptimizerLoop # noqa: F401 +from pytorch_lightning.loops.optimization import ManualOptimization, OptimizerLoop # noqa: F401 diff --git a/pytorch_lightning/loops/base.py b/pytorch_lightning/loops/base.py new file mode 100644 index 0000000000000..c9bb33ccb0188 --- /dev/null +++ b/pytorch_lightning/loops/base.py @@ -0,0 +1,25 @@ +# Copyright The PyTorch Lightning team. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from pytorch_lightning.loops import Loop as NewLoop +from pytorch_lightning.utilities.rank_zero import rank_zero_deprecation + + +class Loop(NewLoop): + def __init__(self) -> None: + rank_zero_deprecation( + "pytorch_lightning.loops.base.Loop has been deprecated in v1.7" + " and will be removed in v1.9." + " Use the equivalent class from the pytorch_lightning.loops.loop.Loop class instead." + ) + super().__init__() diff --git a/tests/deprecated_api/test_remove_1-9.py b/tests/deprecated_api/test_remove_1-9.py index 0ad4d7a7410fd..18aed8c7e1f57 100644 --- a/tests/deprecated_api/test_remove_1-9.py +++ b/tests/deprecated_api/test_remove_1-9.py @@ -95,6 +95,23 @@ def test_old_lightningmodule_path(): LightningModule() +def test_old_loop_path(): + from pytorch_lightning.loops.base import Loop + + class MyLoop(Loop): + def advance(self): + ... + + def done(self): + ... + + def reset(self): + ... + + with pytest.deprecated_call(match="pytorch_lightning.loops.base.Loop has been deprecated in v1.7"): + MyLoop() + + def test_lightningCLI_seed_everything_default_to_None_deprecation_warning(): with mock.patch("sys.argv", ["any.py"]), pytest.deprecated_call( match="Setting `LightningCLI.seed_everything_default` to `None` is deprecated in v1.7 "