Skip to content

Commit

Permalink
as part of ticket Lightning-AI#8728; added deprecation warnings to Da…
Browse files Browse the repository at this point in the history
…tamodule methods: train_transforms, val_transforms, test_transforms, dums, and size
  • Loading branch information
Tshimanga committed Aug 11, 2021
1 parent cb2a8ed commit b05def4
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions pytorch_lightning/core/datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,40 +95,76 @@ def __init__(self, train_transforms=None, val_transforms=None, test_transforms=N
def train_transforms(self):
"""
Optional transforms (or collection of transforms) you can apply to train dataset
.. deprecated:: v1.5
Will be removed in v1.7.0.
"""

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

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

@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

@property
def test_transforms(self):
"""
Optional transforms (or collection of transforms) you can apply to test dataset
.. deprecated:: v1.5
Will be removed in v1.7.0.
"""

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

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

@property
def dims(self):
"""
A tuple describing the shape of your data. Extra functionality exposed in ``size``.
.. deprecated:: v1.5
Will be removed in v1.7.0.
"""
rank_zero_deprecation(
"DataModule property `dims` was deprecated in v1.5 and will be removed in v1.7."
)
return self._dims

@dims.setter
Expand All @@ -139,11 +175,17 @@ def size(self, dim=None) -> Union[Tuple, int]:
"""
Return the dimension of each input either as a tuple or list of tuples. You can index this
just as you would with a torch tensor.
.. deprecated:: v1.5
Will be removed in v1.7.0.
"""

if dim is not None:
return self.dims[dim]

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

@property
Expand Down

0 comments on commit b05def4

Please sign in to comment.