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 src/pytorch_lightning/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Removed the deprecated `pytorch_lightning.loops.base` module in favor of `pytorch_lightning.loops.loop` ([#16142](https://github.com/PyTorchLightning/pytorch-lightning/pull/16142))


- Removed the deprecated `pytorch_lightning.core.lightning` module in favor of `pytorch_lightning.core.module` ([#16318](https://github.com/PyTorchLightning/pytorch-lightning/pull/16318))


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


Expand Down
18 changes: 18 additions & 0 deletions src/pytorch_lightning/_graveyard/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,27 @@
# 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.
import sys
from typing import Any

from pytorch_lightning import LightningDataModule


def _patch_sys_modules() -> None:
# TODO: Remove in v2.0.0
self = sys.modules[__name__]
sys.modules["pytorch_lightning.core.lightning"] = self


class LightningModule:
# TODO: Remove in v2.0.0
def __init__(self, *_: Any, **__: Any) -> None:
raise NotImplementedError(
"Importing `pytorch_lightning.core.lightning.LightningModule` was deprecated in v1.7.0 and removed as of"
" v1.9.0. Please use `from pytorch_lightning import LightningModule` instead"
)


def _on_save_checkpoint(_: LightningDataModule, __: Any) -> None:
# TODO: Remove in v2.0.0
raise NotImplementedError(
Expand All @@ -32,6 +48,8 @@ def _on_load_checkpoint(_: LightningDataModule, __: Any) -> None:
)


_patch_sys_modules()

# Methods
LightningDataModule.on_save_checkpoint = _on_save_checkpoint
LightningDataModule.on_load_checkpoint = _on_load_checkpoint
27 changes: 0 additions & 27 deletions src/pytorch_lightning/core/lightning.py

This file was deleted.

10 changes: 0 additions & 10 deletions tests/tests_pytorch/deprecated_api/test_remove_1-9.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@
import pytest


def test_old_lightningmodule_path():
from pytorch_lightning.core.lightning import LightningModule

with pytest.deprecated_call(
match="pytorch_lightning.core.lightning.LightningModule has been deprecated in v1.7"
" and will be removed in v1.9."
):
LightningModule()


def test_old_callback_path():
from pytorch_lightning.callbacks.base import Callback

Expand Down
9 changes: 9 additions & 0 deletions tests/tests_pytorch/graveyard/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
from pytorch_lightning.demos.boring_classes import BoringDataModule, BoringModel


def test_v2_0_0_moved_lightningmodule():
from pytorch_lightning.core.lightning import LightningModule

with pytest.raises(
NotImplementedError, match="lightning.LightningModule.*was deprecated in v1.7.0 and removed as of v1.9"
):
LightningModule()


def test_v2_0_0_unsupported_datamodule_on_save_load_checkpoint():
datamodule = LightningDataModule()
with pytest.raises(
Expand Down