pytorch-lightning
pytorch-lightning copied to clipboard
Fix mypy errors attributed to `pytorch_lightning.core.datamodule`
What does this PR do?
Fix mypy errors attributed to pytorch_lightning.core.datamodule
for issue #13445
Does your PR introduce any breaking changes? If yes, please list them.
Before submitting
- [x] Was this discussed/approved via a GitHub issue? (not for typos and docs)
- [x] Did you read the contributor guideline, Pull Request section?
- [x] Did you make sure your PR does only one thing, instead of bundling different changes together?
- [x] Did you make sure to update the documentation with your changes? (if necessary)
- [x] Did you write any new necessary tests? (not for typos and docs)
- [x] Did you verify new and existing tests pass locally with your changes?
- [x] Did you list all the breaking changes introduced by this pull request?
- [x] Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)
PR review
Anyone in the community is welcome to review the PR. Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:
- [x] Is this pull request ready for review? (if not, please submit in draft mode)
- [x] Check that all items from Before submitting are resolved
- [x] Make sure the title is self-explanatory and the description concisely explains the PR
- [x] Add labels and milestones (and optionally projects) to the PR so it can be classified
blocked by core.saving
of #13445
I had originally marked this blocked by another contributor's anticipated PR; however, that contributor has not opened a PR after 2 weeks https://github.com/Lightning-AI/lightning/issues/13445#issuecomment-1185436344
Codecov Report
Merging #13693 (402d025) into master (0ca3b5a) will decrease coverage by
10%
. The diff coverage is96%
.
:exclamation: Current head 402d025 differs from pull request most recent head e7cef8a. Consider uploading reports for the commit e7cef8a to get more accurate results
@@ Coverage Diff @@
## master #13693 +/- ##
=========================================
- Coverage 86% 76% -10%
=========================================
Files 330 330
Lines 26782 26798 +16
=========================================
- Hits 23001 20390 -2611
- Misses 3781 6408 +2627
@otaj @carmocca @Borda @rohitgr7
The new, suggested class methods in LightningDataModule are to reconcile errors raised by mypy; however, these errors originate from pl.utilities.argparse.
While troubleshooting the mypy error:
src/pytorch_lightning/utilities/argparse.py:65: error: Item "LightningDataModule" of "Union[ParseArgparserDataType, LightningDataModule]" has no attribute "parse_argparser" [union-attr]
It was found that in pl.utilities.argparse, there appears to be an unused base class (ParseArgparserDataType) that was perhaps intended to act as a mixin/utility interface for LightningDataModule and Trainer. This base class originated in https://github.com/Lightning-AI/lightning/pull/8124, as pointed out by Ota in a Slack conversation.
Should I integrate ParseArgparserDataType in this PR – refactoring both LightningDataModule and Trainer appropriately to inherit from the base class; or should I open a new PR to handle this task?
If this PR should not integrate ParseArgparserDataType, then it is ready for review; otherwise, it should be converted to a draft.
all level 0 functions in pl.utilities.argparse appear as if each should be refactored as either a class or static method of ParseArgparserDataType
@rohitgr7 what was the intended effect of setting strict to None? strict needs to be a bool, so I am wondering if this needs to be False or left as none and ignore the mypy error https://github.com/Lightning-AI/lightning/blob/d29a552b3c701ebc14d608347c1dbf55c3dfaa6a/src/pytorch_lightning/core/datamodule.py#L245
_load_from_checkpoint
was updated in the PR for core.saving yesterday.
@awaelchli this will likely affect your update to core.saving as well
@JustinGoheen added a commit to resolve the issue
apologies, I'm no longer able to keep this PR up to date.