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

Paginate repo likers endpoint #2530

Merged
merged 5 commits into from
Sep 11, 2024
Merged

Paginate repo likers endpoint #2530

merged 5 commits into from
Sep 11, 2024

Conversation

hanouticelina
Copy link
Contributor

Related to #2508 and #2506.

The related test was not modified. To have a robust test, we should maybe use an existing repo with enough likers. WDYT? Do you have any suggestion of such repo we can rely on for this test? @Wauplin

@HuggingFaceDocBuilderDev

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.

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

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

Looks good to me, except my comment about breaking changes. Still think it's ok-ish to break it like this.

Comment on lines +2374 to +2375
for liker in paginate(path, params={}, headers=self._build_hf_headers(token=token)):
yield User(username=liker["user"], fullname=liker["fullname"], avatar_url=liker["avatarUrl"])
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this is unfortunately a breaking change since users cannot do list_repo_likers(...)[0] anymore. It might break some script in the wild. We already had a similar issue when we switched list_models (and datasets/spaces) to paginated results in the past. It was much more painful as it was used everywhere.

Here I'm not sure there is much adoption yet so I would be tempted to merge "as is" and break things rather than having a half-solution for months. @LysandreJik what's your take on this?

For context, I've checked https://github.com/search?q=list_repo_likers&type=code&p=1 and didn't find much third-party integrations.

Copy link
Member

Choose a reason for hiding this comment

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

I would tend to say that a deprecation cycle rarely hurts but if you're certain it's not being used much yet, then maybe breaking this one is fine

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem is that a deprecation cycle on an output type is a bit more annoying. I tried something for list_models in the past (#1143) but we got quite some problems and misunderstanding from users... 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since there is not so much adoption (compared to list_models() or list_datasets()), imo it's worth merging as is rather than handling a deprecation cycle

tests/test_hf_api.py Outdated Show resolved Hide resolved
# a repo with > 5000 likes
all_likers = list(
HfApi().list_repo_likers(
repo_id="open-llm-leaderboard/open_llm_leaderboard", repo_type="space", token=TOKEN
Copy link
Contributor

Choose a reason for hiding this comment

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

I think passing TOKEN (i.e. a staging token) to production will fail. It's fine not to pass token at all in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't seem to fail 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my bad! I forgot to remove it, thanks!

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

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

Thanks! Let's wait for @LysandreJik 's opinion though

Comment on lines +2374 to +2375
for liker in paginate(path, params={}, headers=self._build_hf_headers(token=token)):
yield User(username=liker["user"], fullname=liker["fullname"], avatar_url=liker["avatarUrl"])
Copy link
Member

Choose a reason for hiding this comment

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

I would tend to say that a deprecation cycle rarely hurts but if you're certain it's not being used much yet, then maybe breaking this one is fine

@hanouticelina
Copy link
Contributor Author

Thanks @Wauplin and @LysandreJik for the reviews! based on the discussion here, let's implement the breaking change directly, I'm merging the PR 😄

@hanouticelina hanouticelina merged commit 26c2d89 into main Sep 11, 2024
19 checks passed
@hanouticelina hanouticelina deleted the paginate-likers branch September 11, 2024 14:13
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.

4 participants