Skip to content

Added sha256 checksum info in the compute worker logs for downloaded files - #2684

Merged
ObadaS merged 3 commits into
developfrom
sha256_checksum_compute_worker
Oct 29, 2026
Merged

ObadaS merged 3 commits into
developfrom
sha256_checksum_compute_worker

Conversation

@ObadaS

@ObadaS ObadaS commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

A brief description of the purpose of the changes contained in this PR.

Added sha256 checksum info in the compute worker logs for downloaded files

Checklist

  • Code review by me
  • Hand tested by me
  • I'm proud of my work
  • Code review by reviewer
  • Hand tested by reviewer
  • CircleCi tests are passing
  • Ready to merge

@ObadaS
ObadaS marked this pull request as ready for review October 26, 2026 11:51
@Didayolo

Didayolo commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Three remarks:

Code optimization

The submission file is read twice (SHA256, then MD5), using 4 KB chunks in pure Python, which is slow on large files. The worker is pinned to Python 3.13, so hashlib.file_digest is available. Another option is to compute both digests in a single pass:

def file_checksums(filename, algorithms=("md5", "sha256")):
    hashers = {a: hashlib.new(a) for a in algorithms}
    with open(filename, "rb") as f:
        for chunk in iter(lambda: f.read(1024 * 1024), b""):
            for h in hashers.values():
                h.update(chunk)
    return {a: h.hexdigest() for a, h in hashers.items()}

This also removes the duplication between md5() and sha256().

Cache and size

Cached bundles are re-hashed on every submission. input_data and input/ref are the only bundles that get cached, and they're often the largest (several GB). With this PR, they're read in full on every run, even when nothing is downloaded. That time comes out of the 20-minute padding that tasks.py adds to the Celery soft_time_limit, and it slows down queue throughput. Two options:

  • write the hash next to the cached file (<url_hash>.sha256) when the bundle is downloaded, then read it back on later runs
  • at the very least, say in the log whether the bundle came from the cache. That's exactly the information you need to spot a stale cache

Comments

Wording: "input/ref has a sha256 checksum of [...]" doesn’t match the style of the MD5 log line. I'd suggest f"SHA256 checksum of {path} bundle: {sha256_checksum}". Logging path instead of url is the right call, since the URLs are signed.

@ObadaS

ObadaS commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator Author

Code optimization is done

For the second remark, it is half wrong, the timer does not start in the Preperation phase (otherwise that would mean that downloading docker images and all those files also counts in the timeout, which is not the case currently)
As for calculating the hash of local files, this is a good thing if you want to make sure that the files were not tempered with between the last check and this one. Creating a .sha256 file could allow people to modify it after modifying the file in the cache so that they match.

As for the wording, I have also fixed it to match

@ObadaS
ObadaS force-pushed the sha256_checksum_compute_worker branch from f897e3f to 9bb5955 Compare October 29, 2026 12:36
@ObadaS
ObadaS merged commit fd9f942 into develop Oct 29, 2026
4 checks passed
@ObadaS
ObadaS deleted the sha256_checksum_compute_worker branch October 29, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants