From c214c0decb079cbdc4cd129bc2770b024172a06d Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 18 May 2017 08:32:03 -0500 Subject: [PATCH] Improve env_opt reporting --- spacy/util.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/spacy/util.py b/spacy/util.py index ef2e78b3b..8374e168e 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -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