@@ -948,12 +948,6 @@ def test(
948948 # Attach dataloaders (if given)
949949 self .data_connector .attach_dataloaders (model , test_dataloaders = test_dataloaders )
950950
951- if not model_provided and ckpt_path == 'best' and self .fast_dev_run :
952- raise MisconfigurationException (
953- 'You cannot execute testing when the model is not provided and `fast_dev_run=True`. '
954- 'Provide model with `trainer.test(model=...)` or `trainer.test(ckpt_path=...)`'
955- )
956-
957951 if not model_provided :
958952 self .tested_ckpt_path = self .__load_ckpt_weights (model , ckpt_path = ckpt_path )
959953
@@ -971,10 +965,17 @@ def __load_ckpt_weights(
971965 ckpt_path : Optional [str ] = None ,
972966 ) -> Optional [str ]:
973967 # if user requests the best checkpoint but we don't have it, error
974- if ckpt_path == 'best' and not self .checkpoint_callback .best_model_path :
975- raise MisconfigurationException (
976- 'ckpt_path is "best", but `ModelCheckpoint` is not configured to save the best model.'
977- )
968+ if ckpt_path == 'best' :
969+ if not self .checkpoint_callback .best_model_path and self .fast_dev_run :
970+ raise MisconfigurationException (
971+ 'You cannot execute `trainer.test()` or trainer.validate()`'
972+ ' when `fast_dev_run=True`.'
973+ )
974+
975+ if not self .checkpoint_callback .best_model_path :
976+ raise MisconfigurationException (
977+ 'ckpt_path is "best", but `ModelCheckpoint` is not configured to save the best model.'
978+ )
978979
979980 # load best weights
980981 if ckpt_path is not None :
0 commit comments