Skip to content

Conversation

@himkt
Copy link
Contributor

@himkt himkt commented Jul 6, 2022

What does this PR do?

Part of #13445. Fixing mypy complaints in training_epoch_loop.py.

Before

> mypy --install-types --non-interactive --config-file ../pyproject.toml
pytorch_lightning/loops/epoch/training_epoch_loop.py:294: error: Incompatible types in assignment (expression has type "Optional[Any]", variable has type "Dict[str, Any]")  [assignment]
pytorch_lightning/loops/epoch/training_epoch_loop.py:338: error: Incompatible return value type (got "List[<nothing>]", expected "Union[List[List[Dict[str, Any]]], List[Dict[str, Any]]]")  [return-value]
pytorch_lightning/loops/epoch/training_epoch_loop.py:380: error: Incompatible return value type (got "List[<nothing>]", expected "Union[List[List[List[Dict[str, Any]]]], List[List[Dict[str, Any]]], List[Dict[str, Any]]]")  [return-value]
pytorch_lightning/loops/epoch/training_epoch_loop.py:464: error: Argument 1 to "_get_monitor_value" of "TrainingEpochLoop" has incompatible type "Optional[str]"; expected "str"  [arg-type]
pytorch_lightning/loops/epoch/training_epoch_loop.py:496: error: Function is missing a return type annotation  [no-untyped-def]
pytorch_lightning/loops/epoch/training_epoch_loop.py:538: error: Incompatible types in assignment (expression has type "None", variable has type "Dict[str, Any]")  [assignment]
pytorch_lightning/loops/epoch/training_epoch_loop.py:576: error: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader  [misc]
pytorch_lightning/loops/epoch/training_epoch_loop.py:594: error: Function "numpy.core.multiarray.array" is not valid as a type  [valid-type]
pytorch_lightning/loops/epoch/training_epoch_loop.py:594: note: Perhaps you need "Callable[...]" or a callback protocol?
pytorch_lightning/loops/epoch/training_epoch_loop.py:625: error: Need type annotation for "dimensions"  [var-annotated]
Found 9 errors in 1 file (checked 236 source files)

After

> mypy --install-types --non-interactive --config-file ../pyproject.toml
Success: no issues found in 236 source files

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

  • c44b2c1 Raise RuntimeError if users attempt to use ReduceLROnPlateau without monitor
    • I think this changes the behavior where users attempt a wrong configuration for ReduceLROnPlateau

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 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:

  • 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?

Enjoying mypy puzzle 🤗

@himkt
Copy link
Contributor Author

himkt commented Jul 6, 2022

Single card HPU test failed with the message "ModuleNotFoundError: No module named 'pytorch_lightning'", but I don't understand what's wrong in my PR...

https://dev.azure.com/Lightning-AI/lightning/_build/results?buildId=78310&view=logs&j=8a08b103-7f3c-5f4b-1889-6a795acbb007&t=5236135a-7c43-5800-935b-e902d7c2c9ea

@akihironitta akihironitta added loops Related to the Loop API code quality community This PR is from the community labels Jul 8, 2022
@akihironitta akihironitta added this to the pl:1.7 milestone Jul 8, 2022
@otaj otaj mentioned this pull request Jul 8, 2022
52 tasks
@himkt
Copy link
Contributor Author

himkt commented Jul 9, 2022

https://github.com/Lightning-AI/lightning/runs/7235310789?check_suite_focus=true#step:18:727

It doesn't reproduce on my local environment... 😢

@mergify mergify bot removed the has conflicts label Jul 12, 2022
Copy link
Contributor

@carmocca carmocca left a comment

Choose a reason for hiding this comment

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

LGTM after comments addressed

@mergify mergify bot added ready PRs ready to be merged has conflicts and removed ready PRs ready to be merged labels Jul 13, 2022
@mergify mergify bot added ready PRs ready to be merged and removed has conflicts ready PRs ready to be merged labels Jul 14, 2022
@himkt
Copy link
Contributor Author

himkt commented Jul 14, 2022

Thank you so much for all reviewers! I just revised the PR again, PTAL. cc. @carmocca

@awaelchli awaelchli enabled auto-merge (squash) July 15, 2022 09:48
@awaelchli awaelchli merged commit e4c7c5f into Lightning-AI:master Jul 15, 2022
@himkt himkt deleted the mypy-training_epoch_loop branch July 15, 2022 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code quality community This PR is from the community loops Related to the Loop API ready PRs ready to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants