Skip to content

Commit

Permalink
Remove the deprecated profiler imports (#16059)
Browse files Browse the repository at this point in the history
  • Loading branch information
carmocca authored and awaelchli committed Dec 19, 2022
1 parent 0fc7b82 commit eb4693f
Show file tree
Hide file tree
Showing 15 changed files with 250 additions and 245 deletions.
14 changes: 5 additions & 9 deletions src/lightning_app/utilities/introspection.py
Expand Up @@ -149,7 +149,7 @@ class LightningLoggerVisitor(LightningVisitor):
Names of methods that are part of the Logger API.
"""

class_name = "LightningLoggerBase"
class_name = "Logger"

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

Expand Down Expand Up @@ -248,10 +248,6 @@ class LightningAcceleratorVisitor(LightningVisitor):
class_name = "Accelerator"


class LightningLoggerBaseVisitor(LightningVisitor):
class_name = "LightningLoggerBase"


class LightningLoopVisitor(LightningVisitor):
class_name = "Loop"

Expand All @@ -264,8 +260,8 @@ class LightningLiteVisitor(LightningVisitor):
class_name = "Fabric"


class LightningBaseProfilerVisitor(LightningVisitor):
class_name = "BaseProfiler"
class LightningProfilerVisitor(LightningVisitor):
class_name = "Profiler"


class Scanner:
Expand Down Expand Up @@ -295,11 +291,11 @@ class Scanner:
LightningStrategyVisitor,
LightningPrecisionPluginVisitor,
LightningAcceleratorVisitor,
LightningLoggerBaseVisitor,
LightningLoggerVisitor,
LightningLoopVisitor,
TorchMetricVisitor,
LightningLiteVisitor,
LightningBaseProfilerVisitor,
LightningProfilerVisitor,
]

def __init__(self, path: str, glob_pattern: str = "**/*.py"):
Expand Down
6 changes: 4 additions & 2 deletions src/pytorch_lightning/CHANGELOG.md
Expand Up @@ -72,7 +72,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- 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))


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


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


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


### Fixed

Expand Down Expand Up @@ -512,7 +514,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Deprecated `Trainer.reset_train_val_dataloaders()` in favor of `Trainer.reset_{train,val}_dataloader` ([#12184](https://github.com/Lightning-AI/lightning/pull/12184))
- Deprecated LightningCLI's registries in favor of importing the respective package ([#13221](https://github.com/Lightning-AI/lightning/pull/13221))
- 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))
- Deprecated `pytorch_lightning.profiler` in favor of `pytorch_lightning.profilers` ([#12308](https://github.com/Lightning-AI/lightning/pull/12308))
- Deprecated `pytorch_lightning.profiler.*` in favor of `pytorch_lightning.profilers` ([#12308](https://github.com/Lightning-AI/lightning/pull/12308))

### Removed

Expand Down
93 changes: 87 additions & 6 deletions src/pytorch_lightning/_graveyard/profiler.py
Expand Up @@ -11,12 +11,22 @@
# 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.
import sys
from typing import Any

import pytorch_lightning.profiler.base as base

def _patch_sys_modules() -> None:
# TODO: Remove in v2.0.0
self = sys.modules[__name__]
sys.modules["pytorch_lightning.profiler.advanced"] = self
sys.modules["pytorch_lightning.profiler.base"] = self
sys.modules["pytorch_lightning.profiler.profiler"] = self
sys.modules["pytorch_lightning.profiler.pytorch"] = self
sys.modules["pytorch_lightning.profiler.simple"] = self
sys.modules["pytorch_lightning.profiler.xla"] = self


class _AbstractProfiler:
class AbstractProfiler:
# TODO: Remove in v2.0.0
def __init__(self, *_: Any, **__: Any) -> None:
raise NotImplementedError(
Expand All @@ -25,14 +35,85 @@ def __init__(self, *_: Any, **__: Any) -> None:
)


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


base.AbstractProfiler = _AbstractProfiler
base.BaseProfiler = _BaseProfiler
class AdvancedProfiler:
# TODO: Remove in v2.0.0
def __init__(self, *_: Any, **__: Any) -> None:
raise RuntimeError(
"`pytorch_lightning.profiler.advanced.AdvancedProfiler` was deprecated in v1.7.0 and is not longer"
" supported as of v1.9.0. Use `pytorch_lightning.profilers.AdvancedProfiler` instead."
)


class PassThroughProfiler:
# TODO: Remove in v2.0.0
def __init__(self, *_: Any, **__: Any) -> None:
raise RuntimeError(
"`pytorch_lightning.profiler.base.PassThroughProfiler` was deprecated in v1.7.0 and is not longer"
" supported as of v1.9.0. Use `pytorch_lightning.profilers.PassThroughProfiler` instead."
)


class Profiler:
# TODO: Remove in v2.0.0
def __init__(self, *_: Any, **__: Any) -> None:
raise RuntimeError(
"`pytorch_lightning.profiler.profiler.Profiler` was deprecated in v1.7.0 and is not longer"
" supported as of v1.9.0. Use `pytorch_lightning.profilers.Profiler` instead."
)


class PyTorchProfiler:
# TODO: Remove in v2.0.0
def __init__(self, *_: Any, **__: Any) -> None:
raise RuntimeError(
"`pytorch_lightning.profiler.pytorch.PyTorchProfiler` was deprecated in v1.7.0 and is not longer"
" supported as of v1.9.0. Use `pytorch_lightning.profilers.PyTorchProfiler` instead."
)


class RegisterRecordFunction:
# TODO: Remove in v2.0.0
def __init__(self, *_: Any, **__: Any) -> None:
raise RuntimeError(
"`pytorch_lightning.profiler.pytorch.RegisterRecordFunction` was deprecated in v1.7.0 and is not longer"
" supported as of v1.9.0. Use `pytorch_lightning.profilers.pytorch.RegisterRecordFunction` instead."
)


class ScheduleWrapper:
# TODO: Remove in v2.0.0
def __init__(self, *_: Any, **__: Any) -> None:
raise RuntimeError(
"`pytorch_lightning.profiler.pytorch.ScheduleWrapper` was deprecated in v1.7.0 and is not longer"
" supported as of v1.9.0. Use `pytorch_lightning.profilers.pytorch.ScheduleWrapper` instead."
)


class SimpleProfiler:
# TODO: Remove in v2.0.0
def __init__(self, *_: Any, **__: Any) -> None:
raise RuntimeError(
"`pytorch_lightning.profiler.simple.SimpleProfiler` was deprecated in v1.7.0 and is not longer"
" supported as of v1.9.0. Use `pytorch_lightning.profilers.SimpleProfiler` instead."
)


class XLAProfiler:
# TODO: Remove in v2.0.0
def __init__(self, *_: Any, **__: Any) -> None:
raise RuntimeError(
"`pytorch_lightning.profiler.xla.XLAProfiler` was deprecated in v1.7.0 and is not longer"
" supported as of v1.9.0. Use `pytorch_lightning.profilers.XLAProfiler` instead."
)


_patch_sys_modules()
70 changes: 64 additions & 6 deletions src/pytorch_lightning/profiler/__init__.py
Expand Up @@ -11,12 +11,70 @@
# 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.profilers.advanced import AdvancedProfiler
from pytorch_lightning.profilers.base import PassThroughProfiler
from pytorch_lightning.profilers.profiler import Profiler
from pytorch_lightning.profilers.pytorch import PyTorchProfiler
from pytorch_lightning.profilers.simple import SimpleProfiler
from pytorch_lightning.profilers.xla import XLAProfiler
from typing import Any

from pytorch_lightning.profilers.advanced import AdvancedProfiler as NewAdvancedProfiler
from pytorch_lightning.profilers.base import PassThroughProfiler as NewPassThroughProfiler
from pytorch_lightning.profilers.profiler import Profiler as NewProfiler
from pytorch_lightning.profilers.pytorch import PyTorchProfiler as NewPyTorchProfiler
from pytorch_lightning.profilers.simple import SimpleProfiler as NewSimpleProfiler
from pytorch_lightning.profilers.xla import XLAProfiler as NewXLAProfiler
from pytorch_lightning.utilities.rank_zero import rank_zero_deprecation


class AdvancedProfiler(NewAdvancedProfiler):
def __init__(self, *args: Any, **kwargs: Any) -> None:
rank_zero_deprecation(
"`pytorch_lightning.profiler.AdvancedProfiler` is deprecated in v1.9.0 and will be removed in v1.10.0."
" Use the equivalent `pytorch_lightning.profilers.AdvancedProfiler` class instead."
)
super().__init__(*args, **kwargs)


class PassThroughProfiler(NewPassThroughProfiler):
def __init__(self, *args: Any, **kwargs: Any) -> None:
rank_zero_deprecation(
"`pytorch_lightning.profiler.PassThroughProfiler` is deprecated in v1.9.0 and will be removed in v1.10.0."
" Use the equivalent `pytorch_lightning.profilers.PassThroughProfiler` class instead."
)
super().__init__(*args, **kwargs)


class Profiler(NewProfiler):
def __init__(self, *args: Any, **kwargs: Any) -> None:
rank_zero_deprecation(
"`pytorch_lightning.profiler.Profiler` is deprecated in v1.9.0 and will be removed in v1.10.0."
" Use the equivalent `pytorch_lightning.profilers.Profiler` class instead."
)
super().__init__(*args, **kwargs)


class PyTorchProfiler(NewPyTorchProfiler):
def __init__(self, *args: Any, **kwargs: Any) -> None:
rank_zero_deprecation(
"`pytorch_lightning.profiler.PyTorchProfiler` is deprecated in v1.9.0 and will be removed in v1.10.0."
" Use the equivalent `pytorch_lightning.profilers.PyTorchProfiler` class instead."
)
super().__init__(*args, **kwargs)


class SimpleProfiler(NewSimpleProfiler):
def __init__(self, *args: Any, **kwargs: Any) -> None:
rank_zero_deprecation(
"`pytorch_lightning.profiler.SimpleProfiler` is deprecated in v1.9.0 and will be removed in v1.10.0."
" Use the equivalent `pytorch_lightning.profilers.SimpleProfiler` class instead."
)
super().__init__(*args, **kwargs)


class XLAProfiler(NewXLAProfiler):
def __init__(self, *args: Any, **kwargs: Any) -> None:
rank_zero_deprecation(
"`pytorch_lightning.profiler.XLAProfiler` is deprecated in v1.9.0 and will be removed in v1.10.0."
" Use the equivalent `pytorch_lightning.profilers.XLAProfiler` class instead."
)
super().__init__(*args, **kwargs)


__all__ = [
"Profiler",
Expand Down
24 changes: 0 additions & 24 deletions src/pytorch_lightning/profiler/advanced.py

This file was deleted.

25 changes: 0 additions & 25 deletions src/pytorch_lightning/profiler/base.py

This file was deleted.

30 changes: 0 additions & 30 deletions src/pytorch_lightning/profiler/profiler.py

This file was deleted.

44 changes: 0 additions & 44 deletions src/pytorch_lightning/profiler/pytorch.py

This file was deleted.

0 comments on commit eb4693f

Please sign in to comment.