-
Notifications
You must be signed in to change notification settings - Fork 571
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 filters to HfApi.get_repo_discussions #1845
✨ Add filters to HfApi.get_repo_discussions #1845
Conversation
The documentation is not available anymore as the PR was closed or merged. |
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.
Thanks for the direct PR @SBrandeis ❤️
Looks good to me. 2 things I would add:
- mention in the docs that it's possible to filter by type, status and author. A small paragraph + a unique example with all 3 filters at once is enough (somewhere here).
- add tests to check filter are correctly sent to the server. Something like the snippet below here.
def test_get_repo_discussion_by_type(self):
discussions = list(self._api.get_repo_discussions(repo_id=self.repo_id, discussion_type="discussion"))
self.assertEqual(len(discussions), 1)
self.assertEqual(discussions[0].num, self.discussion.num)
def test_get_repo_discussion_by_author(self):
discussions = list(self._api.get_repo_discussions(repo_id=self.repo_id, discussion_type=USER))
self.assertEqual(len(discussions), 2)
discussions = list(self._api.get_repo_discussions(repo_id=self.repo_id, discussion_type="julien-c"))
self.assertEqual(len(discussions), 0)
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.
looks good!
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1845 +/- ##
===========================================
+ Coverage 48.88% 82.07% +33.19%
===========================================
Files 64 64
Lines 7765 7783 +18
===========================================
+ Hits 3796 6388 +2592
+ Misses 3969 1395 -2574 ☔ View full report in Codecov by Sentry. |
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.
Thanks a lot for the changes @SBrandeis! Looks good to me :)
DiscussionTypeFilter = Literal["all", "discussion", "pull_request"] | ||
DISCUSSION_TYPES: Tuple[DiscussionTypeFilter, ...] = typing.get_args(DiscussionTypeFilter) | ||
DiscussionStatusFilter = Literal["all", "open", "closed"] | ||
DISCUSSION_STATUS: Tuple[DiscussionTypeFilter, ...] = typing.get_args(DiscussionStatusFilter) |
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.
🤯
TL;DR
Add new filters to the
HfApi.get_repo_discussions
methodThis PR depends on https://github.com/huggingface/moon-landing/pull/8147 (private) for the
author
filter.Ping @Narsil
How it works