Skip to content

Instantly share code, notes, and snippets.

@fclesio
Created January 2, 2022 16:18
Show Gist options
  • Save fclesio/f7a18db752a156d7ea7306f058cd6485 to your computer and use it in GitHub Desktop.
Save fclesio/f7a18db752a156d7ea7306f058cd6485 to your computer and use it in GitHub Desktop.
import hashlib
import sys
from module import download_model_locally
def check_model_md5(model_name, api_production_artifact_md5):
"""Ref: https://stackoverflow.com/a/21565932/"""
"""This function will download the model """
download_model_locally_to(model_name)
model_md5 = hashlib.md5()
with open(model_name, "rb") as f:
for block in iter(lambda: f.read(65536), b""):
model_md5.update(block)
if model_md5 != api_production_artifact_md5:
raise SystemExit('Error: Model in a non consistent state with API. Exit.')
def main():
check_model_md5(
model_name='/production_model.h5',
api_production_artifact_md5='9aa16e38ad6e5d53aef0aac7b4ff7674',
)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment