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

Fix saved filename in ModelCheckpoint if it already exists #4861

Merged
merged 17 commits into from
Dec 16, 2020

Conversation

rohitgr7
Copy link
Contributor

@rohitgr7 rohitgr7 commented Nov 25, 2020

What does this PR do?

Fixes the saved filename if it's already present. It will override the file if it's already going to be deleted. Previously if save_top_k=1 and filename is static for eg: some_file, it will create a file with the version for eg: filename=some_file-v2.ckpt if max_epoch > 1 but it should be some_file.ckpt only.

The test fails on master.

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together? Otherwise, we ask you to create a separate PR for every change.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified; Bugfixes should be including in bug-fix release milestones (m.f.X) and features should be included in (m.X.b) releases.

Did you have fun?

Make sure you had fun coding 🙃

@pep8speaks
Copy link

pep8speaks commented Nov 25, 2020

Hello @rohitgr7! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-12-14 17:27:54 UTC

@rohitgr7 rohitgr7 changed the title Bugfix/ckpt fname Bugfix/ckpt fname [ci skip] Nov 25, 2020
@codecov
Copy link

codecov bot commented Nov 25, 2020

Codecov Report

Merging #4861 (dfd47dc) into master (fde972f) will decrease coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #4861   +/-   ##
======================================
- Coverage      93%     93%   -0%     
======================================
  Files         134     134           
  Lines        9907    9905    -2     
======================================
- Hits         9206    9204    -2     
  Misses        701     701           

@rohitgr7 rohitgr7 changed the title Bugfix/ckpt fname [ci skip] Fix saved filename in ModelCheckpoint if it's already present Nov 26, 2020
@rohitgr7 rohitgr7 changed the title Fix saved filename in ModelCheckpoint if it's already present Fix saved filename in ModelCheckpoint if it already exists Nov 26, 2020
@rohitgr7 rohitgr7 added bug Something isn't working checkpointing Related to checkpointing labels Nov 26, 2020
@rohitgr7 rohitgr7 added this to the 1.0.x milestone Nov 26, 2020
@rohitgr7 rohitgr7 marked this pull request as ready for review November 26, 2020 18:32
@rohitgr7
Copy link
Contributor Author

Thanks @carmocca for the review :)

@carmocca
Copy link
Contributor

Unrelated to the PR but, is there a reason for version starting at 0?

file.ckpt  # I find this confusing, kind of implies this is -v-1
file-v0.ckpt
file-v1.ckpt
...

instead of:

file.ckpt
file-v1.ckpt
file-v2.ckpt
...

@Borda Borda modified the milestones: 1.0.x, 1.1 Nov 26, 2020
@Borda
Copy link
Member

Borda commented Nov 26, 2020

Unrelated to the PR but, is there a reason for version starting at 0?

there is no special reason :]
cc: @PyTorchLightning/core-contributors

@rohitgr7
Copy link
Contributor Author

rohitgr7 commented Dec 2, 2020

@carmocca wanna give this a shot? #4861 (comment)

@carmocca
Copy link
Contributor

carmocca commented Dec 2, 2020

@carmocca wanna give this a shot? #4861 (comment)

Sure, I will. Most likely this weekend

@rohitgr7 rohitgr7 changed the title Fix saved filename in ModelCheckpoint if it already exists [wip] Fix saved filename in ModelCheckpoint if it already exists Dec 2, 2020
@rohitgr7 rohitgr7 requested a review from Borda December 3, 2020 18:00
@rohitgr7 rohitgr7 requested review from carmocca and removed request for carmocca December 11, 2020 20:34
@mergify mergify bot requested a review from a team December 12, 2020 14:58
@rohitgr7 rohitgr7 added the ready PRs ready to be merged label Dec 14, 2020
@rohitgr7 rohitgr7 merged commit 79565be into master Dec 16, 2020
@rohitgr7 rohitgr7 deleted the bugfix/ckpt_fname branch December 16, 2020 05:40
awaelchli pushed a commit that referenced this pull request Dec 18, 2020
* disable version if not required

* disable version if not required

* pep

* chlog

* improve test

* improve test

* parametrize test and update del_list

* Update pytorch_lightning/callbacks/model_checkpoint.py

Co-authored-by: Carlos Mocholí <[email protected]>

* try appending version to already saved ckpt_file

* Revert "try appending version to already saved ckpt_file"

This reverts commit 710e05e.

* add more assertions

* use BoringModel

Co-authored-by: Carlos Mocholí <[email protected]>
Co-authored-by: chaton <[email protected]>
Co-authored-by: Roger Shieh <[email protected]>
Borda pushed a commit that referenced this pull request Dec 23, 2020
* disable version if not required

* disable version if not required

* pep

* chlog

* improve test

* improve test

* parametrize test and update del_list

* Update pytorch_lightning/callbacks/model_checkpoint.py

Co-authored-by: Carlos Mocholí <[email protected]>

* try appending version to already saved ckpt_file

* Revert "try appending version to already saved ckpt_file"

This reverts commit 710e05e.

* add more assertions

* use BoringModel

Co-authored-by: Carlos Mocholí <[email protected]>
Co-authored-by: chaton <[email protected]>
Co-authored-by: Roger Shieh <[email protected]>
Borda pushed a commit that referenced this pull request Dec 29, 2020
* disable version if not required

* disable version if not required

* pep

* chlog

* improve test

* improve test

* parametrize test and update del_list

* Update pytorch_lightning/callbacks/model_checkpoint.py

Co-authored-by: Carlos Mocholí <[email protected]>

* try appending version to already saved ckpt_file

* Revert "try appending version to already saved ckpt_file"

This reverts commit 710e05e.

* add more assertions

* use BoringModel

Co-authored-by: Carlos Mocholí <[email protected]>
Co-authored-by: chaton <[email protected]>
Co-authored-by: Roger Shieh <[email protected]>
Borda pushed a commit that referenced this pull request Jan 4, 2021
* disable version if not required

* disable version if not required

* pep

* chlog

* improve test

* improve test

* parametrize test and update del_list

* Update pytorch_lightning/callbacks/model_checkpoint.py

Co-authored-by: Carlos Mocholí <[email protected]>

* try appending version to already saved ckpt_file

* Revert "try appending version to already saved ckpt_file"

This reverts commit 710e05e.

* add more assertions

* use BoringModel

Co-authored-by: Carlos Mocholí <[email protected]>
Co-authored-by: chaton <[email protected]>
Co-authored-by: Roger Shieh <[email protected]>
Borda pushed a commit that referenced this pull request Jan 4, 2021
* disable version if not required

* disable version if not required

* pep

* chlog

* improve test

* improve test

* parametrize test and update del_list

* Update pytorch_lightning/callbacks/model_checkpoint.py

Co-authored-by: Carlos Mocholí <[email protected]>

* try appending version to already saved ckpt_file

* Revert "try appending version to already saved ckpt_file"

This reverts commit 710e05e.

* add more assertions

* use BoringModel

Co-authored-by: Carlos Mocholí <[email protected]>
Co-authored-by: chaton <[email protected]>
Co-authored-by: Roger Shieh <[email protected]>
Borda pushed a commit that referenced this pull request Jan 5, 2021
* disable version if not required

* disable version if not required

* pep

* chlog

* improve test

* improve test

* parametrize test and update del_list

* Update pytorch_lightning/callbacks/model_checkpoint.py

Co-authored-by: Carlos Mocholí <[email protected]>

* try appending version to already saved ckpt_file

* Revert "try appending version to already saved ckpt_file"

This reverts commit 710e05e.

* add more assertions

* use BoringModel

Co-authored-by: Carlos Mocholí <[email protected]>
Co-authored-by: chaton <[email protected]>
Co-authored-by: Roger Shieh <[email protected]>
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 design Includes a design discussion ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants