From e0fda2bd81bd7e7b1a9006c403d52c470954701b Mon Sep 17 00:00:00 2001 From: svlandeg Date: Fri, 15 May 2020 11:02:10 +0200 Subject: [PATCH] throw warning when model_cfg is None --- spacy/errors.py | 2 ++ spacy/language.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/spacy/errors.py b/spacy/errors.py index 23139e10a..99a0081c0 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -104,6 +104,8 @@ class Warnings(object): "string \"Field1=Value1,Value2|Field2=Value3\".") # TODO: fix numbering after merging develop into master + W097 = ("No Model config was provided to create the '{name}' component, " + "and no default configuration could be found either.") W098 = ("No Model config was provided to create the '{name}' component, " "so a default configuration was used.") W099 = ("Expected 'dict' type for the 'model' argument of pipe '{pipe}', " diff --git a/spacy/language.py b/spacy/language.py index 5343df4b7..2dd7ce406 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -184,6 +184,7 @@ class Language(object): self.max_length = max_length self._optimizer = None + # TODO: de-uglify (incorporating into component decorator didn't work because of circular imports) from .ml.models.defaults import ( default_tagger_config, default_parser_config, @@ -349,6 +350,8 @@ class Language(object): if model_cfg is None and default_config is not None: warnings.warn(Warnings.W098.format(name=name)) model_cfg = default_config["model"] + if model_cfg is None: + warnings.warn(Warnings.W097.format(name=name)) model = None if model_cfg is not None: self.config[name] = {"model": model_cfg}