Skip to content

Commit ef82b03

Browse files
committed
Remove the deprecated pl.loops.base module (#16142)
1 parent ad6e32a commit ef82b03

File tree

5 files changed

+29
-26
lines changed

5 files changed

+29
-26
lines changed

src/pytorch_lightning/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
140140
- Removed the deprecated `pytorch_lightning.loggers.base` module in favor of `pytorch_lightning.loggers.logger` ([#16120](https://github.com/PyTorchLightning/pytorch-lightning/pull/16120))
141141

142142

143+
- Removed the deprecated `pytorch_lightning.loops.base` module in favor of `pytorch_lightning.loops.loop` ([#16142](https://github.com/PyTorchLightning/pytorch-lightning/pull/16142))
144+
145+
143146
- Removed the deprecated `Trainer.reset_train_val_dataloaders()` in favor of `Trainer.reset_{train,val}_dataloader` ([#16131](https://github.com/Lightning-AI/lightning/pull/16131))
144147

145148

src/pytorch_lightning/_graveyard/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import pytorch_lightning._graveyard.core
1919
import pytorch_lightning._graveyard.legacy_import_unpickler
2020
import pytorch_lightning._graveyard.loggers
21+
import pytorch_lightning._graveyard.loops
2122
import pytorch_lightning._graveyard.profiler
2223
import pytorch_lightning._graveyard.strategies
2324
import pytorch_lightning._graveyard.trainer

src/pytorch_lightning/loops/base.py renamed to src/pytorch_lightning/_graveyard/loops.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,23 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from pytorch_lightning.loops import Loop as NewLoop
15-
from pytorch_lightning.utilities.rank_zero import rank_zero_deprecation
14+
import sys
15+
from typing import Any
1616

1717

18-
class Loop(NewLoop):
19-
def __init__(self) -> None:
20-
rank_zero_deprecation(
21-
"pytorch_lightning.loops.base.Loop has been deprecated in v1.7"
22-
" and will be removed in v1.9."
23-
" Use the equivalent class from the pytorch_lightning.loops.loop.Loop class instead."
18+
def _patch_sys_modules() -> None:
19+
# TODO: Remove in v2.0.0
20+
self = sys.modules[__name__]
21+
sys.modules["pytorch_lightning.loops.base"] = self
22+
23+
24+
class Loop:
25+
# TODO: Remove in v2.0.0
26+
def __init__(self, *_: Any, **__: Any) -> None:
27+
raise NotImplementedError(
28+
"`pytorch_lightning.loops.base.Loop` was deprecated in v1.7.0 and removed as of v1.9.0."
29+
" Please use `pytorch_lightning.loops.loop.Loop` instead"
2430
)
25-
super().__init__()
31+
32+
33+
_patch_sys_modules()

tests/tests_pytorch/deprecated_api/test_remove_1-9.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,6 @@ def test_old_lightningmodule_path():
2525
LightningModule()
2626

2727

28-
def test_old_loop_path():
29-
from pytorch_lightning.loops.base import Loop
30-
31-
class MyLoop(Loop):
32-
def advance(self):
33-
...
34-
35-
def done(self):
36-
...
37-
38-
def reset(self):
39-
...
40-
41-
with pytest.deprecated_call(match="pytorch_lightning.loops.base.Loop has been deprecated in v1.7"):
42-
MyLoop()
43-
44-
4528
def test_old_callback_path():
4629
from pytorch_lightning.callbacks.base import Callback
4730

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import pytest
2+
3+
4+
def test_v2_0_0_unsupported_base_loop():
5+
from pytorch_lightning.loops.base import Loop
6+
7+
with pytest.raises(NotImplementedError, match="Loop` was deprecated in v1.7.0 and removed as of v1.9"):
8+
Loop()

0 commit comments

Comments
 (0)