import hashlib


def compute_file_hash(filename: str, buffer_size: int = 64 * 1024) -> str:
    """
    When we make any modifications to the inputs of a baseline, the baseline should
    also reflect these changes. Otherwise, we can get into a strange situation of
    irreproducibility: a "hidden" change to the underlying model may produce different
    results.

    To ensure this doesn't happen, we capture a hash of the model that we are using.
    This way, if the model changes, the baseline will have to change, and we will be
    able to better track the changes this way.

    This is akin to:
        $ sha1sum <filename>
    """
    sha1 = hashlib.sha1()
    with open(filename, 'rb') as f:
        data = f.read(buffer_size)
        while data:
            sha1.update(data)
            data = f.read(buffer_size)

    return sha1.hexdigest()