Skip to content

[RFC] Remove has_{setup/teardown}_{stage} properties from DataModule #7301

@ananthsub

Description

@ananthsub

🚀 Feature

Carrying forward discussion from #7289 (comment)

Remove these settings to give more control to the users and making trainer execution easier
https://github.com/PyTorchLightning/pytorch-lightning/blob/490cc57809ebeba19003b4101393a8a058217c31/pytorch_lightning/core/datamodule.py#L33-L52

Motivation

Consecutive calls like this have different behavior:

dm = MyDataModule()
model = MyLightningModule()
trainer.fit(model, datamodule=dm)
trainer.fit(model, datamodule=dm)

The second trainer.fit call will not run the prepare data, setup, or teardown hooks.

Removing this check gives us these advantages

  1. Simpler, consistent hook execution: More control for users for how they want to handle state changes
  2. Less state management inside the trainer and datamodule: less framework overhead/maintenance for us long term and easier debuggability

cc @carmocca

Pitch

Remove this code:

cc @carmocca

Alternatives

Additional context

Metadata

Metadata

Assignees

Labels

designIncludes a design discussiondiscussionIn a discussion stagerefactor

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions