make the docstring more readable and improve the list_models logic (fixes #1539) (#1594)

This commit is contained in:
Damian Stewart 2022-11-28 21:20:56 +01:00 committed by GitHub
commit 281a2e3ecb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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