-
Notifications
You must be signed in to change notification settings - Fork 456
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
Fix pagination when listing discussions #1962
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1962 +/- ##
==========================================
+ Coverage 82.32% 82.38% +0.06%
==========================================
Files 66 66
Lines 8141 8141
==========================================
+ Hits 6702 6707 +5
+ Misses 1439 1434 -5 ☔ 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.
Great, thanks @Wauplin!
@with_production_testing | ||
def test_get_repo_discussion_pagination(self): | ||
discussions = list( | ||
HfApi().get_repo_discussions(repo_id="HuggingFaceH4/open_llm_leaderboard", repo_type="space") | ||
) | ||
assert len(discussions) > 50 |
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.
Heavy test 😅
Thanks for the review! |
Pagination in
get_repo_discussions
is broken which leads to an infinite loop on repos with more than 50 discussions. This PR fixes this. Pagination is page-based (not cursor-based as other listing APIs) and the page parameter is named"p"
server-side, not"page_index"
(see in moon-landing -private repo-).I encountered this issue while listing discussions on the Open LLM Leaderboard (cc @clefourrier).
I also made a small change to use
requests.get(..., params=...)
instead ofurlencode
.