Refactor pl_bolts/datamodules
#337
Labels
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
let's do it!
Looking forward to have it implemented
refactoring
Milestone
🚀 Refactoring
Currently, there are
try: ... except: ...
inpl_bolts/datamodules/__init__.py
which were added in #303, and it is not clean in my humble opinion.In order to make
__init__.py
clean and keep the behaviour, the following steps are needed:try: ... except: ...
in__init__.py
.torchvision
,sklearn
,gym
...) inpl_bolts/datamodules/*.py
withimportlib.util.find_spec("some_package") is not None
in order not to raiseModuleNotFoundError
withfrom pl_bolts.datamodules import ...
The way of importing optional packages was suggested by @awaelchli in Raise ModuleNotFoundError when unavailable #290 (comment)Additional context
These
try: ... except: ...
were added in #303 to fix the import problem in #291 wherefrom pl_bolts.datamodules import MNISTDataModule
raisesModuleNotFoundError
even if the requirements forMNISTDataModule
were met.I would be happy to submit a PR if it sounds reasonable to you!
The text was updated successfully, but these errors were encountered: