Skip to content

Commit 45b679b

Browse files
keplerBorda
andcommitted
Apply suggestions from code review
Co-authored-by: Jirka Borovec <[email protected]>
1 parent 09eb8c5 commit 45b679b

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

@@ -393,9 +393,8 @@ def restore_training_state(self, checkpoint):
393393
"""
394394
if 'optimizer_states' not in checkpoint or 'lr_schedulers' not in checkpoint:
395395
raise KeyError(
396-
f'Trying to restore training state but checkpoint contains only the model. '
397-
f'This is probably due to `ModelCheckpoint.save_weights_only` being set to '
398-
f'True.'
396+
'Trying to restore training state but checkpoint contains only the model.'
397+
' This is probably due to `ModelCheckpoint.save_weights_only` being set to `True`.'
399398
)
400399

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

0 commit comments

Comments
 (0)