From ff4771401a18dd34c1c5239f3fe6ba7bee27d125 Mon Sep 17 00:00:00 2001 From: sanjay aradhyamath Date: Thu, 7 Jul 2022 18:38:06 +0530 Subject: [PATCH 1/7] Removed the deprecated method --- src/pytorch_lightning/CHANGELOG.md | 2 ++ src/pytorch_lightning/overrides/distributed.py | 16 +--------------- .../deprecated_api/test_remove_1-7.py | 11 ----------- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/pytorch_lightning/CHANGELOG.md b/src/pytorch_lightning/CHANGELOG.md index 8d6fd64a2cb47..731836a42a504 100644 --- a/src/pytorch_lightning/CHANGELOG.md +++ b/src/pytorch_lightning/CHANGELOG.md @@ -174,6 +174,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Removed +- Removed the deprecated `IndexBatchSamplerWrapper.batch_indices` method ([]) + - Removed the deprecated `Logger.close` method ([#13149](https://github.com/PyTorchLightning/pytorch-lightning/pull/13149)) diff --git a/src/pytorch_lightning/overrides/distributed.py b/src/pytorch_lightning/overrides/distributed.py index 15a8632af938b..48fce1c9adfbc 100644 --- a/src/pytorch_lightning/overrides/distributed.py +++ b/src/pytorch_lightning/overrides/distributed.py @@ -178,21 +178,7 @@ def __init__(self, sampler: BatchSampler) -> None: 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 = [] 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 2ae305d2c06b7..c80140d71d199 100644 --- a/tests/tests_pytorch/deprecated_api/test_remove_1-7.py +++ b/tests/tests_pytorch/deprecated_api/test_remove_1-7.py @@ -22,7 +22,6 @@ 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, @@ -176,16 +175,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): From f88bfa34d11d8018a7b3a5c08835a0c39b9881c5 Mon Sep 17 00:00:00 2001 From: sanjay aradhyamath Date: Thu, 7 Jul 2022 18:44:58 +0530 Subject: [PATCH 2/7] Removed the deprecated method --- src/pytorch_lightning/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytorch_lightning/CHANGELOG.md b/src/pytorch_lightning/CHANGELOG.md index 731836a42a504..482fd4d91c9cd 100644 --- a/src/pytorch_lightning/CHANGELOG.md +++ b/src/pytorch_lightning/CHANGELOG.md @@ -174,7 +174,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Removed -- Removed the deprecated `IndexBatchSamplerWrapper.batch_indices` method ([]) +- Removed the deprecated `IndexBatchSamplerWrapper.batch_indices` method ([] - Removed the deprecated `Logger.close` method ([#13149](https://github.com/PyTorchLightning/pytorch-lightning/pull/13149)) From c493339d41b548ab7f00aa6b0470512923cfd9f9 Mon Sep 17 00:00:00 2001 From: sanjay aradhyamath Date: Thu, 7 Jul 2022 18:49:32 +0530 Subject: [PATCH 3/7] Removed deprecated IndexBatchSamplerWrapper.batch_indices --- src/pytorch_lightning/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytorch_lightning/CHANGELOG.md b/src/pytorch_lightning/CHANGELOG.md index 482fd4d91c9cd..731836a42a504 100644 --- a/src/pytorch_lightning/CHANGELOG.md +++ b/src/pytorch_lightning/CHANGELOG.md @@ -174,7 +174,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Removed -- Removed the deprecated `IndexBatchSamplerWrapper.batch_indices` method ([] +- Removed the deprecated `IndexBatchSamplerWrapper.batch_indices` method ([]) - Removed the deprecated `Logger.close` method ([#13149](https://github.com/PyTorchLightning/pytorch-lightning/pull/13149)) From 96d66cb51b01ddb40a41a559deffb236bb8abb45 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 7 Jul 2022 13:32:52 +0000 Subject: [PATCH 4/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/pytorch_lightning/CHANGELOG.md | 2 +- src/pytorch_lightning/overrides/distributed.py | 2 -- tests/tests_pytorch/deprecated_api/test_remove_1-7.py | 1 + 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pytorch_lightning/CHANGELOG.md b/src/pytorch_lightning/CHANGELOG.md index 731836a42a504..a9b4a89c530ad 100644 --- a/src/pytorch_lightning/CHANGELOG.md +++ b/src/pytorch_lightning/CHANGELOG.md @@ -175,7 +175,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Removed - Removed the deprecated `IndexBatchSamplerWrapper.batch_indices` method ([]) - + - Removed the deprecated `Logger.close` method ([#13149](https://github.com/PyTorchLightning/pytorch-lightning/pull/13149)) diff --git a/src/pytorch_lightning/overrides/distributed.py b/src/pytorch_lightning/overrides/distributed.py index 48fce1c9adfbc..637ef51da5950 100644 --- a/src/pytorch_lightning/overrides/distributed.py +++ b/src/pytorch_lightning/overrides/distributed.py @@ -178,8 +178,6 @@ def __init__(self, sampler: BatchSampler) -> None: self._sampler = sampler self._batch_indices: List[int] = [] - - def __iter__(self) -> Iterator[List[int]]: self.seen_batch_indices = [] for batch in self._sampler: 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 c80140d71d199..5d31982d26ac4 100644 --- a/tests/tests_pytorch/deprecated_api/test_remove_1-7.py +++ b/tests/tests_pytorch/deprecated_api/test_remove_1-7.py @@ -175,6 +175,7 @@ def is_using_torchelastic(): ): MyClusterEnvironment() + def test_v1_7_0_post_dispatch_hook(): class CustomPlugin(SingleDeviceStrategy): def post_dispatch(self, trainer): From 03590ebfc47e4f25155ffd352cfd9300787b92de Mon Sep 17 00:00:00 2001 From: Akihiro Nitta Date: Fri, 8 Jul 2022 07:24:14 +0900 Subject: [PATCH 5/7] Update src/pytorch_lightning/CHANGELOG.md --- src/pytorch_lightning/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytorch_lightning/CHANGELOG.md b/src/pytorch_lightning/CHANGELOG.md index a9b4a89c530ad..cc5c5f7a713c2 100644 --- a/src/pytorch_lightning/CHANGELOG.md +++ b/src/pytorch_lightning/CHANGELOG.md @@ -174,7 +174,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Removed -- Removed the deprecated `IndexBatchSamplerWrapper.batch_indices` method ([]) +- Removed deprecated `IndexBatchSamplerWrapper.batch_indices` ([#13565](https://github.com/PyTorchLightning/pytorch-lightning/pull/13565)) - Removed the deprecated `Logger.close` method ([#13149](https://github.com/PyTorchLightning/pytorch-lightning/pull/13149)) From 78e517fe549dfcea23cbc28439102924b8b8a257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Mon, 11 Jul 2022 23:58:48 +0200 Subject: [PATCH 6/7] Missed code --- src/pytorch_lightning/overrides/distributed.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pytorch_lightning/overrides/distributed.py b/src/pytorch_lightning/overrides/distributed.py index 637ef51da5950..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,12 +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] = [] 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 From b3af6ed85d81b6d94ee2d0dd7f2b62396bea975e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Tue, 12 Jul 2022 14:07:41 +0200 Subject: [PATCH 7/7] unused import --- tests/tests_pytorch/deprecated_api/test_remove_1-7.py | 1 - 1 file changed, 1 deletion(-) 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 c7424897ec77b..6f91d4c382831 100644 --- a/tests/tests_pytorch/deprecated_api/test_remove_1-7.py +++ b/tests/tests_pytorch/deprecated_api/test_remove_1-7.py @@ -15,7 +15,6 @@ import os from re import escape from unittest import mock -from unittest.mock import Mock import pytest import torch