From 61032e70e097aea63d191183466d0f1b16f9e16e Mon Sep 17 00:00:00 2001 From: abb128 <65567823+abb128@users.noreply.github.com> Date: Sat, 26 Nov 2022 04:10:37 +0200 Subject: [PATCH] Fix exception in find_checkpoints (#668) --- icefall/checkpoint.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/icefall/checkpoint.py b/icefall/checkpoint.py index 8aa0a8eeb..f0663a1df 100644 --- a/icefall/checkpoint.py +++ b/icefall/checkpoint.py @@ -292,7 +292,15 @@ def find_checkpoints(out_dir: Path, iteration: int = 0) -> List[str]: """ checkpoints = list(glob.glob(f"{out_dir}/checkpoint-[0-9]*.pt")) pattern = re.compile(r"checkpoint-([0-9]+).pt") - iter_checkpoints = [(int(pattern.search(c).group(1)), c) for c in checkpoints] + iter_checkpoints = [] + for c in checkpoints: + result = pattern.search(c) + if not result: + logging.warn(f"Invalid checkpoint filename {c}") + continue + + iter_checkpoints.append((int(result.group(1)), c)) + # iter_checkpoints is a list of tuples. Each tuple contains # two elements: (iteration_number, checkpoint-iteration_number.pt)