Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions fms_fsdp/utils/checkpointing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ def get_latest(targdir, qualifier=lambda x: True):
If directory is empty or nonexistent or no items qualify, return None."""
if os.path.exists(targdir) and len(os.listdir(targdir)) > 0:
latest = max(
[
os.path.join(targdir, x)
for x in os.listdir(targdir)
if qualifier(os.path.join(targdir, x))
],
key=lambda path: int(path.split("/")[-1].split("_")[1]),
[x for x in os.listdir(targdir) if qualifier(os.path.join(targdir, x))],
key=lambda path: int(path.split("_")[1]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably the same issue below with get_oldest ?

maybe we could add a unit test?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, removed os.path.join in the get_oldest function in commit 4a2b4b8, and added unit tests in commit f082164.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks better, though now the ctime key fails in get_oldest

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, have pushed a fix, can you run the tests again to see if it works?

)
return os.path.join(targdir, latest)
return None
Expand Down