Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Feb 18, 2021
1 parent a33a6d2 commit 5947b39
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pytorch_lightning/trainer/deprecated_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ def use_single_gpu(self, val: bool) -> None:
if val:
self.accelerator_connector._device_type = DeviceType.GPU


class DeprecatedModelAttributes:

def get_model(self) -> LightningModule:
rank_zero_warn(
"The use of `Trainer.get_model()` is deprecated in favor of `Trainer.lightning_module`"
Expand Down
3 changes: 2 additions & 1 deletion pytorch_lightning/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from pytorch_lightning.trainer.connectors.slurm_connector import SLURMConnector
from pytorch_lightning.trainer.connectors.training_trick_connector import TrainingTricksConnector
from pytorch_lightning.trainer.data_loading import TrainerDataLoadingMixin
from pytorch_lightning.trainer.deprecated_api import DeprecatedDistDeviceAttributes
from pytorch_lightning.trainer.deprecated_api import DeprecatedDistDeviceAttributes, DeprecatedModelAttributes
from pytorch_lightning.trainer.evaluation_loop import EvaluationLoop
from pytorch_lightning.trainer.logging import TrainerLoggingMixin
from pytorch_lightning.trainer.model_hooks import TrainerModelHooksMixin
Expand Down Expand Up @@ -80,6 +80,7 @@ class Trainer(
TrainerTrainingTricksMixin,
TrainerDataLoadingMixin,
DeprecatedDistDeviceAttributes,
DeprecatedModelAttributes,
):

@overwrite_by_env_vars
Expand Down
4 changes: 1 addition & 3 deletions pytorch_lightning/utilities/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ def has_len(dataloader: DataLoader) -> bool:
try:
# try getting the length
if len(dataloader) == 0:
raise ValueError(
'`Dataloader` returned 0 length. Please make sure that it returns at least 1 batch'
)
raise ValueError('`Dataloader` returned 0 length. Please make sure that it returns at least 1 batch')
has_len = True
except TypeError:
has_len = False
Expand Down

0 comments on commit 5947b39

Please sign in to comment.