-
Notifications
You must be signed in to change notification settings - Fork 854
Add daily papers endpoint #3502
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
base: main
Are you sure you want to change the base?
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. |
Wauplin
left a comment
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.
Hi @BastienGimbert, thanks for the PR and sorry for the long delay! PR is in a pretty good shape already. I've left a few comments to make it to the finish line. Thanks in advance 🤗
src/huggingface_hub/hf_api.py
Outdated
| *, | ||
| date: 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.
| *, | |
| date: str, | |
| date: Optional[str] = None, | |
| *, |
Date should be made optional, in which case it returns recent ones https://huggingface.co/api/daily_papers
(also it's fine to have date as positional arg)
src/huggingface_hub/hf_api.py
Outdated
| ``` | ||
| """ | ||
| path = f"{self.endpoint}/api/daily_papers" | ||
| params = {"date": date} |
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.
| params = {"date": date} | |
| params = {"date": date} if date is not None else {} |
tests/test_hf_api.py
Outdated
| assert hasattr(papers[0], "title") | ||
|
|
||
| def test_list_daily_papers_by_date_invalid_date(self) -> None: | ||
| with self.assertRaises(ValueError): |
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.
| with self.assertRaises(ValueError): | |
| with self.assertRaises(BadRequestError): |
more specific to raise BadRequestError (HTTP 400)
…ter and add tests for default behavior ( After Wauplin review )
|
Hello @Wauplin, Have a nice day ! |
Wauplin
left a comment
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 quick update @BastienGimbert ! I'll merge as soon as the CI passes.
Have a nice day too 😃
Samoed
left a comment
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.
Seems from https://huggingface-openapi.hf.space/#tag/papers/get/apipaperssearch daily papers also support p, limit, week, month, sort fields
Co-authored-by: Roman Solomatin <[email protected]>
|
@bot /style |
|
Style bot fixed some files and pushed the changes. |
@Samoed Would you like to open a follow-up PR once this one is merged to add support for these parameters? :) |
|
Yes, of course |
Problem :
There was no simple function to get daily papers by date from the API.
Summary :
Add HfApi.list_daily_papers(date) to call /api/daily_papers.
Add a small test to check the endpoint returns objects and ISO date
Testing
pytest -q tests/test_hf_api.py::PaperApiTest