Skip to content

Commit 75d7357

Browse files
AlessandroWlantiga
andauthored
Proposal(CLI): after_instantiate_classes hook (#20401)
feat(cli): after_instantiate_classes hook Co-authored-by: Luca Antiga <[email protected]>
1 parent 0afd4e1 commit 75d7357

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/lightning/pytorch/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ def __init__(
390390
self._add_instantiators()
391391
self.before_instantiate_classes()
392392
self.instantiate_classes()
393+
self.after_instantiate_classes()
393394

394395
if self.subcommand is not None:
395396
self._run_subcommand(self.subcommand)
@@ -561,6 +562,9 @@ def instantiate_classes(self) -> None:
561562
self._add_configure_optimizers_method_to_model(self.subcommand)
562563
self.trainer = self.instantiate_trainer()
563564

565+
def after_instantiate_classes(self) -> None:
566+
"""Implement to run some code after instantiating the classes."""
567+
564568
def instantiate_trainer(self, **kwargs: Any) -> Trainer:
565569
"""Instantiates the trainer.
566570

0 commit comments

Comments
 (0)