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

Edsnlp is interferring with spacy default behavior, and requires "trainable" dependencies #234

Closed
cvinot opened this issue Dec 13, 2023 · 4 comments · Fixed by #235
Closed
Labels
bug Something isn't working

Comments

@cvinot
Copy link
Contributor

cvinot commented Dec 13, 2023

Description

EDSnlp loader from edsnlp 10.0 (AliasLoader in edsnlp init.py) is interferring with spacy default loader it seems, which creates additionnal dependencies from the edsnlp trainable components which are not listed, if intended.

How to reproduce the bug

In a fresh environment

poetry add edsnlp
download a spacy model, for example fr_core_news_sm-3.5

then:

from spacy import load
model = "fr_core_news_sm-3.5"
nlp = load(model)

Here it raises errors depending on the environment, "foldedtensor" or in our case "torch" module not found. which is not a dependency in any package, as edsnlp[ml] was not desired.

Other

I found the bug with this snippet:

import spacy
model = "fr_core_news_sm-3.5"
nlp = spacy.load(model)

Which raises [E002] Can't find factory for 'tok2vec' for language French (fr). and shows no relation to edsnlp whatsoever interestingly enough.

@percevalw percevalw added the bug Something isn't working label Dec 13, 2023
@percevalw
Copy link
Member

Hi, thank you for letting us know about this ! This is indeed problematic. By default, spacy imports all available components (i.e., that have a spacy_factories entrypoint namespace), even though they are not required by the user. You did not install edsnlp[ml] indeed, so importing some components like eds.transformer will fail, hence the bug you reported.

You can try with to re-install edsnlp with the fix from #235, let me know if this works for you !

pip install git+https://github.com/aphp/edsnlp@fix-non-ml-install

@cvinot
Copy link
Contributor Author

cvinot commented Dec 13, 2023

Interesting, I never dived into these depths of spacy.

It does fix the issue for me at first glance. Great reactivity, thanks.

@cvinot
Copy link
Contributor Author

cvinot commented Dec 13, 2023

I still have the same problem if I import part of edsnlp though.

import spacy
import edsnlp
model = "fr_core_news_sm-3.5"
nlp = spacy.load(model)

or even

import spacy
from edsnlp.language import EDSTokenizer
model = "fr_core_news_sm-3.5"
nlp = spacy.load(model)

raise the same error.

@percevalw
Copy link
Member

Ok thank you for testing, the new fix in #235 (same pip install git+https://github.com/aphp/edsnlp@fix-non-ml-install) should do the trick now 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants