Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the deprecated profiler imports #16059

Merged
merged 3 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/pytorch_lightning/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,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` ([#12308](https://github.com/PyTorchLightning/pytorch-lightning/pull/12308))


### Removed
Expand All @@ -95,6 +95,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` ([#12308](https://github.com/PyTorchLightning/pytorch-lightning/pull/12308))


### Fixed

Expand Down Expand Up @@ -508,7 +510,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
carmocca marked this conversation as resolved.
Show resolved Hide resolved
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.

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

This file was deleted.

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

This file was deleted.

Loading