Commit fef4e002 authored by Jose Fonollosa's avatar Jose Fonollosa Committed by Facebook Github Bot
Browse files

Add missing parentheses in regex expression (#567)

Summary:
The regex pattern without parentheses is not correct. The checkpoints are not sorted in descending order
Pull Request resolved: https://github.com/pytorch/fairseq/pull/567

Differential Revision: D14404380

Pulled By: myleott

fbshipit-source-id: 98cd0cfa8c92b78a03ffbb94840bc0f7a118eca1
parent 5869385c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -325,7 +325,7 @@ def save_checkpoint(args, trainer, epoch_itr, val_loss):

    if args.keep_last_epochs > 0:
        # remove old epoch checkpoints; checkpoints are sorted in descending order
        checkpoints = utils.checkpoint_paths(args.save_dir, pattern=r'checkpoint\d+\.pt')
        checkpoints = utils.checkpoint_paths(args.save_dir, pattern=r'checkpoint(\d+)\.pt')
        for old_chk in checkpoints[args.keep_last_epochs:]:
            if os.path.lexists(old_chk):
                os.remove(old_chk)