Skip to content

Commit e7b8300

Browse files
IvyZXFlax Authors
authored andcommitted
Allow the checkpoint directory to be nonexistent before saving.
PiperOrigin-RevId: 515453724
1 parent 8d95e22 commit e7b8300

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

flax/training/checkpoints.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,9 @@ def _remove_invalid_ckpts(ckpt_path: str, base_path: str, keep: int,
336336
"""Clean up the checkpoint space according to `overwrite`, `keep`, and `keep_every_n_steps` parameters.
337337
"""
338338
dir_path, prefix = os.path.split(base_path)
339-
checkpoint_files: List[Any] = [pathlib.PurePath(c) for c in io.listdir(dir_path)]
339+
checkpoint_files: List[Any] = [
340+
pathlib.PurePath(c) for c in _allowempty_listdir(dir_path)
341+
]
340342
checkpoint_files = [
341343
os.path.join(dir_path, c)
342344
for c in checkpoint_files

0 commit comments

Comments
 (0)