Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make error message nicer for when two artifacts that share a prefix are found #2023

Merged
merged 3 commits into from
Nov 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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