Skip to content
3 changes: 3 additions & 0 deletions src/pytorch_lightning/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down
19 changes: 0 additions & 19 deletions src/pytorch_lightning/overrides/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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

Expand Down
11 changes: 0 additions & 11 deletions tests/tests_pytorch/deprecated_api/test_remove_1-7.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down