Skip to content

Commit 28ac360

Browse files
committed
move the val_check_interval query to on_init_end
1 parent 48c6759 commit 28ac360

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pytorch_lightning/callbacks/model_checkpoint.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,16 +265,16 @@ def state_key(self) -> str:
265265
save_on_train_epoch_end=self._save_on_train_epoch_end,
266266
)
267267

268-
def on_pretrain_routine_start(self, trainer: "pl.Trainer", pl_module: "pl.LightningModule") -> None:
269-
"""
270-
When pretrain routine starts we build the ckpt dir on the fly
271-
"""
272-
self.__resolve_ckpt_dir(trainer)
268+
def on_init_end(self, trainer: "pl.Trainer") -> None:
273269
if self._save_on_train_epoch_end is None:
274270
# if the user runs validation multiple times per training epoch, we try to save checkpoint after
275271
# validation instead of on train epoch end
276272
self._save_on_train_epoch_end = trainer.val_check_interval == 1.0
277273

274+
def on_pretrain_routine_start(self, trainer: "pl.Trainer", pl_module: "pl.LightningModule") -> None:
275+
"""When pretrain routine starts we build the ckpt dir on the fly."""
276+
self.__resolve_ckpt_dir(trainer)
277+
278278
def on_train_start(self, trainer: "pl.Trainer", pl_module: "pl.LightningModule") -> None:
279279
self._last_time_checked = time.monotonic()
280280

0 commit comments

Comments
 (0)