Skip to content

Commit a00f1f6

Browse files
author
jkamelin
committed
remove hash length assertion
1 parent 4fd489f commit a00f1f6

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

tools/model_tools/src/openvino/model_zoo/download_engine/cache.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727

2828
class NullCache:
29-
def has(self, hash, hash_len): return False
30-
def get(self, model_file, path, reporter, hash_len): return False
29+
def has(self, hash): return False
30+
def get(self, model_file, path, reporter): return False
3131
def put(self, hash, path): pass
3232

3333

@@ -41,16 +41,15 @@ def __init__(self, cache_dir):
4141
self._staging_dir = self._cache_dir / 'staging'
4242
self._staging_dir.mkdir(exist_ok=True)
4343

44-
def _hash_path(self, hash, hash_len):
45-
assert len(hash) == hash_len
44+
def _hash_path(self, hash):
4645
hash_str = hash.hex().lower()
4746
return self._cache_dir / hash_str[:2] / hash_str[2:]
4847

49-
def has(self, hash, hash_len):
50-
return self._hash_path(hash, hash_len).exists()
48+
def has(self, hash):
49+
return self._hash_path(hash).exists()
5150

52-
def get(self, model_file, path, reporter, hash_len):
53-
cache_path = self._hash_path(model_file.checksum.value, hash_len)
51+
def get(self, model_file, path, reporter):
52+
cache_path = self._hash_path(model_file.checksum.value)
5453
cache_sha = model_file.checksum.type
5554
cache_size = 0
5655

tools/model_tools/src/openvino/model_zoo/download_engine/downloader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ def _try_download(self, reporter, file, start_download, size, hasher):
108108

109109
def _try_retrieve_from_cache(self, reporter, model_file, destination):
110110
try:
111-
if self.cache.has(model_file.checksum.value, model_file.checksum.type.digest_size):
111+
if self.cache.has(model_file.checksum.value):
112112
reporter.job_context.check_interrupted()
113113

114114
reporter.print_section_heading('Retrieving {} from the cache', destination)
115-
if not self.cache.get(model_file, destination, reporter, model_file.checksum.type.digest_size):
115+
if not self.cache.get(model_file, destination, reporter):
116116
reporter.print('Will retry from the original source.')
117117
reporter.print()
118118
return False

0 commit comments

Comments
 (0)