 Improve legacy checkpoint testing
🚀 Feature
Improve legacy checkpoint testing
Motivation
Currently, we only test whether a legacy checkpoint can be loaded and run, but no internal state is checked.
Pitch
Check the epoch number is correct, if the state is the expected, if we achieve a particular loss after 1 step...
We already have similar tests, we just have to do them for legacy checkpoints. see
https://github.com/PyTorchLightning/pytorch-lightning/blob/master/tests/models/test_restore.py
Additional context

  
    
      pytorch-lightning/tests/checkpointing/test_legacy_checkpoints.py
    
    
        Lines 49 to 72
      in
      1f6236a
    
  
  
    

        
          
           def test_resume_legacy_checkpoints(tmpdir, pl_version): 
        

        
          
               path_dir = os.path.join(LEGACY_CHECKPOINTS_PATH, pl_version) 
        

        
          
            
        

        
          
               # todo: make this as mock, so it is cleaner... 
        

        
          
               orig_sys_paths = list(sys.path) 
        

        
          
               sys.path.insert(0, path_dir) 
        

        
          
               from zero_training import DummyModel 
        

        
          
            
        

        
          
               path_ckpts = sorted(glob.glob(os.path.join(path_dir, f'*{CHECKPOINT_EXTENSION}'))) 
        

        
          
               assert path_ckpts, 'No checkpoints found in folder "%s"' % path_dir 
        

        
          
               path_ckpt = path_ckpts[-1] 
        

        
          
            
        

        
          
               model = DummyModel.load_from_checkpoint(path_ckpt) 
        

        
          
               trainer = Trainer(default_root_dir=tmpdir, max_epochs=6) 
        

        
          
               result = trainer.fit(model) 
        

        
          
               assert result 
        

        
          
            
        

        
          
               # todo 
        

        
          
               # model = DummyModel() 
        

        
          
               # trainer = Trainer(default_root_dir=tmpdir, max_epochs=1, resume_from_checkpoint=path_ckpt) 
        

        
          
               # result = trainer.fit(model) 
        

        
          
               # assert result 
        

        
          
            
        

        
          
               sys.path = orig_sys_paths 
        
    
  


cc: @Borda