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

Add list_spaces to HfApi #889

Merged
merged 13 commits into from
Jun 29, 2022
Merged

Conversation

cakiki
Copy link
Contributor

@cakiki cakiki commented May 30, 2022

First try; fixes #881. :-)
Reused the SpaceInfo class, but not sure that was the way to go because of unused fields:

SpaceInfo: {
	id: BigSalmon/Streamlit_Headline_Writer
	sha: None
	lastModified: None
	siblings: None
	private: None
	author: None
	sdk: streamlit
}

cc @osanseviero @LysandreJik

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented May 30, 2022

The documentation is not available anymore as the PR was closed or merged.

Copy link
Contributor

@osanseviero osanseviero left a comment

Choose a reason for hiding this comment

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

Overall this looks to go in the right direction! I would suggest to add a test for this 😄

src/huggingface_hub/hf_api.py Outdated Show resolved Hide resolved
src/huggingface_hub/hf_api.py Outdated Show resolved Hide resolved
@julien-c
Copy link
Member

On the server API side, possible query params on that endpoint are:

  • full (boolean) => will return in addition to the base props

    • author
    • sha
    • lastModified
    • cardData
    • tags
  • datasets (boolean or string or array of strings which are dataset ids)

  • models (boolean or string or array of strings which are model ids)

  • datasets=true and models=true can be replaced with linked=true (boolean)

relevant internal PR for the model/dataset linking

Feel free to experiment with the API to see what it does!
Hope it's not too confusing!

@cakiki
Copy link
Contributor Author

cakiki commented Jun 2, 2022

@julien-c
Copy link
Member

julien-c commented Jun 2, 2022

@osanseviero @LysandreJik can chime in but i don't think so

@LysandreJik
Copy link
Member

It's useful, but definitely not necessary. Having list_spaces is already a very nice first step!

@cakiki
Copy link
Contributor Author

cakiki commented Jun 11, 2022

datasets=True and models=True doesn't seem to work (returns an empty list). Not sure if that's an implementation error on my side or an endpoint issue. Passing a dataset id or a model id works fine.

@cakiki cakiki requested review from osanseviero and julien-c June 13, 2022 12:33
Copy link
Member

@julien-c julien-c 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 from a quick glance!

Thank you @cakiki!!

@julien-c
Copy link
Member

hmm so @osanseviero made me realize i was mistaken, datasets (boolean) or models (boolean) are not supported

I only meant that if you pass models or datasets in your query (as string or array of string), then they will also be returned as fields in the API output.

Sorry about the incorrect information!

Copy link
Contributor

@osanseviero osanseviero left a comment

Choose a reason for hiding this comment

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

Very cool PR! I left some suggestions 😄

src/huggingface_hub/hf_api.py Outdated Show resolved Hide resolved
src/huggingface_hub/hf_api.py Outdated Show resolved Hide resolved
src/huggingface_hub/hf_api.py Outdated Show resolved Hide resolved
src/huggingface_hub/hf_api.py Outdated Show resolved Hide resolved
src/huggingface_hub/hf_api.py Outdated Show resolved Hide resolved
src/huggingface_hub/hf_api.py Outdated Show resolved Hide resolved
src/huggingface_hub/hf_api.py Outdated Show resolved Hide resolved
src/huggingface_hub/hf_api.py Outdated Show resolved Hide resolved
cakiki and others added 2 commits June 22, 2022 14:00
Co-authored-by: Omar Sanseviero <osanseviero@gmail.com>
@cakiki cakiki requested a review from osanseviero June 23, 2022 08:15
Copy link
Contributor

@osanseviero osanseviero 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! I left some comments on the tests but otherwise looks almost ready to merge

src/huggingface_hub/hf_api.py Outdated Show resolved Hide resolved
tests/test_hf_api.py Outdated Show resolved Hide resolved
@cakiki cakiki requested a review from osanseviero June 24, 2022 19:29
cakiki and others added 2 commits June 28, 2022 15:35
@osanseviero osanseviero merged commit c216bbd into huggingface:main Jun 29, 2022
@osanseviero
Copy link
Contributor

Thank you @cakiki for the contribution!! 🔥 🔥

@julien-c
Copy link
Member

Yay it's very cool!! thanks

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.

Add list_spaces
5 participants