Skip to content

Commit 53416fb

Browse files
keplerBorda
andauthored
Apply suggestions from code review
Co-authored-by: Jirka Borovec <[email protected]>
1 parent c5abd85 commit 53416fb

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

pytorch_lightning/trainer/training_io.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,10 @@ def dump_checkpoint(self, weights_only: bool = False):
313313
}
314314

315315
if not weights_only:
316-
if self.checkpoint_callback is not None and self.checkpoint_callback is not False:
316+
if self.checkpoint_callback:
317317
checkpoint['checkpoint_callback_best'] = self.checkpoint_callback.best
318318

319-
if self.early_stop_callback is not None and self.checkpoint_callback is not False:
319+
if self.early_stop_callback:
320320
checkpoint['early_stop_callback_wait'] = self.early_stop_callback.wait
321321
checkpoint['early_stop_callback_patience'] = self.early_stop_callback.patience
322322

@@ -386,9 +386,8 @@ def restore_training_state(self, checkpoint):
386386
"""
387387
if 'optimizer_states' not in checkpoint or 'lr_schedulers' not in checkpoint:
388388
raise KeyError(
389-
f'Trying to restore training state but checkpoint contains only the model. '
390-
f'This is probably due to `ModelCheckpoint.save_weights_only` being set to '
391-
f'True.'
389+
'Trying to restore training state but checkpoint contains only the model.'
390+
' This is probably due to `ModelCheckpoint.save_weights_only` being set to `True`.'
392391
)
393392

394393
if self.checkpoint_callback is not None and self.checkpoint_callback is not False:

0 commit comments

Comments
 (0)