Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

raise clear error for module not available #1425

Merged
merged 8 commits into from
Aug 30, 2022

Conversation

aniketmaurya
Copy link
Contributor

@aniketmaurya aniketmaurya commented Aug 22, 2022

What does this PR do?

Fixes #1422 #1423. This PR:

  • Adds @requires("kornia") decorator to image segmentation input transform code for better coverage and clearer error.
  • Since Audio Classification uses torchvision, a requires decorator for torchvision is also added in the relevant file.

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • 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?
  • Did you write any new necessary tests? [not needed for typos/docs]
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

  • Is this pull request ready for review? (if not, please submit in draft mode)

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@codecov
Copy link

codecov bot commented Aug 22, 2022

Codecov Report

Merging #1425 (c054bf0) into master (c892d69) will decrease coverage by 7.77%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1425      +/-   ##
==========================================
- Coverage   92.89%   85.12%   -7.78%     
==========================================
  Files         286      286              
  Lines       12870    12874       +4     
==========================================
- Hits        11956    10959     -997     
- Misses        914     1915    +1001     
Flag Coverage Δ
unittests 85.12% <100.00%> (-7.78%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
flash/audio/classification/input_transform.py 92.59% <100.00%> (+0.28%) ⬆️
flash/core/utilities/imports.py 91.42% <100.00%> (ø)
flash/image/segmentation/input_transform.py 94.59% <100.00%> (+0.47%) ⬆️
...lash/image/embedding/vissl/transforms/utilities.py 15.15% <0.00%> (-84.85%) ⬇️
flash/image/embedding/heads/vissl_heads.py 35.29% <0.00%> (-64.71%) ⬇️
flash/image/embedding/losses/vissl_losses.py 37.50% <0.00%> (-62.50%) ⬇️
flash/image/embedding/vissl/adapter.py 31.63% <0.00%> (-62.25%) ⬇️
flash/image/detection/input.py 38.88% <0.00%> (-61.12%) ⬇️
...age/face_detection/backbones/fastface_backbones.py 42.10% <0.00%> (-57.90%) ⬇️
flash/image/face_detection/model.py 36.84% <0.00%> (-55.27%) ⬇️
... and 57 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@krshrimali krshrimali left a comment

Choose a reason for hiding this comment

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

Thank you, @aniketmaurya for this PR! LGTM 🔥 A suggestion and a question:

  1. Let's also add torchvision requirement to datatype_audio.txt file, since we need it for audio classification. Can you please do this in this PR?
  2. Question: just cross-checking, did you make sure that a clearer error is raised if kornia is not installed and a user attempts to run this example?

Also, I've modified the PR description for future reference, just in case anyone hops on this for any reason! :) Hope that sounds good to you.

@aniketmaurya
Copy link
Contributor Author

aniketmaurya commented Aug 22, 2022

Thank you for reviewing the PR and suggestions @krshrimali 😄 !
I have added torchvision to audio requirements and also cross-checked the error message when Kornia is not uninstalled. The error message clearly states that Konia is not installed 👇🏻

ModuleNotFoundError: Required dependencies not available. Please run: pip install 'kornia'

@krshrimali
Copy link
Contributor

@aniketmaurya - Sounds great, thank you so much! However, I can't see any commit after your comment. Did you forget to push the changes for requirements? ;)

@aniketmaurya
Copy link
Contributor Author

Hi @krshrimali, yeah sorry I forgot to push it earlier. I've updated the PR just now! 😅

@krshrimali
Copy link
Contributor

Update: added CHANGELOG entries! cc: @ethanwharris - if you can merge this whenever you are back! :)

@mergify mergify bot removed the has conflicts label Aug 29, 2022
Copy link
Collaborator

@ethanwharris ethanwharris left a comment

Choose a reason for hiding this comment

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

LGTM, just small suggestions to require lightning-flash[image] or lightning-flash[audio] rather than the libraries themselves

flash/audio/classification/input_transform.py Outdated Show resolved Hide resolved
flash/image/segmentation/input_transform.py Outdated Show resolved Hide resolved
flash/image/segmentation/input_transform.py Outdated Show resolved Hide resolved
flash/image/segmentation/input_transform.py Outdated Show resolved Hide resolved
@ethanwharris ethanwharris self-assigned this Aug 30, 2022
@ethanwharris ethanwharris merged commit 1af048f into Lightning-Universe:master Aug 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Raise clearer error when module not available
3 participants