Closed
Description
I see warnings when spacy is called from unittest. I do not see these warning from
non-unittest contexts.
$ cat testcase.py
import unittest
import spacy
class SpacyTestCase(unittest.TestCase):
def test_spacy(self):
nlp = spacy.load('en')
doc = nlp('this is just a test.')
print(doc)
$ python -m unittest testcase.py
/Users/joelb/venv3/lib/python3.6/importlib/_bootstrap.py:205: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
return f(*args, **kwds)
/Users/joelb/venv3/lib/python3.6/importlib/_bootstrap.py:205: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192, got 176
return f(*args, **kwds)
/Users/joelb/venv3/lib/python3.6/importlib/_bootstrap.py:205: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
return f(*args, **kwds)
/Users/joelb/venv3/lib/python3.6/site-packages/spacy/util.py:521: ResourceWarning: unclosed file <_io.BufferedReader name='/Users/joelb/venv3/lib/python3.6/site-packages/spacy/data/en/en_core_web_sm-2.0.0/vocab/key2row'>
reader(path / key)
/Users/joelb/venv3/lib/python3.6/site-packages/spacy/language.py:618: ResourceWarning: unclosed file <_io.TextIOWrapper name='/Users/joelb/venv3/lib/python3.6/site-packages/spacy/data/en/en_core_web_sm-2.0.0/meta.json' mode='r' encoding='UTF-8'>
('meta.json', lambda p: self.meta.update(ujson.load(p.open('r'))))
/Users/joelb/venv3/lib/python3.6/site-packages/spacy/util.py:521: ResourceWarning: unclosed file <_io.TextIOWrapper name='/Users/joelb/venv3/lib/python3.6/site-packages/spacy/data/en/en_core_web_sm-2.0.0/tagger/cfg' mode='r' encoding='UTF-8'>
reader(path / key)
/Users/joelb/venv3/lib/python3.6/site-packages/spacy/util.py:521: ResourceWarning: unclosed file <_io.BufferedReader name='/Users/joelb/venv3/lib/python3.6/site-packages/spacy/data/en/en_core_web_sm-2.0.0/tagger/model'>
reader(path / key)
/Users/joelb/venv3/lib/python3.6/site-packages/spacy/util.py:521: ResourceWarning: unclosed file <_io.TextIOWrapper name='/Users/joelb/venv3/lib/python3.6/site-packages/spacy/data/en/en_core_web_sm-2.0.0/parser/cfg' mode='r' encoding='UTF-8'>
reader(path / key)
/Users/joelb/venv3/lib/python3.6/site-packages/spacy/util.py:521: ResourceWarning: unclosed file <_io.TextIOWrapper name='/Users/joelb/venv3/lib/python3.6/site-packages/spacy/data/en/en_core_web_sm-2.0.0/ner/cfg' mode='r' encoding='UTF-8'>
reader(path / key)
this is just a test.
.
----------------------------------------------------------------------
Ran 1 test in 2.013s
OK
To suppress the warnings:
$ python -W ignore:ResourceWarning -m unittest testcase.py
this is just a test.
.
----------------------------------------------------------------------
Ran 1 test in 1.933s
OK
however since these did not appear until after we upgraded to spaCy 2.x,
I thought it was worth reporting.
Your Environment
$ python -m spacy info --markdown
Info about spaCy
- spaCy version: 2.0.5
- Platform: Darwin-16.7.0-x86_64-i386-64bit
- Python version: 3.6.0
- Models: en