Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the deprecated LightningDataModule.val_transforms #12763

Merged
merged 8 commits into from
Apr 22, 2022
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 @@ -121,6 +121,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Removed support for passing strategy names or strategy instances to the plugins Trainer argument ([#12700](https://github.com/PyTorchLightning/pytorch-lightning/pull/12700))


- Removed the deprecated `val_transforms` argument from the `LightningDataModule` constructor ([#12763](https://github.com/PyTorchLightning/pytorch-lightning/pull/12763))


- Removed the deprecated `test_transforms` argument from the `LightningDataModule` constructor ([#12773](https://github.com/PyTorchLightning/pytorch-lightning/pull/12773))


Expand Down
27 changes: 1 addition & 26 deletions pytorch_lightning/core/datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from pytorch_lightning.core.hooks import CheckpointHooks, DataHooks
from pytorch_lightning.core.mixins import HyperparametersMixin
from pytorch_lightning.utilities import rank_zero_deprecation
from pytorch_lightning.utilities.argparse import add_argparse_args, from_argparse_args, get_init_arguments_and_types


Expand Down Expand Up @@ -54,35 +53,11 @@ def teardown(self):

name: str = ...

def __init__(self, val_transforms=None):
def __init__(self) -> None:
super().__init__()
if val_transforms is not None:
rank_zero_deprecation(
"DataModule property `val_transforms` was deprecated in v1.5 and will be removed in v1.7."
)
self._val_transforms = val_transforms
# Pointer to the trainer object
self.trainer = None

@property
def val_transforms(self):
"""Optional transforms (or collection of transforms) you can apply to validation dataset.

.. deprecated:: v1.5 Will be removed in v1.7.0.
"""

rank_zero_deprecation(
"DataModule property `val_transforms` was deprecated in v1.5 and will be removed in v1.7."
)
return self._val_transforms

@val_transforms.setter
def val_transforms(self, t):
rank_zero_deprecation(
"DataModule property `val_transforms` was deprecated in v1.5 and will be removed in v1.7."
)
self._val_transforms = t

@classmethod
def add_argparse_args(cls, parent_parser: ArgumentParser, **kwargs) -> ArgumentParser:
"""Extends existing argparse by default `LightningDataModule` attributes."""
Expand Down
11 changes: 1 addition & 10 deletions tests/deprecated_api/test_remove_1-7.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import pytest
import torch

from pytorch_lightning import Callback, LightningDataModule, Trainer
from pytorch_lightning import Callback, Trainer
from pytorch_lightning.callbacks.lr_monitor import LearningRateMonitor
from pytorch_lightning.loggers import LoggerCollection, TestTubeLogger
from pytorch_lightning.overrides.distributed import IndexBatchSamplerWrapper
Expand All @@ -34,19 +34,10 @@
from pytorch_lightning.strategies import SingleDeviceStrategy
from tests.deprecated_api import _soft_unimport_module
from tests.helpers import BoringModel
from tests.helpers.datamodules import MNISTDataModule
from tests.loggers.test_logger import CustomLogger
from tests.plugins.environments.test_lsf_environment import _make_rankfile


def test_v1_7_0_datamodule_transform_properties(tmpdir):
dm = MNISTDataModule()
with pytest.deprecated_call(match=r"DataModule property `val_transforms` was deprecated in v1.5"):
dm.val_transforms = "b"
with pytest.deprecated_call(match=r"DataModule property `val_transforms` was deprecated in v1.5"):
_ = LightningDataModule(val_transforms="b")


def test_v1_7_0_moved_get_progress_bar_dict(tmpdir):
class TestModel(BoringModel):
def get_progress_bar_dict(self):
Expand Down