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

Disallow invalid seed string values #8787

Merged
merged 12 commits into from
Sep 23, 2021

Conversation

stancld
Copy link
Contributor

@stancld stancld commented Aug 7, 2021

What does this PR do?

See title.
Fixes mypy typing in utilities.seed.py

Part of #7037. This PR disentangles large #7218

Does your PR introduce any breaking changes? If yes, please list them.

Passing invalid seed values to seed_everything is now disallowed.

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • 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?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is welcome to review the PR.
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

Did you have fun?

Make sure you had fun coding 🙃

@codecov
Copy link

codecov bot commented Aug 7, 2021

Codecov Report

Merging #8787 (d7f616a) into master (530caef) will increase coverage by 1%.
The diff coverage is 100%.

❗ Current head d7f616a differs from pull request most recent head 0994577. Consider uploading reports for the commit 0994577 to get more accurate results

@@           Coverage Diff            @@
##           master   #8787     +/-   ##
========================================
+ Coverage      88%     89%     +1%     
========================================
  Files         178     179      +1     
  Lines       14889   19134   +4245     
========================================
+ Hits        13122   17120   +3998     
- Misses       1767    2014    +247     

@stancld stancld changed the title Fix mypy typing for utilities.seed Fix mypy typing for utilities.seed Aug 7, 2021
@stancld stancld changed the title Fix mypy typing for utilities.seed [WIP] Fix mypy typing for utilities.seed Aug 7, 2021
@stancld stancld changed the title [WIP] Fix mypy typing for utilities.seed Fix mypy typing for utilities.seed Aug 9, 2021
@stancld stancld marked this pull request as ready for review August 9, 2021 07:52
@awaelchli awaelchli added this to the v1.5 milestone Aug 9, 2021
@tchaton
Copy link
Contributor

tchaton commented Aug 31, 2021

Dear @stancld,

Any updates on this PR ?

Best,
T.C

@stancld
Copy link
Contributor Author

stancld commented Sep 1, 2021

Dear @tchaton: @awaelchli stressed the importance to keep the functionality the same. In this case, however, satisfying the requirements imposed by mypy leads to much more complex code. Since here, the possible type errors are handled by try - except statement, would it be possible just to ask mypy not to check the typing for the line stating seed = int(seed)?

@awaelchli
Copy link
Contributor

Yes I think we should favor reproducibility here and not the typing. Let's not change the implementation unless there is a bug. In this case ignoring a line there for mypy is well justified imo

@awaelchli awaelchli closed this Sep 1, 2021
@awaelchli awaelchli reopened this Sep 1, 2021
@tchaton
Copy link
Contributor

tchaton commented Sep 1, 2021

Dear @awaelchli @stancld,

First of all, thanks @stancld for investing time and effort on this PR. This is well appreciated !
What should we do ? Close this PR or add ignore flags for mypy there with a comment on why we made this decision ?

Best.
T.C

@stancld
Copy link
Contributor Author

stancld commented Sep 1, 2021

@tchaton If it's okay I would re-write this PR tomorrow and add two ignoring comments with a supplementary one why this solution is appropriate :)

@tchaton
Copy link
Contributor

tchaton commented Sep 2, 2021

Hey @stancld,

Thanks for helping out !

Best,
T.C

@mergify mergify bot added the has conflicts label Sep 6, 2021
@mergify mergify bot removed the has conflicts label Sep 9, 2021
pytorch_lightning/utilities/seed.py Outdated Show resolved Hide resolved
pytorch_lightning/utilities/seed.py Outdated Show resolved Hide resolved
@mergify mergify bot added the ready PRs ready to be merged label Sep 9, 2021
Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

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

LGTM !

@carmocca carmocca changed the title Fix mypy typing for utilities.seed Disallow invalid seed string values Sep 23, 2021
@carmocca carmocca enabled auto-merge (squash) September 23, 2021 14:43
@carmocca carmocca merged commit 568a1e0 into Lightning-AI:master Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready PRs ready to be merged refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants