-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
In spacy 2.1, linking a model from within a python interpreter fails #3435
Comments
Ah, I think this is a side-effect of not creating the symlink for models that are also packages and can be loaded via the package name. I'm surprised that it can't find the model from within the same session... I guess if you install a new package, To explain this in more detail: There are essentially 3 ways of loading that are supported by Does creating the symlink explicitly via from spacy.cli import link
from spacy.util import get_package_path
model_name = "en_core_web_sm"
package_path = get_package_path(model_name)
link(model_name, model_name, force=True, package_path=package_path) If not, we could re-add an argument to the |
Yes, putting an explicit link in there works, thanks for the workaround. Personally, I'd say that finding a solution for getting |
Yay, glad it worked 👍 Already added the flag, and I guess it's okay to have it, just so there's a clear way to replicate the exact behaviour of 2.0. We'll think about this some more! |
I'm getting this same error on a brand new virtual env using spacy
And then:
|
You forgot these two lines: >>> from spacy.cli.download import download
>>> download('en_core_web_sm') |
@ines what was the reason for reverting the |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm not certain I named this right, as I don't know enough of spacy's internals to know if this is a linking issue or not, but it sure looks like it to me.
Prior to spacy 2.1, we were able to download a model from within a python interpreter and then, without restarting the interpreter, load the model successfully. It appears that in 2.1 we can no longer do this. I had a bit of a hit-and-miss reproducing this - my mac laptop originally reproduced it, then failed to (maybe a symlink was created that didn't get removed when I tried to clean the environment...?) - but on a fresh docker image, the issue is obviously there.
How to reproduce the behaviour
In spacy 2.0.x:
In spacy 2.1.0:
If I exit the interpreter and restart it after this, loading the model works without issue.
Context for why we want this functionality
In allennlp, we want to install spacy models when they are requested, inside of a training command: https://github.com/allenai/allennlp/blob/1b07b481007a52c76531fb4295120448493e6a41/allennlp/common/util.py#L289-L294. This dramatically simplifies our setup, so we don't have to worry about having a default model installed when you
pip install allennlp
.Your Environment
The text was updated successfully, but these errors were encountered: