From 7e9c5aa4596037a202e79ea4d316169d517cd13c Mon Sep 17 00:00:00 2001 From: jirka Date: Wed, 12 May 2021 14:39:27 +0200 Subject: [PATCH 1/9] argparse_utils --- pytorch_lightning/utilities/argparse_utils.py | 2 -- tests/deprecated_api/test_remove_1-4.py | 4 ---- 2 files changed, 6 deletions(-) diff --git a/pytorch_lightning/utilities/argparse_utils.py b/pytorch_lightning/utilities/argparse_utils.py index 17f0e9b8cc4a9..92cb7804da878 100644 --- a/pytorch_lightning/utilities/argparse_utils.py +++ b/pytorch_lightning/utilities/argparse_utils.py @@ -2,8 +2,6 @@ rank_zero_deprecation("`argparse_utils` package has been renamed to `argparse` since v1.2 and will be removed in v1.4") -from pytorch_lightning.utilities.argparse import * # noqa: F403 E402 F401 - # for backward compatibility with old checkpoints (versions < 1.2.0) # that need to be able to unpickle the function from the checkpoint from pytorch_lightning.utilities.argparse import _gpus_arg_default # noqa: E402 F401 # isort: skip diff --git a/tests/deprecated_api/test_remove_1-4.py b/tests/deprecated_api/test_remove_1-4.py index 99e1b31f6edad..efa58ccddfd72 100644 --- a/tests/deprecated_api/test_remove_1-4.py +++ b/tests/deprecated_api/test_remove_1-4.py @@ -45,10 +45,6 @@ def test_v1_4_0_deprecated_trainer_methods(): def test_v1_4_0_deprecated_imports(): - _soft_unimport_module('pytorch_lightning.utilities.argparse_utils') - with pytest.deprecated_call(match='will be removed in v1.4'): - from pytorch_lightning.utilities.argparse_utils import from_argparse_args # noqa: F811 F401 - _soft_unimport_module('pytorch_lightning.utilities.model_utils') with pytest.deprecated_call(match='will be removed in v1.4'): from pytorch_lightning.utilities.model_utils import is_overridden # noqa: F811 F401 From 0ce64afe9b49ff7ec59f602c67df349f2957b519 Mon Sep 17 00:00:00 2001 From: jirka Date: Wed, 12 May 2021 14:40:30 +0200 Subject: [PATCH 2/9] model_utils --- pytorch_lightning/utilities/model_utils.py | 7 ------- tests/deprecated_api/test_remove_1-4.py | 4 ---- 2 files changed, 11 deletions(-) delete mode 100644 pytorch_lightning/utilities/model_utils.py diff --git a/pytorch_lightning/utilities/model_utils.py b/pytorch_lightning/utilities/model_utils.py deleted file mode 100644 index 728f73f4f0d32..0000000000000 --- a/pytorch_lightning/utilities/model_utils.py +++ /dev/null @@ -1,7 +0,0 @@ -from pytorch_lightning.utilities import rank_zero_deprecation - -rank_zero_deprecation( - "`model_utils` package has been renamed to `model_helpers` since v1.2 and will be removed in v1.4" -) - -from pytorch_lightning.utilities.model_helpers import * # noqa: F403 E402 F401 diff --git a/tests/deprecated_api/test_remove_1-4.py b/tests/deprecated_api/test_remove_1-4.py index efa58ccddfd72..80534633cf1c1 100644 --- a/tests/deprecated_api/test_remove_1-4.py +++ b/tests/deprecated_api/test_remove_1-4.py @@ -45,10 +45,6 @@ def test_v1_4_0_deprecated_trainer_methods(): def test_v1_4_0_deprecated_imports(): - _soft_unimport_module('pytorch_lightning.utilities.model_utils') - with pytest.deprecated_call(match='will be removed in v1.4'): - from pytorch_lightning.utilities.model_utils import is_overridden # noqa: F811 F401 - _soft_unimport_module('pytorch_lightning.utilities.warning_utils') with pytest.deprecated_call(match='will be removed in v1.4'): from pytorch_lightning.utilities.warning_utils import WarningCache # noqa: F811 F401 From 9769afa70db015cfe8ed24f3fd62a26da5102c01 Mon Sep 17 00:00:00 2001 From: jirka Date: Wed, 12 May 2021 14:40:48 +0200 Subject: [PATCH 3/9] warning_utils --- pytorch_lightning/utilities/warning_utils.py | 5 ----- tests/deprecated_api/test_remove_1-4.py | 3 --- 2 files changed, 8 deletions(-) delete mode 100644 pytorch_lightning/utilities/warning_utils.py diff --git a/pytorch_lightning/utilities/warning_utils.py b/pytorch_lightning/utilities/warning_utils.py deleted file mode 100644 index 0668bababa609..0000000000000 --- a/pytorch_lightning/utilities/warning_utils.py +++ /dev/null @@ -1,5 +0,0 @@ -from pytorch_lightning.utilities import rank_zero_deprecation - -rank_zero_deprecation("`warning_utils` package has been renamed to `warnings` since v1.2 and will be removed in v1.4") - -from pytorch_lightning.utilities.warnings import * # noqa: F403 E402 F401 diff --git a/tests/deprecated_api/test_remove_1-4.py b/tests/deprecated_api/test_remove_1-4.py index 80534633cf1c1..17e3e69aba2d1 100644 --- a/tests/deprecated_api/test_remove_1-4.py +++ b/tests/deprecated_api/test_remove_1-4.py @@ -45,9 +45,6 @@ def test_v1_4_0_deprecated_trainer_methods(): def test_v1_4_0_deprecated_imports(): - _soft_unimport_module('pytorch_lightning.utilities.warning_utils') - with pytest.deprecated_call(match='will be removed in v1.4'): - from pytorch_lightning.utilities.warning_utils import WarningCache # noqa: F811 F401 _soft_unimport_module('pytorch_lightning.utilities.xla_device_utils') with pytest.deprecated_call(match='will be removed in v1.4'): From e5ef30cb517f54a1ee46836f7f9b5f73b4cc7502 Mon Sep 17 00:00:00 2001 From: jirka Date: Wed, 12 May 2021 14:41:07 +0200 Subject: [PATCH 4/9] xla_device_utils --- .../utilities/xla_device_utils.py | 20 ------------------- tests/deprecated_api/test_remove_1-4.py | 7 ------- 2 files changed, 27 deletions(-) delete mode 100644 pytorch_lightning/utilities/xla_device_utils.py diff --git a/pytorch_lightning/utilities/xla_device_utils.py b/pytorch_lightning/utilities/xla_device_utils.py deleted file mode 100644 index f028222e3930b..0000000000000 --- a/pytorch_lightning/utilities/xla_device_utils.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright The PyTorch Lightning team. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -from pytorch_lightning.utilities import rank_zero_deprecation - -rank_zero_deprecation( - "`xla_device_utils` package has been renamed to `xla_device` since v1.2 and will be removed in v1.4" -) - -from pytorch_lightning.utilities.xla_device import * # noqa: F403 E402 F401 diff --git a/tests/deprecated_api/test_remove_1-4.py b/tests/deprecated_api/test_remove_1-4.py index 17e3e69aba2d1..e3d278ff6d1d3 100644 --- a/tests/deprecated_api/test_remove_1-4.py +++ b/tests/deprecated_api/test_remove_1-4.py @@ -44,13 +44,6 @@ def test_v1_4_0_deprecated_trainer_methods(): assert trainer.get_model() == trainer.lightning_module -def test_v1_4_0_deprecated_imports(): - - _soft_unimport_module('pytorch_lightning.utilities.xla_device_utils') - with pytest.deprecated_call(match='will be removed in v1.4'): - from pytorch_lightning.utilities.xla_device_utils import XLADeviceUtils # noqa: F811 F401 - - def test_v1_4_0_deprecated_trainer_device_distrib(): """Test that Trainer attributes works fine.""" trainer = Trainer() From b9285e43523b3de77a94369f4b115c51cd98f5cf Mon Sep 17 00:00:00 2001 From: jirka Date: Wed, 12 May 2021 14:44:38 +0200 Subject: [PATCH 5/9] chlog --- CHANGELOG.md | 2 ++ pytorch_lightning/utilities/types.py | 1 + 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84db9b385009e..e61a998ce554b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Removed +- Removed deprecated utils modules `model_utils`, `warning_utils`, `xla_device_utils` and partially `argparse_utils` ([7503](https://github.com/PyTorchLightning/pytorch-lightning/pull/7503)) + ### Fixed diff --git a/pytorch_lightning/utilities/types.py b/pytorch_lightning/utilities/types.py index ecb0101a2279e..43143113036f3 100644 --- a/pytorch_lightning/utilities/types.py +++ b/pytorch_lightning/utilities/types.py @@ -2,6 +2,7 @@ import torch from torchmetrics import Metric + """ Convention: - Do not include any `_TYPE` suffix From dee8274acb21e16ac775beb3318b4d6ad59df76b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 12 May 2021 12:45:29 +0000 Subject: [PATCH 6/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pytorch_lightning/utilities/types.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pytorch_lightning/utilities/types.py b/pytorch_lightning/utilities/types.py index 43143113036f3..ecb0101a2279e 100644 --- a/pytorch_lightning/utilities/types.py +++ b/pytorch_lightning/utilities/types.py @@ -2,7 +2,6 @@ import torch from torchmetrics import Metric - """ Convention: - Do not include any `_TYPE` suffix From ab9783439271e5d4530ba2e5325c28627fafd05f Mon Sep 17 00:00:00 2001 From: jirka Date: Wed, 12 May 2021 16:53:03 +0200 Subject: [PATCH 7/9] flake8 --- tests/deprecated_api/test_remove_1-4.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/deprecated_api/test_remove_1-4.py b/tests/deprecated_api/test_remove_1-4.py index e3d278ff6d1d3..c18c3526ee01e 100644 --- a/tests/deprecated_api/test_remove_1-4.py +++ b/tests/deprecated_api/test_remove_1-4.py @@ -25,7 +25,6 @@ from pytorch_lightning.overrides.distributed import LightningDistributedModule from pytorch_lightning.plugins import DDPSpawnPlugin from pytorch_lightning.plugins.environments import LightningEnvironment -from tests.deprecated_api import _soft_unimport_module from tests.helpers import BoringModel from tests.helpers.runif import RunIf From b36c5c849282aca46bf26ad94525de3ad271cb9a Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Thu, 13 May 2021 00:27:45 +0200 Subject: [PATCH 8/9] add test --- tests/deprecated_api/test_remove_1-4.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/deprecated_api/test_remove_1-4.py b/tests/deprecated_api/test_remove_1-4.py index de1263cb09e2d..b9090d82a7320 100644 --- a/tests/deprecated_api/test_remove_1-4.py +++ b/tests/deprecated_api/test_remove_1-4.py @@ -25,10 +25,17 @@ from pytorch_lightning.overrides.distributed import LightningDistributedModule from pytorch_lightning.plugins import DDPSpawnPlugin from pytorch_lightning.plugins.environments import LightningEnvironment +from tests.deprecated_api import _soft_unimport_module from tests.helpers import BoringModel from tests.helpers.runif import RunIf +def test_v1_4_0_deprecated_imports(): + _soft_unimport_module('pytorch_lightning.utilities.argparse_utils') + with pytest.deprecated_call(match='will be removed in v1.4'): + from pytorch_lightning.utilities.argparse_utils import _gpus_arg_default # noqa: F811 F401 + + def test_v1_4_0_deprecated_trainer_device_distrib(): """Test that Trainer attributes works fine.""" trainer = Trainer() From 578d95eec4060027818023cb11dc477184b9b9d7 Mon Sep 17 00:00:00 2001 From: jirka Date: Thu, 13 May 2021 08:54:50 +0200 Subject: [PATCH 9/9] fix --- dockers/tpu-tests/tpu_test_cases.jsonnet | 2 +- setup.cfg | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dockers/tpu-tests/tpu_test_cases.jsonnet b/dockers/tpu-tests/tpu_test_cases.jsonnet index 8c3f3693fda50..13f70deed43ca 100644 --- a/dockers/tpu-tests/tpu_test_cases.jsonnet +++ b/dockers/tpu-tests/tpu_test_cases.jsonnet @@ -22,7 +22,7 @@ local tputests = base.BaseTest { ||| cd pytorch-lightning coverage run --source=pytorch_lightning -m pytest -v --capture=no \ - pytorch_lightning/utilities/xla_device_utils.py \ + pytorch_lightning/utilities/xla_device.py \ tests/accelerators/test_tpu_backend.py \ tests/models/test_tpu.py test_exit_code=$? diff --git a/setup.cfg b/setup.cfg index 3fa6e39076725..ba4ee69da5464 100644 --- a/setup.cfg +++ b/setup.cfg @@ -44,7 +44,6 @@ exclude_lines = # *metrics (94%+) are temporarily removed from testing while tests speed up omit = pytorch_lightning/cluster_environments/*.py - pytorch_lightning/utilities/xla_device_utils.py pytorch_lightning/utilities/distributed.py pytorch_lightning/tuner/auto_gpu_select.py