Improve env_opt reporting

This commit is contained in:
Matthew Honnibal 2017-05-18 08:32:03 -05:00
parent bbb59e371c
commit c214c0decb
1 changed files with 13 additions and 8 deletions

View File

@ -168,15 +168,20 @@ def get_async(stream, numpy_array):
def env_opt(name, default=None):
type_convert = type(default)
if name in os.environ:
print("Get from env", name, os.environ[name])
return type_convert(os.environ[name])
elif 'SPACY_' + name.upper() in os.environ:
print("Get from env", name, os.environ['SPACY_' + name.upper()])
return type_convert(os.environ['SPACY_' + name.upper()])
if type(default) is float:
type_convert = float
else:
print("Default", name, default)
type_convert = int
if 'SPACY_' + name.upper() in os.environ:
value = type_convert(os.environ['SPACY_' + name.upper()])
print(name, "=", repr(value), "via", "$SPACY_" + name.upper())
return value
elif name in os.environ:
value = type_convert(os.environ[name])
print(name, "=", repr(value), "via", '$' + name)
return value
else:
print(name, '=', repr(default), "by default")
return default