Skip to content

Commit

Permalink
Update how file's security metadata is retrieved following changes in…
Browse files Browse the repository at this point in the history
… the API response (#2621)

* Update security key name and BlobSecurityInfo object

* typos

* small typo

* add comment

* fix typo again
  • Loading branch information
hanouticelina authored Oct 22, 2024
1 parent e118ecc commit ab0b386
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/huggingface_hub/hf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ def __post_init__(self): # hack to make BlobLfsInfo backward compatible

@dataclass
class BlobSecurityInfo(dict):
safe: bool
safe: bool # duplicate information with "status" field, keeping it for backward compatibility
status: str
av_scan: Optional[Dict]
pickle_import_scan: Optional[Dict]

Expand Down Expand Up @@ -656,10 +657,14 @@ def __init__(self, **kwargs):
oid=last_commit["id"], title=last_commit["title"], date=parse_datetime(last_commit["date"])
)
self.last_commit = last_commit
security = kwargs.pop("security", None)
security = kwargs.pop("securityFileStatus", None)
if security is not None:
safe = security["status"] == "safe"
security = BlobSecurityInfo(
safe=security["safe"], av_scan=security["avScan"], pickle_import_scan=security["pickleImportScan"]
safe=safe,
status=security["status"],
av_scan=security["avScan"],
pickle_import_scan=security["pickleImportScan"],
)
self.security = security

Expand Down

0 comments on commit ab0b386

Please sign in to comment.