Skip to content

Commit

Permalink
Ersilia Catalog Bug when no models are available (#1175)
Browse files Browse the repository at this point in the history
* fixed error that occurs when no local model is available

* implenting requested changes

---------

Co-authored-by: Dhanshree Arora <DhanshreeA@users.noreply.github.com>
  • Loading branch information
dzumii and DhanshreeA authored Jun 26, 2024
1 parent 0f7e968 commit c3b4151
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions ersilia/cli/commands/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def catalog_cmd():
def catalog(local=False, file_name=None, browser=False, more=False):
if local is True and browser is True:
click.echo(
"You cannot show the local model catalog in the browser", fg="red"
"You cannot show the local model catalog in the browser",
fg="red",
)
if more:
only_identifier = False
Expand All @@ -42,16 +43,19 @@ def catalog(local=False, file_name=None, browser=False, more=False):
if browser:
mc.airtable()
return
if local:
if file_name is None:
catalog = mc.local().as_json()
else:
mc.local().write(file_name)
catalog = None
catalog_table = mc.local() if local else mc.hub()
if local and not catalog_table.data:
click.echo(
click.style(
"No local model is available. Please fetch a model by running 'ersilia fetch ...'",
fg="red",
)
)
return
if file_name is None:
catalog = catalog_table.as_json()
else:
if file_name is None:
catalog = mc.hub().as_json()
else:
mc.hub().write(file_name)
catalog = None
catalog_table.write(file_name)
catalog = None

click.echo(catalog)
2 changes: 1 addition & 1 deletion ersilia/hub/content/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def local(self):
columns = ["Identifier", "Slug", "Title", "Status", "Input", "Output", "Service Class"]
logger.info("Found {0} models".format(len(R)))
if len(R) == 0:
return None
return CatalogTable(data=[], columns=columns)
return CatalogTable(data=R, columns=columns)

def bentoml(self):
Expand Down

0 comments on commit c3b4151

Please sign in to comment.