stop crash on !import_models call on model inside rootdir

- addresses bug report #1546
This commit is contained in:
Lincoln Stein 2022-11-26 14:58:22 +00:00
parent fdf41cc739
commit a341297b0c

View File

@ -178,11 +178,12 @@ class ModelCache(object):
method will return True. Will fail with an assertion error if provided method will return True. Will fail with an assertion error if provided
attributes are incorrect or the model name is missing. attributes are incorrect or the model name is missing.
''' '''
omega = self.config
for field in ('description','weights','height','width','config'): for field in ('description','weights','height','width','config'):
assert field in model_attributes, f'required field {field} is missing' assert field in model_attributes, f'required field {field} is missing'
assert (clobber or model_name not in omega), f'attempt to overwrite existing model definition "{model_name}"' assert (clobber or model_name not in omega), f'attempt to overwrite existing model definition "{model_name}"'
omega = self.config
config = omega[model_name] if model_name in omega else {} config = omega[model_name] if model_name in omega else {}
for field in model_attributes: for field in model_attributes:
config[field] = model_attributes[field] config[field] = model_attributes[field]