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

spacy.load should raise error if model not found #968

Closed
coventry opened this issue Apr 8, 2017 · 5 comments
Closed

spacy.load should raise error if model not found #968

coventry opened this issue Apr 8, 2017 · 5 comments
Labels
enhancement Feature requests and improvements 🌙 nightly Discussion and contributions related to nightly builds

Comments

@coventry
Copy link

coventry commented Apr 8, 2017

E.g. python -c 'import spacy; n = spacy.load("en_ansoteauhnotoheunatoheun")' runs without error

In [69]: import spacy
nlp = spacy.load('en_aosentnoteoeunt')
doc = nlp(u'They told us to duck.')
for word in doc:
    print(word.text, word.lemma, word.lemma_, word.tag, word.tag_, word.pos, word.pos_)


In [70]: 
In [71]: 
In [72]:    ....:    ....: (u'They', 0, u'', 0, u'', 0, u'')
(u'told', 0, u'', 0, u'', 0, u'')
(u'us', 0, u'', 0, u'', 0, u'')
(u'to', 0, u'', 0, u'', 0, u'')
(u'duck', 0, u'', 0, u'', 0, u'')
(u'.', 0, u'', 0, u'', 0, u'')

I assume the tag and pos values are not all supposed to be empty/zero. BTW, I get the same result even if I use nlp = spacy.load('en'), but that may be some kind of misconfiguration from installing it carelessly.

@coventry
Copy link
Author

coventry commented Apr 8, 2017

This was on an ubuntu 14.04 system with many other packages install. Doesn't happen on a fresh 16.04 so it's probably some kind of boring version skew.

@coventry coventry closed this as completed Apr 8, 2017
@honnibal honnibal added the enhancement Feature requests and improvements label Apr 8, 2017
@honnibal honnibal changed the title spacy.load silently accepts garbage as long as you give a good language prefix spacy.load should raise error if model not found Apr 8, 2017
@honnibal honnibal reopened this Apr 8, 2017
@honnibal honnibal added the 🌙 nightly Discussion and contributions related to nightly builds label Apr 8, 2017
@honnibal
Copy link
Member

honnibal commented Apr 8, 2017

Thanks for updating after you debugged. I have that sort of problem with my Python environments a lot. The most common cause is if my PATH and PYTHONPATH variables are out-of-synch, so the pip command and python -m pip do something different.

Anyway. Relabelling this issue for a planned enhancement for v2. It's rubbish that the spacy.load() command silently "works" even if it doesn't...load. This behaviour has been preserved through the last few releases for backwards compatibility, but will be fixed for v2.

@ines
Copy link
Member

ines commented Apr 8, 2017

Yes, I agree – for now, it'd be nice to at least print a warning if spacy.load() is called with a name that doesn't map to a model (the underlying functionality for checking that is all there). I'll have a look at this.

For v2.0, we should maybe consider explicitly encouraging importing models as packages for the default use case:

import en_core_web_sm
nlp = en_core_web_sm.load()

From the feedback we got so far, it turned out that a lot of users now actually prefer this way of loading the models over spacy.load(), as it's cleaner and more transparent, and lets you manage model dependencies like any other package dependency. As we publish more models, this will become more and more relevant. Especially production users might not want to rely on having the right model installed and mapped to an arbitrary name – instead, their application can explicitly require a specific version of a specific model.

@ines
Copy link
Member

ines commented Apr 16, 2017

Fixed in v1.8.0!

@ines ines closed this as completed Apr 16, 2017
@lock
Copy link

lock bot commented May 8, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators May 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Feature requests and improvements 🌙 nightly Discussion and contributions related to nightly builds
Projects
None yet
Development

No branches or pull requests

3 participants