huggingface / huggingface_hub

The official Python client for the Huggingface Hub.
https://huggingface.co/docs/huggingface_hub
Apache License 2.0
1.82k stars 470 forks source link

Support `expand` parameter in `xxx_info` and `list_xxxs` (model/dataset/Space) #2333

Open Wauplin opened 2 weeks ago

Wauplin commented 2 weeks ago

Solve https://github.com/huggingface/huggingface_hub/issues/2325.

EDIT: added support for model_info/dataset_info/space_info as well as list_models/list_datasets/list_spaces. Added tests and docstrings for all of them.


First draft of what we discussed in https://github.com/huggingface/huggingface_hub/issues/2325#issuecomment-2162407468 cc @osanseviero @julien-c . In the end I went for "put everything in ModelInfo and have all attributes optional". For now I only implemented expand for models helpers but it can be easily extended to datasets/spaces.

In order to better document the available parameters, I used a Literal type annotations listing all valid keys. Since it's "just" a type annotation, passing any string will still be backward compatible in the future as long as the server handles it. The cons is that the list has to be manually maintained to stay up to date with server changes (not happening very often). I have added a test for that. At least an update is pushed server-side, we will notice it in our CI runs.

@osanseviero @julien-c let me know if you are opinionated on something, otherwise I'll continue with it :)

HuggingFaceDocBuilderDev commented 2 weeks ago

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.