throw warning when model_cfg is None

This commit is contained in:
svlandeg 2020-05-15 11:02:10 +02:00
parent 102c8c7e2f
commit e0fda2bd81
2 changed files with 5 additions and 0 deletions

View File

@ -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}', "

View File

@ -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}