Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModelCheckpoint does not create full path #3001

Closed
ydcjeff opened this issue Aug 16, 2020 · 11 comments
Closed

ModelCheckpoint does not create full path #3001

ydcjeff opened this issue Aug 16, 2020 · 11 comments
Assignees
Labels
bug Something isn't working checkpointing Related to checkpointing help wanted Open to be worked on priority: 0 High priority task
Milestone

Comments

@ydcjeff
Copy link
Contributor

ydcjeff commented Aug 16, 2020

🐛 Bug

To Reproduce

Run checkpoint_callback = ModelCheckpoint('my/path/')
Only my folder is created.

I think this line discard the last trailing slash. So the directories are not created as intended when the paths are getting split.

Expected behavior

Path should be fully created.

@ydcjeff ydcjeff added bug Something isn't working help wanted Open to be worked on labels Aug 16, 2020
@awaelchli
Copy link
Contributor

awaelchli commented Aug 16, 2020

I do not think that the trailing slash is the root problem. We also want that "my/path" should be interpreted as a path to a folder.
I think a reasonable fix is to force the user to provide the extension when they want a file. This way, we can easily differentiate between folders and files.

@rohitgr7
Copy link
Contributor

rohitgr7 commented Aug 16, 2020

how about having two parameters, dirpath and filename? dirpath should be required (or maybe default to '.') and filename can be optional?

@awaelchli
Copy link
Contributor

I don't think we can make it required, because we have default_root_dir in Trainer, which should work as expected.

@ydcjeff
Copy link
Contributor Author

ydcjeff commented Aug 16, 2020

@awaelchli I mean trailing slash isn't the problem, discarding the last trailing slash is the problem.

@rohitgr7
Copy link
Contributor

yeah it can be optional, no problem

@rohitgr7
Copy link
Contributor

but @ydcjeff it should work with both 'my/path/' and 'my/path'.

@awaelchli
Copy link
Contributor

awaelchli commented Aug 16, 2020

I think what jeff wants to say is that

path, filename = os.path.split("a/b/c")

vs.

path, filename = os.path.split("a/b/c/")

in the former, filename = "c", and in the latter filename = ""

@ydcjeff
Copy link
Contributor Author

ydcjeff commented Aug 16, 2020

yes, it's that.
When we give filepath=mnist/ckpt/ or filepath=mnist/ckpt, os.path.realpath() outputs mnist/ckpt
and when we do splitting, it becomes like path=mnist and filename=ckpt

@rohitgr7
Copy link
Contributor

rohitgr7 commented Aug 16, 2020

I think separate parameters dirpath and filename would be more flexible for the user. Not sure if it will break any backward compatibility with other parameters from Trainer or logger.

@edenlightning edenlightning added this to the 0.9.x milestone Sep 1, 2020
@Borda Borda added the checkpointing Related to checkpointing label Sep 4, 2020
@edenlightning edenlightning added the priority: 0 High priority task label Sep 16, 2020
@edenlightning
Copy link
Contributor

Anyone can send a PR?

@rohitgr7
Copy link
Contributor

let's discuss it on #3583. The approach suggested there will solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working checkpointing Related to checkpointing help wanted Open to be worked on priority: 0 High priority task
Projects
None yet
Development

No branches or pull requests

5 participants