Mechanism to skip certain hooks
🚀 Feature
Do we need a way to prevent certain hooks to be executed? I'm not entirely sure how solid this idea is, so I'm hoping for some discussion :)
Motivation
A user encountered a use case in which they wanted to build the model in the setup hook. However, because the setup hook is exectued everytime regardless whether the model was already trained or not, this would then overwrite the weights of the model, making continued training impossible. #5410
Pitch
Something abstract like
model.skip_hooks = ["setup", ...]
could be considered.
Alternatives
The user can handle it on their side with some conditional code in their hook,
def setup(self, stage):
    if self.has_setup:
        return
    # do your thing
    ...
    self.has_setup = True
or forcefully remove the method from the model object, delattr(model, "setup"), for example.
Additional context
Originates from here
cc: @sjgosai
cc @Borda @tchaton @justusschock @awaelchli @carmocca @ninginthecloud @daniellepintz @rohitgr7