-
Notifications
You must be signed in to change notification settings - Fork 3.6k
refactor imports of optional dependencies #4859
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
|
@awaelchli any idea how it is possible that the package is found so |
|
@awaelchli it seems that the conditional import does not work, it is imported even inside the if statement... :/ |
|
@Borda Seems import importlib
def _module_available(module_path: str) -> bool:
"""Testing if given module is avalaible in your env
>>> _module_available('system')
True
>>> _module_available('bla.bla')
False
"""
mods = module_path.split('.')
assert mods, 'nothing given to test'
# it has to be tested as per partets
for i in range(1, len(mods)):
module_path = '.'.join(mods[:i])
if importlib.util.find_spec(module_path) is None:
return False
return True
print(_module_available("asdf"))
print(_module_available("asdf.asdf"))and encountered the following unexpected behaviour... True
False |
|
@tgaddair mind have a look at why the Horovod tests are failing? |
|
after merging all the partial PRs this remain only for Horovod |
bf5cb91 to
6dfe510
Compare
ae0c9c2 to
ff9e7cd
Compare
Codecov Report
@@ Coverage Diff @@
## master #4859 +/- ##
======================================
- Coverage 93% 93% -0%
======================================
Files 124 124
Lines 9302 9295 -7
======================================
- Hits 8615 8608 -7
Misses 687 687 |
16b7e22 to
66aaf34
Compare
66aaf34 to
3f00512
Compare
|
the TPU and GPU #4884 failing is unrelated to this PR cc: @zcain117 |
tchaton
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.
LTGM !
What does this PR do?
drop tricky try/catch. form optional imports, @awaelchli
resolves #2266
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 🙃