From 03872b823fd473f3ba066975f5fe965ab56da189 Mon Sep 17 00:00:00 2001 From: mrq Date: Thu, 17 Aug 2023 00:11:29 -0500 Subject: [PATCH] why did I type rglob, another 10 bucks down the drain... --- vall_e/engines/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vall_e/engines/base.py b/vall_e/engines/base.py index abff0d1..048cc7d 100755 --- a/vall_e/engines/base.py +++ b/vall_e/engines/base.py @@ -223,10 +223,13 @@ class Engines(dict[str, Engine]): # might be better to prune before saving for safety, but [:0] returns an empty list, but I could do [:-cfg.trainer.keep_last_checkpoints - 1 if cfg.trainer.keep_last_checkpoints > 1 else None] if cfg.trainer.keep_last_checkpoints > 0 and is_global_leader(): - checkpoints = list(save_dir.rglob("*/")) + checkpoints = [ d for d in list(save_dir.glob("*")) if d.is_dir() ] checkpoints.sort(key=lambda x: x.stat().st_mtime) checkpoints = checkpoints[:-cfg.trainer.keep_last_checkpoints] for d in checkpoints: + if not d.is_dir() or not d.exists(): + continue + print("Removing", d) for p in d.iterdir(): p.unlink() d.rmdir()