Add function to resolve load name

Warn if old 'path' keyword argument is used.
This commit is contained in:
ines 2017-05-08 16:33:37 +02:00
parent e6f1a5d0a1
commit b9ba58ba5c
2 changed files with 10 additions and 2 deletions

View File

@ -10,8 +10,7 @@ from . import util
def load(name, **overrides):
if overrides.get('path') not in (None, False, True):
name = overrides.get('path')
name = util.resolve_load_name(name, **overrides)
model_path = util.resolve_model_path(name)
meta = util.parse_package_meta(model_path)
if 'lang' not in meta:

View File

@ -142,6 +142,15 @@ def read_json(location):
return ujson.load(f)
def resolve_load_name(name, **overrides):
if overrides.get('path') not in (None, False, True):
name = overrides.get('path')
prints("To load a model from a path, you can now use the first argument.",
"OLD: spacy.load('en', path='/some/path')", "NEW: spacy.load('/some/path')",
title="Warning: deprecated argument 'path'")
return name
def resolve_model_path(name):
data_path = get_data_path()
if not data_path or not data_path.exists():