-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[WIP] Add typing for pytorch_lightning.utilities
#7218
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
Conversation
* [WIP] Need to verify if logged metrics are of a type torch.Tensor or whether Any can be passed in
* Files: seed, upgrade_checkpoint, warnings * Fix typo in parsing
Hello @stancld! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-05-27 21:20:42 UTC |
Codecov Report
@@ Coverage Diff @@
## master #7218 +/- ##
========================================
- Coverage 92% 44% -48%
========================================
Files 199 199
Lines 12996 13014 +18
========================================
- Hits 12003 5726 -6277
- Misses 993 7288 +6295 |
pytorch_lightning.utilities
pytorch_lightning.utilities
hook=ddp_comm_hook, | ||
) | ||
# If condition required for mypy compatibility | ||
if ddp_comm_hook is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather allow passing None, or what happen if none is passed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this condition is dropped, the following mypy issue is raised:
utilities/distributed.py:320: error: Item "None" of "Optional[Callable[..., Any]]" has no attribute "__qualname__"
return collect_init_args(frame.f_back, path_args, inside=True) | ||
elif not inside: | ||
return collect_init_args(frame.f_back, path_args, inside) | ||
if isinstance(frame.f_back, FrameType): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mind comment on why this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping this condition leads to the following two issues:
utilities/parsing.py:174: error: Argument 1 to "collect_init_args" has incompatible type "Optional[FrameType]"; expected "FrameType"
utilities/parsing.py:176: error: Argument 1 to "collect_init_args" has incompatible type "Optional[FrameType]"; expected "FrameType"
Maybe, there's another nice workaround.
@Borda Hi, sorry for not responding. This PR looks now obsolete and pretty complicated to merge due to its large extent. Would you mind if I close this PR and maybe open some little PRs for individual files to finish this mypy task? |
If it's possible to break down in smaller pieces that would be awesome! very welcomed! |
What does this PR do?
Part of #7037
Before submitting
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:
Did you have fun?
Make sure you had fun coding 🙃