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

Option to get security status with hf_api #2649

Closed
suzukimain opened this issue Nov 1, 2024 · 5 comments
Closed

Option to get security status with hf_api #2649

suzukimain opened this issue Nov 1, 2024 · 5 comments

Comments

@suzukimain
Copy link

Is your feature request related to a problem? Please describe.
There is no option to get securityStatus in list_models

Describe the solution you'd like
I would like to request an option in list_models like securityStatus in model_info

Describe alternatives you've considered
After getting the repo id in list_models, I get it in securityStatus of model_info

Additional context
I am thinking of making a feature request to the api-inference-community as well, if necessary.

@Wauplin
Copy link
Contributor

Wauplin commented Nov 1, 2024

Hi @suzukimain, the securityStatus field has been removed in favor of security_repo_status. The change has been made server side so you won't be able to fetch it the old way. However you can already get the new format in list_models thanks to #2639. If you upgrade to v0.26.2, you'll get it. See #2638 (comment).

@suzukimain
Copy link
Author

Hi @suzukimain, the securityStatus field has been removed in favor of security_repo_status. The change has been made server side so you won't be able to fetch it the old way. However you can already get the new format in list_models thanks to #2639. If you upgrade to v0.26.2, you'll get it. See #2638 (comment).

I'm sorry, my previous explanation was insufficient. The feature I want to request is an option to directly obtain security_repo_status from list_models, as shown in the following code. Currently, the default value None is returned, but I would like to have security_repo_status included and returned.

from huggingface_hub import HfApi

hf_api = HfApi()
hf_info = list(hf_api.list_models(filter="google"))

model_info = hf_info[0].__dict__

security_repo_status = model_info["security_repo_status"]

print(f"security_repo_status: {security_repo_status}")
print(f"keys: {model_info.keys()}")

# security_repo_status: None
# keys: dict_keys(['id', 'author', 'sha', 'last_modified', 'created_at', 'private', 'gated', 'disabled', 'downloads', 'downloads_all_time', 'likes', 'library_name', 'gguf', 'inference', 'tags', 'pipeline_tag', 'mask_token', 'trending_score', 'card_data', 'widget_data', 'model_index', 'config', 'transformers_info', 'siblings', 'spaces', 'safetensors', 'security_repo_status', 'lastModified', 'cardData', 'transformersInfo', '_id', 'modelId'])

@Wauplin
Copy link
Contributor

Wauplin commented Nov 1, 2024

In #2638 (comment) @hanouticelina showed how to leverage the securityStatus=True parameter to ask the server to return the security info. Have you tried it?

@hanouticelina
Copy link
Contributor

@Wauplin I think the issue pointed here is that the endpoint /api/models doesn't include the security status of the listed repos, the info is not included even with?full=true. However, the individual model endpoint info /api/models/{model_id} includes security status when requested with ?securityStatus=true. i guess we should look into this on the server side.

@suzukimain For now, you can work around this by iterating through the list of models and call HfApi().model_info("your_model_id",securityStatus=True) for each model. While we know this is definitely not optimal, we've noted your feature request, thanks a lot! 🤗 we will get back to you as soon as we have a better solution.

@hanouticelina
Copy link
Contributor

Hi @suzukimain, the backend team confirmed that including security_repo_status directly in the /api/models response isn’t feasible at this time, unfortunately. since this field is retrieved on-demand rather than stored in a database, adding it would significantly slow down the API and likely trigger rate limiting when requested in bulk.

The recommendation is to retrieve this information on a case-by-case basis by querying model info individually:

from huggingface_hub import HfApi
api = HfApi()
api.model_info("your_model_id", securityStatus=True)

thanks a lot for your understanding! I will close this issue but don't hesitate to comment or open a new one if you have any other question or feature request 🤗

@hanouticelina hanouticelina closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2024
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

No branches or pull requests

3 participants