Skip to content

Commit 677d8bd

Browse files
committed
Update datamodule.py
1 parent b4e770a commit 677d8bd

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pytorch_lightning/core/datamodule.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
from torch.utils.data import DataLoader, Dataset, IterableDataset
2121

2222
from pytorch_lightning.core.hooks import CheckpointHooks, DataHooks
23-
from pytorch_lightning.utilities import rank_zero_only
2423
from pytorch_lightning.utilities.argparse import add_argparse_args, from_argparse_args, get_init_arguments_and_types
25-
from pytorch_lightning.utilities.distributed import rank_zero_deprecation
24+
from pytorch_lightning.utilities.distributed import rank_zero_deprecation, rank_zero_only, rank_zero_warn
2625

2726

2827
class LightningDataModule(CheckpointHooks, DataHooks):
@@ -434,8 +433,13 @@ def wrapped_fn(*args: str, **kwargs: Optional[str]) -> Any:
434433
has_run = obj._has_prepared_data
435434
obj._has_prepared_data = True
436435

437-
if not has_run:
438-
return fn(*args, **kwargs)
436+
if has_run:
437+
rank_zero_warn(
438+
f"DataModule.{name} has already been called, so it will not be called again. "
439+
f"In v1.6 this behavior will change to always call DataModule.{name}."
440+
)
441+
else:
442+
fn(*args, **kwargs)
439443

440444
return wrapped_fn
441445

0 commit comments

Comments
 (0)