Skip to content

Commit

Permalink
Make error message nicer for when two artifacts that share a prefix a…
Browse files Browse the repository at this point in the history
…re found (#2023)

* fix ugly error message

* remove flavor
  • Loading branch information
strickvl authored Nov 7, 2023
1 parent 999e96f commit 6555c52
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/zenml/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5391,11 +5391,15 @@ def _get_entity_by_id_or_name_or_prefix(

# If more than one entity with the same name is found, raise an error.
entity_label = get_method.__name__.replace("get_", "") + "s"
formatted_entity_items = [
f"- {item.name}: (id: {item.id})\n"
for item in entity.items
]
raise ZenKeyError(
f"{entity.total} {entity_label} have been found that have "
f"a name that matches the provided "
f"string '{name_id_or_prefix}':\n"
f"{[entity.items]}.\n"
f"{formatted_entity_items}.\n"
f"Please use the id to uniquely identify "
f"only one of the {entity_label}s."
)
Expand Down

0 comments on commit 6555c52

Please sign in to comment.