revert to older version of list_models() (#1611)

This restores the correct behavior of list_models() and quenches
the bug of list_models() returning a single model entry named "name".

I have not investigated what was wrong with the new version, but I
think it may have to do with changes to the behavior in dict.update()
This commit is contained in:
Lincoln Stein 2022-11-29 08:54:39 -05:00 committed by GitHub
parent 8999a5564b
commit 40c3ab0181
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -126,18 +126,15 @@ class ModelCache(object):
def list_models(self) -> dict: def list_models(self) -> dict:
''' '''
Return a dict of models in the format: Return a dict of models in the format:
{ { model_name1: {'status': ('active'|'cached'|'not loaded'),
model_name1: {
'status': ('active'|'cached'|'not loaded'),
'description': description, 'description': description,
}, },
model_name2: { etc }, model_name2: { etc }
}
''' '''
models = {} models = {}
for name, config in self.config.items(): for name in self.config:
try: try:
description = config.description description = self.config[name].description
except ConfigAttributeError: except ConfigAttributeError:
description = '<no description>' description = '<no description>'
@ -148,12 +145,10 @@ class ModelCache(object):
else: else:
status = 'not loaded' status = 'not loaded'
models.update( models[name]={
name = { 'status' : status,
'status': status, 'description' : description
'description': description, }
})
return models return models
def print_models(self) -> None: def print_models(self) -> None: