Skip to content

Commit a7c2197

Browse files
committed
Reverted back to md5 calculation
1 parent ddf5157 commit a7c2197

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

src/algorithmia_deployer.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,17 @@ def _replace_placeholders(self, parametric_str):
6262
return parametric_str
6363

6464
def _calculate_model_md5(self):
65-
return "xxx"
66-
# DIGEST_BLOCK_SIZE = 128 * 64
67-
# md5_hash = None
68-
# try:
69-
# with open(self.model_full_path, "rb") as f:
70-
# file_hash = hashlib.md5()
71-
# while chunk := f.read(DIGEST_BLOCK_SIZE):
72-
# file_hash.update(chunk)
73-
# md5_hash = file_hash.hexdigest()
74-
# except Exception as e:
75-
# print(f"An exception occurred while getting MD5 hash of file: {e}")
76-
# return md5_hash
65+
DIGEST_BLOCK_SIZE = 128 * 64
66+
md5 = hashlib.md5()
67+
md5_hash = None
68+
try:
69+
with open(self.model_full_path, "rb") as f:
70+
for chunk in iter(lambda: f.read(DIGEST_BLOCK_SIZE), b""):
71+
md5.update(chunk)
72+
md5_hash = md5.hexdigest()
73+
except Exception as e:
74+
print(f"An exception occurred while getting MD5 hash of file: {e}")
75+
return md5_hash
7776

7877
def _upload_model(self, remote_path, commit_SHA):
7978
_, model_name = os.path.split(self.model_full_path)

0 commit comments

Comments
 (0)