Skip to content
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

Refactor pl_bolts/datamodules #337

Closed
akihironitta opened this issue Nov 5, 2020 · 2 comments · Fixed by #338
Closed

Refactor pl_bolts/datamodules #337

akihironitta opened this issue Nov 5, 2020 · 2 comments · Fixed by #338
Assignees
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

Comments

@akihironitta
Copy link
Contributor

🚀 Refactoring

Currently, there are try: ... except: ... in pl_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:

  1. Remove try: ... except: ... in __init__.py.
  2. Rewrite optional imports (torchvision, sklearn, gym...) in pl_bolts/datamodules/*.py with importlib.util.find_spec("some_package") is not None in order not to raise ModuleNotFoundError with from 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 where from pl_bolts.datamodules import MNISTDataModule raises ModuleNotFoundError even if the requirements for MNISTDataModule were met.

I would be happy to submit a PR if it sounds reasonable to you!

@akihironitta akihironitta added enhancement New feature or request help wanted Extra attention is needed labels Nov 5, 2020
@ananyahjha93
Copy link
Contributor

@akihironitta I think this would be a good enhancement. Go for it, send in the PR.

@Borda Borda added good first issue Good for newcomers let's do it! Looking forward to have it implemented refactoring labels Nov 5, 2020
@Borda
Copy link
Member

Borda commented Nov 5, 2020

cc: @awaelchli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants