Skip to content

Commit 3d2364c

Browse files
authored
Fix bug with repeated checkpoint path
Code was calling `os.path.join()` too many times and causing the path to be repeated unnecessarily.
1 parent 948cb2a commit 3d2364c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

fms_fsdp/utils/checkpointing_utils.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@ def get_latest(targdir, qualifier=lambda x: True):
2525
If directory is empty or nonexistent or no items qualify, return None."""
2626
if os.path.exists(targdir) and len(os.listdir(targdir)) > 0:
2727
latest = max(
28-
[
29-
os.path.join(targdir, x)
30-
for x in os.listdir(targdir)
31-
if qualifier(os.path.join(targdir, x))
32-
],
33-
key=lambda path: int(path.split("/")[-1].split("_")[1]),
28+
[x for x in os.listdir(targdir) if qualifier(os.path.join(targdir, x))],
29+
key=lambda path: int(path.split("_")[1]),
3430
)
3531
return os.path.join(targdir, latest)
3632
return None

0 commit comments

Comments
 (0)