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

Warn about truncation when listing collections #1873

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/source/en/guides/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ Number of upvotes: 1
Number of upvotes: 5
```

<Tip warning={true}>

When listing collections, the item list per collection is truncated to 4 items maximum. To retrieve all items from a collection, you must use [`get_collection`].

</Tip>

It is possible to do more advanced filtering. Let's get all collections containing the model [TheBloke/OpenHermes-2.5-Mistral-7B-GGUF](https://huggingface.co/TheBloke/OpenHermes-2.5-Mistral-7B-GGUF), sorted by trending, and limit the count to 5.
```py
>>> collections = list_collections(item="models/TheBloke/OpenHermes-2.5-Mistral-7B-GGUF", sort="trending", limit=5):
Expand Down
7 changes: 7 additions & 0 deletions src/huggingface_hub/hf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7270,6 +7270,13 @@ def list_collections(
) -> Iterable[Collection]:
"""List collections on the Huggingface Hub, given some filters.

<Tip warning={true}>

When listing collections, the item list per collection is truncated to 4 items maximum. To retrieve all items
from a collection, you must use [`get_collection`].

</Tip>

Args:
owner (`List[str]` or `str`, *optional*):
Filter by owner's username.
Expand Down
Loading