Skip to content

Commit d4c4676

Browse files
author
Laurent
committed
make refiners.conversion.utils.Hub.expected_sha256 optional
1 parent 0620473 commit d4c4676

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/refiners/conversion/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ def __init__(
6363
self,
6464
repo_id: str,
6565
filename: str,
66-
expected_sha256: str,
6766
revision: str = "main",
67+
expected_sha256: str | None = None,
6868
download_url: str | None = None,
6969
) -> None:
7070
"""Initialize the HubPath.
@@ -79,7 +79,7 @@ def __init__(
7979
self.repo_id = repo_id
8080
self.filename = filename
8181
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
8383
self.override_download_url = download_url
8484

8585
@staticmethod
@@ -135,6 +135,7 @@ def local_hash(self) -> str:
135135

136136
def check_local_hash(self) -> bool:
137137
"""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"
138139
if self.expected_sha256 != self.local_hash:
139140
logging.warning(f"{self.local_path} local sha256 mismatch, {self.local_hash} != {self.expected_sha256}")
140141
return False
@@ -144,6 +145,7 @@ def check_local_hash(self) -> bool:
144145

145146
def check_remote_hash(self) -> bool:
146147
"""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"
147149
if self.expected_sha256 != self.hf_sha256_hash:
148150
logging.warning(
149151
f"{self.local_path} remote sha256 mismatch, {self.hf_sha256_hash} != {self.expected_sha256}"

0 commit comments

Comments
 (0)