Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6dc7542
Revert "Remove deprecated device attributes from Trainer (#14829)"
awaelchli Oct 10, 2022
a3243ef
update
awaelchli Oct 10, 2022
66dff01
reset
awaelchli Oct 10, 2022
af00bf0
reset changelog
awaelchli Oct 10, 2022
dda8d75
fix
awaelchli Oct 10, 2022
ac03cfd
use_amp
awaelchli Oct 10, 2022
0300483
use amp
awaelchli Oct 10, 2022
c5089ea
Merge branch 'master' into feature/remove/trainer-attrs
awaelchli Oct 10, 2022
1231cf9
more
awaelchli Oct 10, 2022
1bb640d
x
awaelchli Oct 10, 2022
f53cffd
more
awaelchli Oct 10, 2022
955e014
Introduce the graveyard
carmocca Oct 10, 2022
24465fd
WIP
carmocca Oct 10, 2022
1665aa1
Merge branch 'feat/graveyard' into feature/remove/trainer-attrs
awaelchli Oct 10, 2022
ce118dc
trainer graveyard
awaelchli Oct 10, 2022
fd1188f
graveyard for module
awaelchli Oct 10, 2022
e9ed4db
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 10, 2022
ba7c48e
methods
awaelchli Oct 10, 2022
4d62492
Merge branch 'feature/remove/trainer-methods' into feature/remove/tra…
awaelchli Oct 10, 2022
421482a
methods
awaelchli Oct 10, 2022
4165239
methods
awaelchli Oct 10, 2022
6b6ddee
mixin
awaelchli Oct 10, 2022
1b59711
import stuff
awaelchli Oct 10, 2022
97a1462
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 10, 2022
81e708e
Merge branch 'master' into feature/remove/trainer-mixins
awaelchli Oct 11, 2022
d76d0c7
Merge branch 'master' into feature/remove/trainer-mixins
awaelchli Oct 11, 2022
b765ff3
fix
awaelchli Oct 11, 2022
5cef6d7
rm
awaelchli Oct 11, 2022
d318fa7
Apply suggestions from code review
awaelchli Oct 11, 2022
35b7a53
todo
awaelchli Oct 11, 2022
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
52 changes: 51 additions & 1 deletion src/pytorch_lightning/_graveyard/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,34 @@
# 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, Optional

from pytorch_lightning import Trainer


def _patch_sys_modules() -> None:
self = sys.modules[__name__]
sys.modules["pytorch_lightning.trainer.data_loading"] = self
sys.modules["pytorch_lightning.trainer.optimizers"] = self


class TrainerDataLoadingMixin:
# TODO: Remove in v2.0.0
def __init__(self) -> None:
raise NotImplementedError(
"The `TrainerDataLoadingMixin` class was deprecated in v1.6 and is no longer supported as of v1.8."
)


class TrainerOptimizersMixin:
# TODO: Remove in v2.0.0
def __init__(self) -> None:
raise NotImplementedError(
"The `TrainerOptimizersMixin` class was deprecated in v1.6 and is no longer supported as of v1.8."
)


def _gpus(_: Trainer) -> None:
# Remove in v2.0.0
raise AttributeError(
Expand Down Expand Up @@ -169,6 +191,30 @@ def _call_hook(_: Trainer, *__: Any, **___: Any) -> Any:
raise NotImplementedError("`Trainer.call_hook` was deprecated in v1.6 and is no longer supported as of v1.8.")


def _prepare_dataloader(_: Trainer, *__: Any, **___: Any) -> None:
raise NotImplementedError(
"`Trainer.prepare_dataloader` was deprecated in v1.6 and is no longer supported as of v1.8."
)


def _request_dataloader(_: Trainer, *__: Any, **___: Any) -> None:
raise NotImplementedError(
"`Trainer.request_dataloader` was deprecated in v1.6 and is no longer supported as of v1.8."
)


def _init_optimizers(_: Trainer, *__: Any, **___: Any) -> None:
raise NotImplementedError("`Trainer.init_optimizers` was deprecated in v1.6 and is no longer supported as of v1.8.")


def _convert_to_lightning_optimizers(_: Trainer) -> None:
raise NotImplementedError(
"`Trainer.convert_to_lightning_optimizers` was deprecated in v1.6 and is no longer supported as of v1.8."
)


_patch_sys_modules()

# Properties/Attributes
Trainer.gpus = property(_gpus)
Trainer.root_gpu = property(_root_gpu)
Expand All @@ -189,3 +235,7 @@ def _call_hook(_: Trainer, *__: Any, **___: Any) -> Any:
# Methods
Trainer.run_stage = _run_stage
Trainer.call_hook = _call_hook
Trainer.prepare_dataloader = _prepare_dataloader
Trainer.request_dataloader = _request_dataloader
Trainer.init_optimizers = _init_optimizers
Trainer.convert_to_lightning_optimizers = _convert_to_lightning_optimizers
51 changes: 51 additions & 0 deletions tests/tests_pytorch/graveyard/test_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,54 @@ def test_v2_0_0_unsupported_call_hook():
NotImplementedError, match="`Trainer.call_hook` was deprecated in v1.6 and is no longer supported as of v1.8."
):
trainer.call_hook("test_hook")


def test_v2_0_0_unsupported_data_loading_mixin():
from pytorch_lightning.trainer.data_loading import TrainerDataLoadingMixin

class CustomTrainerDataLoadingMixin(TrainerDataLoadingMixin):
pass

with pytest.raises(
NotImplementedError,
match="`TrainerDataLoadingMixin` class was deprecated in v1.6 and is no longer supported as of v1.8",
):
CustomTrainerDataLoadingMixin()

trainer = Trainer()
with pytest.raises(
NotImplementedError,
match="`Trainer.prepare_dataloader` was deprecated in v1.6 and is no longer supported as of v1.8.",
):
trainer.prepare_dataloader(None)
with pytest.raises(
NotImplementedError,
match="`Trainer.request_dataloader` was deprecated in v1.6 and is no longer supported as of v1.8.",
):
trainer.request_dataloader(None)


def test_v2_0_0_trainer_optimizers_mixin():
from pytorch_lightning.trainer.optimizers import TrainerOptimizersMixin

class CustomTrainerOptimizersMixin(TrainerOptimizersMixin):
pass

with pytest.raises(
NotImplementedError,
match="`TrainerOptimizersMixin` class was deprecated in v1.6 and is no longer supported as of v1.8",
):
CustomTrainerOptimizersMixin()

trainer = Trainer()
with pytest.raises(
NotImplementedError,
match="`Trainer.init_optimizers` was deprecated in v1.6 and is no longer supported as of v1.8.",
):
trainer.init_optimizers(None)

with pytest.raises(
NotImplementedError,
match="`Trainer.convert_to_lightning_optimizers` was deprecated in v1.6 and is no longer supported as of v1.8.",
):
trainer.convert_to_lightning_optimizers()