mirror of https://github.com/explosion/spaCy.git
Use make_tempdir instead
This commit is contained in:
parent
e9f7f9a4bc
commit
0efb7413f9
|
@ -17,7 +17,7 @@ from spacy.schemas import ConfigSchemaTraining
|
||||||
|
|
||||||
from thinc.api import get_current_ops, NumpyOps, CupyOps
|
from thinc.api import get_current_ops, NumpyOps, CupyOps
|
||||||
|
|
||||||
from .util import get_random_doc, make_named_tempfile
|
from .util import get_random_doc, make_tempdir
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -369,11 +369,12 @@ def make_dummy_component(
|
||||||
return DummyComponent(nlp.vocab, name)
|
return DummyComponent(nlp.vocab, name)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
with make_named_tempfile(mode="w", suffix=".py") as fileh:
|
with make_tempdir() as temp_dir:
|
||||||
|
code_path = os.path.join(temp_dir, "code.py")
|
||||||
|
with open(code_path, "w") as fileh:
|
||||||
fileh.write(code_str)
|
fileh.write(code_str)
|
||||||
fileh.flush()
|
|
||||||
|
|
||||||
import_file("python_code", fileh.name)
|
import_file("python_code", code_path)
|
||||||
config = {"initialize": {"components": {"dummy_component": {"dummy_param": 1}}}}
|
config = {"initialize": {"components": {"dummy_component": {"dummy_param": 1}}}}
|
||||||
nlp = English.from_config(config)
|
nlp = English.from_config(config)
|
||||||
nlp.add_pipe("dummy_component")
|
nlp.add_pipe("dummy_component")
|
||||||
|
|
|
@ -14,13 +14,6 @@ def make_tempfile(mode="r"):
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
|
||||||
def make_named_tempfile(mode="r", suffix=None):
|
|
||||||
f = tempfile.NamedTemporaryFile(mode=mode, suffix=suffix)
|
|
||||||
yield f
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
|
|
||||||
def get_batch(batch_size):
|
def get_batch(batch_size):
|
||||||
vocab = Vocab()
|
vocab = Vocab()
|
||||||
docs = []
|
docs = []
|
||||||
|
|
Loading…
Reference in New Issue