Skip to content

Commit 06e1f19

Browse files
authored
Remove the deprecated profiler imports (#16059)
1 parent 6745531 commit 06e1f19

File tree

15 files changed

+246
-245
lines changed

15 files changed

+246
-245
lines changed

src/lightning_app/utilities/introspection.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class LightningLoggerVisitor(LightningVisitor):
149149
Names of methods that are part of the Logger API.
150150
"""
151151

152-
class_name = "LightningLoggerBase"
152+
class_name = "Logger"
153153

154154
methods: Set[str] = {"log_hyperparams", "log_metrics"}
155155

@@ -248,10 +248,6 @@ class LightningAcceleratorVisitor(LightningVisitor):
248248
class_name = "Accelerator"
249249

250250

251-
class LightningLoggerBaseVisitor(LightningVisitor):
252-
class_name = "LightningLoggerBase"
253-
254-
255251
class LightningLoopVisitor(LightningVisitor):
256252
class_name = "Loop"
257253

@@ -264,8 +260,8 @@ class LightningLiteVisitor(LightningVisitor):
264260
class_name = "LightningLite"
265261

266262

267-
class LightningBaseProfilerVisitor(LightningVisitor):
268-
class_name = "BaseProfiler"
263+
class LightningProfilerVisitor(LightningVisitor):
264+
class_name = "Profiler"
269265

270266

271267
class Scanner:
@@ -295,11 +291,11 @@ class Scanner:
295291
LightningStrategyVisitor,
296292
LightningPrecisionPluginVisitor,
297293
LightningAcceleratorVisitor,
298-
LightningLoggerBaseVisitor,
294+
LightningLoggerVisitor,
299295
LightningLoopVisitor,
300296
TorchMetricVisitor,
301297
LightningLiteVisitor,
302-
LightningBaseProfilerVisitor,
298+
LightningProfilerVisitor,
303299
]
304300

305301
def __init__(self, path: str, glob_pattern: str = "**/*.py"):

src/pytorch_lightning/CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
6969
- Deprecated `description`, `env_prefix` and `env_parse` parameters in `LightningCLI.__init__` in favour of giving them through `parser_kwargs` ([#15651](https://github.com/Lightning-AI/lightning/pull/15651))
7070

7171

72-
-
72+
- Deprecated `pytorch_lightning.profiler` in favor of `pytorch_lightning.profilers` ([#16059](https://github.com/PyTorchLightning/pytorch-lightning/pull/16059))
7373

7474

7575
### Removed
@@ -95,6 +95,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
9595
- Removed the deprecated `pytorch_lightning.accelerators.GPUAccelerator` in favor of `pytorch_lightning.accelerators.CUDAAccelerator` ([#16050](https://github.com/Lightning-AI/lightning/pull/16050))
9696

9797

98+
- Removed the deprecated `pytorch_lightning.profiler.*` classes in favor of `pytorch_lightning.profilers` ([#16059](https://github.com/PyTorchLightning/pytorch-lightning/pull/16059))
99+
98100

99101
### Fixed
100102

@@ -508,7 +510,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
508510
- Deprecated `Trainer.reset_train_val_dataloaders()` in favor of `Trainer.reset_{train,val}_dataloader` ([#12184](https://github.com/Lightning-AI/lightning/pull/12184))
509511
- Deprecated LightningCLI's registries in favor of importing the respective package ([#13221](https://github.com/Lightning-AI/lightning/pull/13221))
510512
- Deprecated public utilities in `pytorch_lightning.utilities.cli.LightningCLI` in favor of equivalent copies in `pytorch_lightning.cli.LightningCLI` ([#13767](https://github.com/Lightning-AI/lightning/pull/13767))
511-
- Deprecated `pytorch_lightning.profiler` in favor of `pytorch_lightning.profilers` ([#12308](https://github.com/Lightning-AI/lightning/pull/12308))
513+
- Deprecated `pytorch_lightning.profiler.*` in favor of `pytorch_lightning.profilers` ([#12308](https://github.com/Lightning-AI/lightning/pull/12308))
512514

513515
### Removed
514516

src/pytorch_lightning/_graveyard/profiler.py

Lines changed: 87 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,22 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
import sys
1415
from typing import Any
1516

16-
import pytorch_lightning.profiler.base as base
17+
18+
def _patch_sys_modules() -> None:
19+
# TODO: Remove in v2.0.0
20+
self = sys.modules[__name__]
21+
sys.modules["pytorch_lightning.profiler.advanced"] = self
22+
sys.modules["pytorch_lightning.profiler.base"] = self
23+
sys.modules["pytorch_lightning.profiler.profiler"] = self
24+
sys.modules["pytorch_lightning.profiler.pytorch"] = self
25+
sys.modules["pytorch_lightning.profiler.simple"] = self
26+
sys.modules["pytorch_lightning.profiler.xla"] = self
1727

1828

19-
class _AbstractProfiler:
29+
class AbstractProfiler:
2030
# TODO: Remove in v2.0.0
2131
def __init__(self, *_: Any, **__: Any) -> None:
2232
raise NotImplementedError(
@@ -25,14 +35,85 @@ def __init__(self, *_: Any, **__: Any) -> None:
2535
)
2636

2737

28-
class _BaseProfiler:
38+
class BaseProfiler:
2939
# TODO: Remove in v2.0.0
3040
def __init__(self, *_: Any, **__: Any) -> None:
3141
raise RuntimeError(
32-
"`pytorch_lightning.profiler.base.AbstractProfiler` was deprecated in v1.6 and is no longer supported"
42+
"`pytorch_lightning.profiler.base.BaseProfiler` was deprecated in v1.6 and is no longer supported"
3343
" as of v1.9. Use `pytorch_lightning.profilers.Profiler` instead."
3444
)
3545

3646

37-
base.AbstractProfiler = _AbstractProfiler
38-
base.BaseProfiler = _BaseProfiler
47+
class AdvancedProfiler:
48+
# TODO: Remove in v2.0.0
49+
def __init__(self, *_: Any, **__: Any) -> None:
50+
raise RuntimeError(
51+
"`pytorch_lightning.profiler.advanced.AdvancedProfiler` was deprecated in v1.7.0 and is not longer"
52+
" supported as of v1.9.0. Use `pytorch_lightning.profilers.AdvancedProfiler` instead."
53+
)
54+
55+
56+
class PassThroughProfiler:
57+
# TODO: Remove in v2.0.0
58+
def __init__(self, *_: Any, **__: Any) -> None:
59+
raise RuntimeError(
60+
"`pytorch_lightning.profiler.base.PassThroughProfiler` was deprecated in v1.7.0 and is not longer"
61+
" supported as of v1.9.0. Use `pytorch_lightning.profilers.PassThroughProfiler` instead."
62+
)
63+
64+
65+
class Profiler:
66+
# TODO: Remove in v2.0.0
67+
def __init__(self, *_: Any, **__: Any) -> None:
68+
raise RuntimeError(
69+
"`pytorch_lightning.profiler.profiler.Profiler` was deprecated in v1.7.0 and is not longer"
70+
" supported as of v1.9.0. Use `pytorch_lightning.profilers.Profiler` instead."
71+
)
72+
73+
74+
class PyTorchProfiler:
75+
# TODO: Remove in v2.0.0
76+
def __init__(self, *_: Any, **__: Any) -> None:
77+
raise RuntimeError(
78+
"`pytorch_lightning.profiler.pytorch.PyTorchProfiler` was deprecated in v1.7.0 and is not longer"
79+
" supported as of v1.9.0. Use `pytorch_lightning.profilers.PyTorchProfiler` instead."
80+
)
81+
82+
83+
class RegisterRecordFunction:
84+
# TODO: Remove in v2.0.0
85+
def __init__(self, *_: Any, **__: Any) -> None:
86+
raise RuntimeError(
87+
"`pytorch_lightning.profiler.pytorch.RegisterRecordFunction` was deprecated in v1.7.0 and is not longer"
88+
" supported as of v1.9.0. Use `pytorch_lightning.profilers.pytorch.RegisterRecordFunction` instead."
89+
)
90+
91+
92+
class ScheduleWrapper:
93+
# TODO: Remove in v2.0.0
94+
def __init__(self, *_: Any, **__: Any) -> None:
95+
raise RuntimeError(
96+
"`pytorch_lightning.profiler.pytorch.ScheduleWrapper` was deprecated in v1.7.0 and is not longer"
97+
" supported as of v1.9.0. Use `pytorch_lightning.profilers.pytorch.ScheduleWrapper` instead."
98+
)
99+
100+
101+
class SimpleProfiler:
102+
# TODO: Remove in v2.0.0
103+
def __init__(self, *_: Any, **__: Any) -> None:
104+
raise RuntimeError(
105+
"`pytorch_lightning.profiler.simple.SimpleProfiler` was deprecated in v1.7.0 and is not longer"
106+
" supported as of v1.9.0. Use `pytorch_lightning.profilers.SimpleProfiler` instead."
107+
)
108+
109+
110+
class XLAProfiler:
111+
# TODO: Remove in v2.0.0
112+
def __init__(self, *_: Any, **__: Any) -> None:
113+
raise RuntimeError(
114+
"`pytorch_lightning.profiler.xla.XLAProfiler` was deprecated in v1.7.0 and is not longer"
115+
" supported as of v1.9.0. Use `pytorch_lightning.profilers.XLAProfiler` instead."
116+
)
117+
118+
119+
_patch_sys_modules()

src/pytorch_lightning/profiler/__init__.py

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,70 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from pytorch_lightning.profilers.advanced import AdvancedProfiler
15-
from pytorch_lightning.profilers.base import PassThroughProfiler
16-
from pytorch_lightning.profilers.profiler import Profiler
17-
from pytorch_lightning.profilers.pytorch import PyTorchProfiler
18-
from pytorch_lightning.profilers.simple import SimpleProfiler
19-
from pytorch_lightning.profilers.xla import XLAProfiler
14+
from typing import Any
15+
16+
from pytorch_lightning.profilers.advanced import AdvancedProfiler as NewAdvancedProfiler
17+
from pytorch_lightning.profilers.base import PassThroughProfiler as NewPassThroughProfiler
18+
from pytorch_lightning.profilers.profiler import Profiler as NewProfiler
19+
from pytorch_lightning.profilers.pytorch import PyTorchProfiler as NewPyTorchProfiler
20+
from pytorch_lightning.profilers.simple import SimpleProfiler as NewSimpleProfiler
21+
from pytorch_lightning.profilers.xla import XLAProfiler as NewXLAProfiler
22+
from pytorch_lightning.utilities.rank_zero import rank_zero_deprecation
23+
24+
25+
class AdvancedProfiler(NewAdvancedProfiler):
26+
def __init__(self, *args: Any, **kwargs: Any) -> None:
27+
rank_zero_deprecation(
28+
"`pytorch_lightning.profiler.AdvancedProfiler` is deprecated in v1.9.0 and will be removed in v1.10.0."
29+
" Use the equivalent `pytorch_lightning.profilers.AdvancedProfiler` class instead."
30+
)
31+
super().__init__(*args, **kwargs)
32+
33+
34+
class PassThroughProfiler(NewPassThroughProfiler):
35+
def __init__(self, *args: Any, **kwargs: Any) -> None:
36+
rank_zero_deprecation(
37+
"`pytorch_lightning.profiler.PassThroughProfiler` is deprecated in v1.9.0 and will be removed in v1.10.0."
38+
" Use the equivalent `pytorch_lightning.profilers.PassThroughProfiler` class instead."
39+
)
40+
super().__init__(*args, **kwargs)
41+
42+
43+
class Profiler(NewProfiler):
44+
def __init__(self, *args: Any, **kwargs: Any) -> None:
45+
rank_zero_deprecation(
46+
"`pytorch_lightning.profiler.Profiler` is deprecated in v1.9.0 and will be removed in v1.10.0."
47+
" Use the equivalent `pytorch_lightning.profilers.Profiler` class instead."
48+
)
49+
super().__init__(*args, **kwargs)
50+
51+
52+
class PyTorchProfiler(NewPyTorchProfiler):
53+
def __init__(self, *args: Any, **kwargs: Any) -> None:
54+
rank_zero_deprecation(
55+
"`pytorch_lightning.profiler.PyTorchProfiler` is deprecated in v1.9.0 and will be removed in v1.10.0."
56+
" Use the equivalent `pytorch_lightning.profilers.PyTorchProfiler` class instead."
57+
)
58+
super().__init__(*args, **kwargs)
59+
60+
61+
class SimpleProfiler(NewSimpleProfiler):
62+
def __init__(self, *args: Any, **kwargs: Any) -> None:
63+
rank_zero_deprecation(
64+
"`pytorch_lightning.profiler.SimpleProfiler` is deprecated in v1.9.0 and will be removed in v1.10.0."
65+
" Use the equivalent `pytorch_lightning.profilers.SimpleProfiler` class instead."
66+
)
67+
super().__init__(*args, **kwargs)
68+
69+
70+
class XLAProfiler(NewXLAProfiler):
71+
def __init__(self, *args: Any, **kwargs: Any) -> None:
72+
rank_zero_deprecation(
73+
"`pytorch_lightning.profiler.XLAProfiler` is deprecated in v1.9.0 and will be removed in v1.10.0."
74+
" Use the equivalent `pytorch_lightning.profilers.XLAProfiler` class instead."
75+
)
76+
super().__init__(*args, **kwargs)
77+
2078

2179
__all__ = [
2280
"Profiler",

src/pytorch_lightning/profiler/advanced.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/pytorch_lightning/profiler/base.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/pytorch_lightning/profiler/profiler.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/pytorch_lightning/profiler/pytorch.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)