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 2.0 seems to cause problems #830

Closed
yayitswei opened this Issue Nov 13, 2017 · 11 comments

Comments

Projects
None yet
6 participants
@yayitswei
Contributor

yayitswei commented Nov 13, 2017

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-2-dd528794d4e5> in <module>()
----> 1 from snorkel.parser import TSVDocPreprocessor
      2 
      3 doc_preprocessor = TSVDocPreprocessor('data/articles.tsv', max_docs=n_docs)

/Users/wei/code/snorkel/snorkel/parser/__init__.py in <module>()
      3 from .doc_preprocessors import *
      4 from .parser import *
----> 5 from .spacy_parser import *
      6 from .rule_parser import *

/Users/wei/code/snorkel/snorkel/parser/spacy_parser.py in <module>()
      9     from spacy.deprecated import resolve_model_name
     10 except:
---> 11     raise Exception("spaCy not installed. Use `pip install spacy`.")
     12 
     13 

Exception: spaCy not installed. Use `pip install spacy`.
@ajratner

This comment has been minimized.

Show comment
Hide comment
@ajratner

ajratner Nov 14, 2017

Contributor

So you have spacy installed and then this happened when you upgraded? Can you give a bit more context? thanks!

Contributor

ajratner commented Nov 14, 2017

So you have spacy installed and then this happened when you upgraded? Can you give a bit more context? thanks!

@yayitswei

This comment has been minimized.

Show comment
Hide comment
@yayitswei

yayitswei Nov 15, 2017

Contributor

Yup, this happened with spacy 2.0 and when I downgraded to spacy 1.10.0 I didn't get this message anymore.

Contributor

yayitswei commented Nov 15, 2017

Yup, this happened with spacy 2.0 and when I downgraded to spacy 1.10.0 I didn't get this message anymore.

@piordanov

This comment has been minimized.

Show comment
Hide comment
@piordanov

piordanov Nov 16, 2017

Spacy v2.0 has a lot of backwards incompatibilities listed here. It's likely one of these must be impacting snorkel
I set up a fresh install of snorkel recently and ran into the same problem

Hopefully this will help migrating from spacy 1.x

piordanov commented Nov 16, 2017

Spacy v2.0 has a lot of backwards incompatibilities listed here. It's likely one of these must be impacting snorkel
I set up a fresh install of snorkel recently and ran into the same problem

Hopefully this will help migrating from spacy 1.x

@DarkDataAnalytics

This comment has been minimized.

Show comment
Hide comment
@DarkDataAnalytics

DarkDataAnalytics Nov 16, 2017

I have the same issue. Even when uninstalling space 2.0.3 and then installing space 1.10.0.
Yayitswei how did you downgraded spacy ? Did you do a pip uninstall ?

DarkDataAnalytics commented Nov 16, 2017

I have the same issue. Even when uninstalling space 2.0.3 and then installing space 1.10.0.
Yayitswei how did you downgraded spacy ? Did you do a pip uninstall ?

@yayitswei

This comment has been minimized.

Show comment
Hide comment
@yayitswei

yayitswei Nov 17, 2017

Contributor

I added this to python-package-requirement.txt:

spacy==1.10.0

and reran pip install -r python-package-requirement.txt

Contributor

yayitswei commented Nov 17, 2017

I added this to python-package-requirement.txt:

spacy==1.10.0

and reran pip install -r python-package-requirement.txt

@ajratner

This comment has been minimized.

Show comment
Hide comment
@ajratner

ajratner Nov 18, 2017

Contributor

Hi @yayitswei if you want to submit that change as a PR that would be great :) . Otherwise we'll add shortly

Contributor

ajratner commented Nov 18, 2017

Hi @yayitswei if you want to submit that change as a PR that would be great :) . Otherwise we'll add shortly

@DarkDataAnalytics

This comment has been minimized.

Show comment
Hide comment
@DarkDataAnalytics

DarkDataAnalytics Nov 20, 2017

Thanks for the answer but it is still not working for me.

DarkDataAnalytics commented Nov 20, 2017

Thanks for the answer but it is still not working for me.

@DarkDataAnalytics

This comment has been minimized.

Show comment
Hide comment
@DarkDataAnalytics

DarkDataAnalytics Nov 21, 2017

A bit of context here.
I use Ubuntu 16.04 on an EC2 instance with Python 2.7. The OS is up to date.
When I install the libraries with pip I do :
sudo -H pip install --requirement python-package-requirement.txt
I do it after doing : source avtivate py2Env

DarkDataAnalytics commented Nov 21, 2017

A bit of context here.
I use Ubuntu 16.04 on an EC2 instance with Python 2.7. The OS is up to date.
When I install the libraries with pip I do :
sudo -H pip install --requirement python-package-requirement.txt
I do it after doing : source avtivate py2Env

@fsonntag

This comment has been minimized.

Show comment
Hide comment
@fsonntag

fsonntag Nov 26, 2017

Contributor

Yeah, it's because of the from spacy.deprecated import resolve_model_name, because this functionality is gone. You can remove this and replace

model_name = resolve_model_name(name)
model_path = data_path / model_name

with

model_path = data_path / name

Works fine.

Contributor

fsonntag commented Nov 26, 2017

Yeah, it's because of the from spacy.deprecated import resolve_model_name, because this functionality is gone. You can remove this and replace

model_name = resolve_model_name(name)
model_path = data_path / model_name

with

model_path = data_path / name

Works fine.

@ajratner

This comment has been minimized.

Show comment
Hide comment
@ajratner

ajratner Dec 13, 2017

Contributor

Should be fixed by PR #834 re-open if not!

Contributor

ajratner commented Dec 13, 2017

Should be fixed by PR #834 re-open if not!

@ajratner ajratner closed this Dec 13, 2017

@arturomp

This comment has been minimized.

Show comment
Hide comment
@arturomp

arturomp Jan 26, 2018

Using spacy 2.0.5, snorkel 0.6.2 (acc. to snorkel/snorkel/__init__.py) or 0.6.0 (acc. to snorkel/docs/conf.py). Ran a slightly modified version of the intro tutorial. Had to change spacy_parser.py due to the error

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-3-42840d262509> in <module>()
     36 #             yield Sentence(**parts)
     37 
---> 38 corpus_parser = CorpusParser(parser=Spacy(lang='en_core_web_lg'))
     39 get_ipython().magic(u'time corpus_parser.apply(doc_preprocessor, count=n_docs)')

/Users/ampawake/Documents/awake/code/rudi.nlp/ietests/snorkel/snorkel/parser/spacy_parser.py in __init__(self, annotators, lang, num_threads, verbose)
     59         self.pipeline = []
     60         for proc in annotators:
---> 61             self.pipeline += [self.model.__dict__[proc]]
     62 
     63     @staticmethod

KeyError: u'tagger'

Replaced:

self.pipeline = []
for proc in annotators:
    self.pipeline += [self.model.__dict__[proc]]

for

self.pipeline = [proc for _, proc in self.model.__dict__['pipeline']]

If using spacy >= 2, you won't need the values of annotators anymore in Spacy.__init__() in spacy_parser.py. But just in case, their values now seem to be 'tagger', 'parser', 'ner' instead of 'tagger', 'parser', 'entity'.

arturomp commented Jan 26, 2018

Using spacy 2.0.5, snorkel 0.6.2 (acc. to snorkel/snorkel/__init__.py) or 0.6.0 (acc. to snorkel/docs/conf.py). Ran a slightly modified version of the intro tutorial. Had to change spacy_parser.py due to the error

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-3-42840d262509> in <module>()
     36 #             yield Sentence(**parts)
     37 
---> 38 corpus_parser = CorpusParser(parser=Spacy(lang='en_core_web_lg'))
     39 get_ipython().magic(u'time corpus_parser.apply(doc_preprocessor, count=n_docs)')

/Users/ampawake/Documents/awake/code/rudi.nlp/ietests/snorkel/snorkel/parser/spacy_parser.py in __init__(self, annotators, lang, num_threads, verbose)
     59         self.pipeline = []
     60         for proc in annotators:
---> 61             self.pipeline += [self.model.__dict__[proc]]
     62 
     63     @staticmethod

KeyError: u'tagger'

Replaced:

self.pipeline = []
for proc in annotators:
    self.pipeline += [self.model.__dict__[proc]]

for

self.pipeline = [proc for _, proc in self.model.__dict__['pipeline']]

If using spacy >= 2, you won't need the values of annotators anymore in Spacy.__init__() in spacy_parser.py. But just in case, their values now seem to be 'tagger', 'parser', 'ner' instead of 'tagger', 'parser', 'entity'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment