huggingface / Google-Cloud-Containers

Hugging Face Deep Learning Containers (DLCs) for Google Cloud
https://hf.co/docs/google-cloud
Apache License 2.0
130 stars 18 forks source link

'ModelInfo' object has no attribute 'securityStatus' #116

Closed weigary closed 3 weeks ago

weigary commented 1 month ago

Hi HF team,

We used to use the hf_api.model_info().securityStatus to check if the model repo contains any unsafe files, see the sample call below

from huggingface_hub import HfApi

hf_api = HfApi(
    endpoint="https://huggingface.co",
)

model_info = hf_api.model_info(repo_id="google/gemma-2-27b", securityStatus=True)
print(model_info.securityStatus)

It stopped working as we found it today.

Error message:

Cell In[4], line 8
      3 hf_api = HfApi(
      4     endpoint="https://huggingface.co",
      5 )
      7 model_info = hf_api.model_info(repo_id="google/gemma-2-27b", securityStatus=True)
----> 8 print(model_info.securityStatus)

AttributeError: 'ModelInfo' object has no attribute 'securityStatus'

Still investigating, but it seems it is not related to the version of the huggingface_hub libarary version. For example, the latest lib version in Google3 is 0.25.1, while the previous version is 0.24.6, which is the version we found it was working. However, even if we downgrade the lib version to 0.24.6, the same API call still does not work.

weigary commented 1 month ago

It seems the API response has been changed to:

https://huggingface.co/api/models/google/gemma-2-27b?securityStatus=1

  "securityRepoStatus": {
    "scansDone": false,
    "filesWithIssues": []
  },
weigary commented 1 month ago

Is it a long-term change?

suzukimain commented 4 weeks ago

Hello. @weigary Do you have any new information on this issue?

hanouticelina commented 3 weeks ago

Hello @weigary, one of the maintainers of huggingface_hub here 🤗 The issue comes from the fact that the securityStatus field was recently renamed to securityRepoStatus on the server side. we've just shipped a patch release (v0.26.2) to fix this where we added a proper field to access a model's security scan status in ModelInfo:

first you will need to upgrade to huggingface_hub==0.26.2:

pip install huggingface_hub==0.26.2

then, you will be able to access model's scan status using ModelInfo.security_repo_status field :

from huggingface_hub import HfApi

hf_api = HfApi(
    endpoint="https://huggingface.co",
)

model_info = hf_api.model_info(repo_id="google/gemma-2-27b", securityStatus=True)
print(model_info.security_repo_status)
weigary commented 3 weeks ago

Thank you Celina. I am using the model_info.securityRepoStatus which seems to work for now. I will update my code to start using the model_info.security_repo_status!

weigary commented 3 weeks ago

Mark it as closed.