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

Fix Driver imports #74

Merged
merged 3 commits into from
Dec 19, 2022
Merged

Fix Driver imports #74

merged 3 commits into from
Dec 19, 2022

Conversation

axkoenig
Copy link
Contributor

Description

  • this fixes an issue where all dependencies (torchvision, hub, huggingface, deeplake) needed to be installed for squirrel datasets core to work. Even if I import from squirrel_datasets_core.driver.huggingface import HuggingfaceDriver the squirrel_datasets_core.driver is called, an since we have all the imports in there we also needed our users to install all of those dependencies, which is not good - because they might not even need them.
  • solution is to delete content in squirrel_datasets_core.driver module and ask users to directly import the respective driver from the respective submodule
  • I also added registration of the deeplake driver which I missed in the last PR - could you please double check that
  • I suggest a version bump to 0.2.0, because this might be a breaking change for some users (imports might not work for some users anymore).

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring including code style reformatting
  • Other (please describe):

@@ -70,10 +79,7 @@ def squirrel_sources() -> List[Tuple[CatalogKey, Source]]:
import squirrel_datasets_core.datasets as ds

for m in pkgutil.iter_modules(ds.__path__):
try:
with contextlib.suppress(AttributeError):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

my IDE suggested this change, I think it's much cleaner that way. https://docs.python.org/3/library/contextlib.html

Copy link
Contributor

Choose a reason for hiding this comment

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

agreed

Copy link
Contributor

@winfried-ripken winfried-ripken left a comment

Choose a reason for hiding this comment

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

Just one comment about squirrel_plugin.py otherwise LG

@@ -36,6 +44,7 @@ def squirrel_drivers() -> List[Type[Driver]]:
drivers = []
add_drivers = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also wrap this in a try/except block like below and catch any import errors? This would prevent squirrel from crashing when datasets is installed and some requirements are missing

Copy link
Contributor Author

@axkoenig axkoenig Dec 15, 2022

Choose a reason for hiding this comment

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

are you referring to line 42?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah sorry, I got confused, please ignore this comment :)

Copy link
Contributor

@winfried-ripken winfried-ripken 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, LG!

@axkoenig axkoenig merged commit 875274b into main Dec 19, 2022
@axkoenig axkoenig deleted the ak-fix-driver-imports branch December 19, 2022 13:33
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 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.

2 participants