diff --git a/src/pytorch_lightning/CHANGELOG.md b/src/pytorch_lightning/CHANGELOG.md index a4bec3f0adaa7..9b3cefc66bd19 100644 --- a/src/pytorch_lightning/CHANGELOG.md +++ b/src/pytorch_lightning/CHANGELOG.md @@ -174,6 +174,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Removed +- Removed deprecated `IndexBatchSamplerWrapper.batch_indices` ([#13565](https://github.com/PyTorchLightning/pytorch-lightning/pull/13565)) + + - Removed the deprecated `LightningModule.add_to_queue` and `LightningModule.get_from_queue` method ([#13600](https://github.com/PyTorchLightning/pytorch-lightning/pull/13600)) diff --git a/src/pytorch_lightning/overrides/distributed.py b/src/pytorch_lightning/overrides/distributed.py index 15a8632af938b..8048d83252af7 100644 --- a/src/pytorch_lightning/overrides/distributed.py +++ b/src/pytorch_lightning/overrides/distributed.py @@ -20,7 +20,6 @@ from torch.utils.data import BatchSampler, Dataset, DistributedSampler, Sampler from pytorch_lightning.overrides.base import _LightningModuleWrapperBase -from pytorch_lightning.utilities import rank_zero_deprecation from pytorch_lightning.utilities.exceptions import MisconfigurationException @@ -176,28 +175,10 @@ class IndexBatchSamplerWrapper: def __init__(self, sampler: BatchSampler) -> None: self.seen_batch_indices: List[List[int]] = [] self._sampler = sampler - self._batch_indices: List[int] = [] - - @property - def batch_indices(self) -> List[int]: - rank_zero_deprecation( - "The attribute `IndexBatchSamplerWrapper.batch_indices` was deprecated in v1.5 and will be removed in" - " v1.7. Access the full list `seen_batch_indices` instead." - ) - return self._batch_indices - - @batch_indices.setter - def batch_indices(self, indices: List[int]) -> None: - rank_zero_deprecation( - "The attribute `IndexBatchSamplerWrapper.batch_indices` was deprecated in v1.5 and will be removed in" - " v1.7. Access the full list `seen_batch_indices` instead." - ) - self._batch_indices = indices def __iter__(self) -> Iterator[List[int]]: self.seen_batch_indices = [] for batch in self._sampler: - self._batch_indices = batch self.seen_batch_indices.append(batch) yield batch diff --git a/tests/tests_pytorch/deprecated_api/test_remove_1-7.py b/tests/tests_pytorch/deprecated_api/test_remove_1-7.py index 629bb9f9136ef..4187757fa3980 100644 --- a/tests/tests_pytorch/deprecated_api/test_remove_1-7.py +++ b/tests/tests_pytorch/deprecated_api/test_remove_1-7.py @@ -15,14 +15,12 @@ import os from re import escape from unittest import mock -from unittest.mock import Mock import pytest import torch from pytorch_lightning import Trainer from pytorch_lightning.demos.boring_classes import BoringModel -from pytorch_lightning.overrides.distributed import IndexBatchSamplerWrapper from pytorch_lightning.plugins.environments import ( KubeflowEnvironment, LightningEnvironment, @@ -148,15 +146,6 @@ def is_using_torchelastic(): MyClusterEnvironment() -def test_v1_7_0_index_batch_sampler_wrapper_batch_indices(): - sampler = IndexBatchSamplerWrapper(Mock()) - with pytest.deprecated_call(match="was deprecated in v1.5 and will be removed in v1.7"): - _ = sampler.batch_indices - - with pytest.deprecated_call(match="was deprecated in v1.5 and will be removed in v1.7"): - sampler.batch_indices = [] - - def test_v1_7_0_post_dispatch_hook(): class CustomPlugin(SingleDeviceStrategy): def post_dispatch(self, trainer):