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

Add label collection to help with multiple label comparisons #116

Merged
merged 3 commits into from
Aug 17, 2023

Conversation

wagoodman
Copy link
Contributor

Today it's easy to load all of the labels needed for an image and pass them into the comparison helpers. However, doing that will result in slow comparisons without it being clear as to why. In the future more logic can be added around the core objects to make it hard to misuse, but in the meantime a convenience LabelEntryCollection has been added by this PR to allow an API user to filter already loaded labels before a comparison is done.

Note: this uses functools.cache which was introduced in python 3.9, so the requirements were changed.

Additionally:

  • we shouldn't try to load all of the labels just because an empty list is passed, we should distinct between None and []. This has been addressed.
  • there is a lot of noise when in debug for loading labels so I removed one log line in that code path.

Signed-off-by: Alex Goodman <[email protected]>
@wagoodman wagoodman requested a review from a team August 17, 2023 13:23
@@ -499,6 +500,15 @@ def effective_year(self, by_cve=False) -> Optional[int]:
return year


class LabelEntryCollection:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. Is this meant to be used as the type of label_entries in src/yardstick/__init__.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not in this PR, no. This PR only adds this object to be used by API consumers. In the future this can be rolled underneath the core API.

Signed-off-by: Alex Goodman <[email protected]>
@wagoodman wagoodman merged commit dc54ea7 into main Aug 17, 2023
2 checks passed
@wagoodman wagoodman deleted the add-label-collection branch August 17, 2023 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants