-
Notifications
You must be signed in to change notification settings - Fork 467
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
Create tags table #2036
Create tags table #2036
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a general question, how implicit should this whole tagging be. The way I alway imagined it was when I create a resource with a list of tags (strings) the whole db entity creation happens completely abstracted away from me as a user. Even at the API layer I would imagine that we use updates on the resource to set/remove tags. What do you think about this in general.
src/zenml/utils/tag_utils.py
Outdated
pass | ||
|
||
|
||
def delete_links( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea where to write this - but do we have any way of implementing cascading delete? Like if I delete resource 1 - will all entries for tags on resource 1 be deleted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be cascaded - this is need for removal of tags via update, I'll rename it for clarity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This folk is cascading (set in Models and other taggable entities going forward)
tags: List["TagResourceSchema"] = Relationship(
back_populates="model",
sa_relationship_kwargs=dict(
primaryjoin=f"and_(TagResourceSchema.resource_type=={TaggableResourceTypes.MODEL.value}, foreign(TagResourceSchema.resource_id)==ModelSchema.id)",
cascade="delete",
),
)
@@ -267,7 +267,7 @@ def update_model( | |||
trade_offs=tradeoffs, | |||
ethics=ethical, | |||
limitations=limitations, | |||
tags=tag, | |||
add_tags=tag, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect this to take a list of strings not just one string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a list, just the limitation of click - the name of arg must match the name of arg in the function and the user pass it as -t a -t b ...
It is exactly like you described - the user passes in a list of strings, and creation/retrieval happens under the hood. Next with Update models one can add or remove tags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, love the overall design, very clean how tags and resources are connected now, well done!!
Overall, the entire PR looks great and very polished already. High-level the only change I'd request is to handle the link creation inside the update_{resource}
ZenStore methods and get rid of the TagResource endpoints.
Also, I noticed the RestZenStore methods are still missing, but I'm sure integration tests would reveal that sooner or later anyways.
src/zenml/models/model_models.py
Outdated
tags: List[TagResponseModel] = Field( | ||
title="Tags associated with the model", | ||
) | ||
tagged: List[str] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tagged
seems redundant, this is just tag.name for tag in tags
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for CLI only, yes it is a bit redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case I'd suggest to delete that arg and simply call tag.name for tag in tags
wherever you need it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
Yes, that's exactly what I meant as well with links being created in update methods instead 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful 🙌
@@ -6560,14 +6563,17 @@ def create_tag_resource( | |||
def delete_tag_resource( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this method and the other still used now that the interface no longer exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, called inside helpers.
E2E template updates in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautifully crafted PR ! I only have a couple of suggestions, but nothing that would keep this from being merged.
Describe changes
I implemented Tags and TagsResources tables as follows:
The connection between Models (as a first entity) and linking table TagResource is soft and controlled by SQLModel, shown only for demo purposes - it is not a real FK on the DB level.
Tags are equipped with the full scope of CLI commands:
How does the connection between entities and tags work?
TagResources
Models (same for any other entity)
What are the needed changes for adding other Taggable entities?
zenml.enums.TaggableResourceTypes
@Cahllagerfeld , this PR changes the Update model for Models by removing
tags
and introducingadd_tags
andremove_tags
Pre-requisites
Please ensure you have done the following:
develop
and the open PR is targetingdevelop
. If your branch wasn't based on develop read Contribution guide on rebasing branch to develop.Types of changes