Check that model is configured correctly
🚀 Feature
Check that model is correctly setup before training
Motivation
As of right now, there is no checking that essential methods like training_step, configure_optimizers and train_dataloader are proper defined in the model.
For example if no configure_optimizers is defined the model will train, however nothing will happen. If no training_step is defined then this error occurs:
AttributeError: 'NoneType' object has no attribute 'items',
which are not very useful error message.
Additionally, it would be useful to check if a val_dataloader is defined then validation_step and validation_step_end is also defined.
Pitch
Some checking is already done here:

  
    
      pytorch-lightning/pytorch_lightning/trainer/trainer.py
    
    
        Lines 649 to 668
      in
      c32e3f3
    
  
  
    

        
          
           if train_dataloader is not None: 
        

        
          
               if not self.is_overriden('training_step', model): 
        

        
          
                   m = 'You called .fit() with a train_dataloader but did not define training_step()' 
        

        
          
                   raise MisconfigurationException(m) 
        

        
          
            
        

        
          
               model.train_dataloader = _PatchDataLoader(train_dataloader) 
        

        
          
            
        

        
          
           if val_dataloaders is not None: 
        

        
          
               if not self.is_overriden('validation_step', model): 
        

        
          
                   m = 'You called .fit() with a val_dataloaders but did not define validation_step()' 
        

        
          
                   raise MisconfigurationException(m) 
        

        
          
            
        

        
          
               model.val_dataloader = _PatchDataLoader(val_dataloaders) 
        

        
          
            
        

        
          
           if test_dataloaders is not None: 
        

        
          
               if not self.is_overriden('test_step', model): 
        

        
          
                   m = 'You called .fit() with a test_dataloaders but did not define test_step()' 
        

        
          
                   raise MisconfigurationException(m) 
        

        
          
            
        

        
          
               model.test_dataloader = _PatchDataLoader(test_dataloaders) 
        
    
  


but that is checked if an user pass in dataloaders to the .fit() method. I propose to expand on this in a separate method, something like
    def model_correctly_configured(self, model):
        if not self.is_overriden('train_dataloader', model):
            raise MisconfigurationException('No train_dataloader defined')
    
        if not self.is_overriden('configure_optimizers', model):
            raise MisconfigurationException('No configure_optimizers method defined')
        
        if not self.is_overriden('training_step', model):
            raise MisconfigurationException('No training_step method defined')
            
        if self.is_overriden('val_dataloader', model):
            if not self.is_overriden('validation_step', model):
                raise MisconfigurationException('defined val_dataloader but no val_step')
            else:
                if not self.is_overriden('validation_epoch_end', model):
                    warnings.warn('You have a val_dataloader and validation_step,'
                                 'you may want to also defined val_step_end')
                    
        if self.is_overriden('test_dataloader', model):
            if not self.is_overriden('test_step', model):
                raise MisconfigurationException('defined test_dataloader but no test_step')
            else:
                if not self.is_overriden('test_epoch_end', model):
                    warnings.warn('You have a test_dataloader and test_step,'
                                 'you may want to also defined val_step_end')

possible with even more checks.