@@ -63,8 +63,8 @@ def __init__(
63
63
self ,
64
64
repo_id : str ,
65
65
filename : str ,
66
- expected_sha256 : str ,
67
66
revision : str = "main" ,
67
+ expected_sha256 : str | None = None ,
68
68
download_url : str | None = None ,
69
69
) -> None :
70
70
"""Initialize the HubPath.
@@ -79,7 +79,7 @@ def __init__(
79
79
self .repo_id = repo_id
80
80
self .filename = filename
81
81
self .revision = revision
82
- self .expected_sha256 = expected_sha256 .lower ()
82
+ self .expected_sha256 = expected_sha256 .lower () if expected_sha256 is not None else None
83
83
self .override_download_url = download_url
84
84
85
85
@staticmethod
@@ -135,6 +135,7 @@ def local_hash(self) -> str:
135
135
136
136
def check_local_hash (self ) -> bool :
137
137
"""Check if the sha256 hash of the file in the local hub is correct."""
138
+ assert self .expected_sha256 is not None , f"{ self .repo_id } /{ self .filename } has no expected sha256 hash"
138
139
if self .expected_sha256 != self .local_hash :
139
140
logging .warning (f"{ self .local_path } local sha256 mismatch, { self .local_hash } != { self .expected_sha256 } " )
140
141
return False
@@ -144,6 +145,7 @@ def check_local_hash(self) -> bool:
144
145
145
146
def check_remote_hash (self ) -> bool :
146
147
"""Check if the sha256 hash of the file on the hf hub is correct."""
148
+ assert self .expected_sha256 is not None , f"{ self .repo_id } /{ self .filename } has no expected sha256 hash"
147
149
if self .expected_sha256 != self .hf_sha256_hash :
148
150
logging .warning (
149
151
f"{ self .local_path } remote sha256 mismatch, { self .hf_sha256_hash } != { self .expected_sha256 } "
0 commit comments