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

Perform additional check for owner string in is_<library>_available functions #2859

Merged
merged 3 commits into from
Aug 23, 2024

Conversation

leblancfg
Copy link
Contributor

@leblancfg leblancfg commented Jul 24, 2024

Currently if you have a datasets module in your sys.path, the is_datasets_available function will return True, even if it's not the one from Huggingface.

Here we add a slightly smarter logic to check the origin string of the importlib spec, and match it against the expected owner. This makes it possible for users who also have an unrelated module in their sys.path called datasets to do imports like

from sentence_transformers import SentenceTransformer

while leaving all other functionality untouched.

Closes #2858

leblancfg and others added 2 commits July 24, 2024 11:52
Currently if you have a `datasets` module in your PYTHONPATH, the
`is_datasets_available` function will return True, even if it's not the
one from Huggingface.

Here we add a slightly more complex logic to check the origin string of
the importlib spec to match it against the expected owner.
That function returns a boolean, not None
@leblancfg leblancfg force-pushed the importlib-datasets-spec-check branch from acda278 to eab0a28 Compare August 20, 2024 15:25
@leblancfg leblancfg requested a review from tomaarsen August 20, 2024 15:26
@tomaarsen
Copy link
Collaborator

I ran some tests locally, and it seems to work just like you'd hope now! Thanks a bunch, I'm merging this now. (We can ignore the CI test failures, they're unrelated due to disk space).

  • Tom Aarsen

@tomaarsen tomaarsen merged commit fbe7d6a into UKPLab:master Aug 23, 2024
6 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Initializing the package fails if there's unrelated datasets module in PYTHONPATH
2 participants