-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix typing in pl/tuner/tuning.py #13616
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 typing in pl/tuner/tuning.py #13616
Conversation
* Refactor docker builds in CI * Reduce duplicate and merge two workflows * push: bool expression * Extend timeout for ipu builds * Update concurrency group * Define env for push to hub * Rename workflow * Fix bool expressions * Remove unnecessary trigger paths * Remove unused env var * Update job names * Trim timeout * rename Co-authored-by: Jirka <[email protected]>
| early_stop_threshold: float = 4.0, | ||
| update_attr: bool = False, | ||
| ) -> Optional[_LRFinder]: | ||
| ) -> Optional[Union[int, _LRFinder]]: |
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.
this was correct no?
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.
Well, the tune is expected to return Optional[Union[int, _LRFinder]].
mypy detects this and returns an assignment error.
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.
yes, but lr_find returns result['lr_find'].
| max_trials: int = 25, | ||
| batch_arg_name: str = "batch_size", | ||
| ) -> Optional[int]: | ||
| ) -> Optional[Union[int, _LRFinder]]: |
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.
same here
| lr_find_kwargs = lr_find_kwargs or {} | ||
| # return a dict instead of a tuple so BC is not broken if a new tuning procedure is added | ||
| result = {} | ||
| result: Dict[str, Any] = {} |
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.
| result: Dict[str, Any] = {} | |
| result: Dict[str, Union[int, _LRFinder]] = {} |
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.
Thanks! I think the Union has to be optional otherwise mypy will throw an error: Incompatible types in assignment (expression has type "Optional[int]", target has type "Union[int, _LRFinder]").
`
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.
| result: Dict[str, Any] = {} | |
| result: Dict[str, Optional[Union[int, _LRFinder]]] = {} |
…#13538) Co-authored-by: Akihiro Nitta <[email protected]>
…3494) Co-authored-by: Rohit Gupta <[email protected]> Co-authored-by: Carlos Mocholí <[email protected]>
* Enable dependabot on GHA * Update comment * Update PR limit Co-authored-by: Jirka Borovec <[email protected]>
Update labeler
Remove redundant test
* CI: hotfix gatekeeper * no min * min 1
…13600) Co-authored-by: Carlos Mocholí <[email protected]>
carmocca
left a comment
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.
I would explore using a TypedDict instead:
from typing_extensions import TypedDict
class _TunerResult(TypedDict):
lr_find: Optional[_LRFinder]
scale_batch_size: Optional[int]Which should clarify the ambiguity and improve the type checks
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](actions/upload-artifact@v2...v3) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 1 to 2. - [Release notes](https://github.com/docker/setup-buildx-action/releases) - [Commits](docker/setup-buildx-action@v1...v2) --- updated-dependencies: - dependency-name: docker/setup-buildx-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…hSamplerWrapper.batch_indices` (#13565) * Removed the deprecated method * Removed deprecated IndexBatchSamplerWrapper.batch_indices * Update src/pytorch_lightning/CHANGELOG.md * Missed code Co-authored-by: Akihiro Nitta <[email protected]> Co-authored-by: Carlos Mocholí <[email protected]>
for more information, see https://pre-commit.ci
|
Thanks. I'll close this PR and incorporate the suggestions in the next one. |
What does this PR do?
Fixes typing errors in pytorch_lightning/tuner/lr_finder.py in #13445.
Does your PR introduce any breaking changes? If yes, please list them.
None
Before submitting
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:
Did you have fun?
Make sure you had fun coding 🙃