Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3031 +/- ##
=======================================
Coverage 95% 95%
=======================================
Files 84 84
Lines 15503 15504 +1
=======================================
+ Hits 14772 14773 +1
Misses 731 731 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the bounded-memory checksum change.
No open issues 🎉
What changed in this PR
Reduces memory use during asset validation by streaming MD5 checks in 1 MiB chunks instead of loading entire files. Existing checksum comparison and download behavior remain unchanged; this is a memory improvement, not a claimed speedup.
Changes:
- Updates the hash helper to process files incrementally.
- Adds coverage for digest correctness, bounded reads and allocations, error cleanup, and cached downloads.
- Documents the bounded-memory behavior and adds an Unreleased changelog entry.
| File | Description |
|---|---|
tests/assets/test_downloader.py |
Adds streaming, memory-bound, failure-path, and cache-validation tests. |
src/supervision/assets/downloader.py |
Streams MD5 updates in 1 MiB chunks and updates the docstring. |
docs/changelog.md |
Records the memory improvement and updates the modification date. |
Review effort: Balanced
2 of 3 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
download_assetschecks the MD5 of an existing cached asset on every call. The check currently reads the entire file into a Python bytes object. Stream the same digest in 1 MiB chunks so validation does not require a file-sized buffer.Motivation and Context
The catalog's
vehicles.mp4is 35,345,757 bytes. On macOS with Python 3.11.17, five warmed cacheddownload_assets(VideoAssets.VEHICLES)calls produced these medians, using the same verified video and environment in a fresh process per revision:This is a 94% reduction in traced Python allocation for this path. Timing is included for context; these measurements support a memory improvement, with no speedup claim. They measure cached hash validation rather than process RSS or video decoding. No network requests occurred during the measured calls. The catalog MD5 matched on both revisions.
Minimal local reproduction after downloading the asset once:
Changes Made
Testing
Changelog integration update (20 November 2026): merged
f094e33eand retained the #3031, #2954 and #2956 entries. The MD5 implementation and its tests are unchanged. Two complete local runs each finished with 7,571 passed / 283 skipped; fullpre-commit run --all-filesalso passed twice. Hosted CI results are a separate gate.Earlier validation of the original MD5 change:
pytest --cov=supervision --cov-report=xml: 7,542 passed, 283 skipped. The baseline had 7,524 passed and the same skips; every baseline test retained its outcome.pytest tests/assets/test_downloader.py tests/assets/test_list.py -q: 38 passed.UV_NO_SYNC=1 pre-commit run --all-files: passed, including mypy.The allocation test also passed with
PYTHONTRACEMALLOC=1; pre-existing parent tracing and an earlier object's traceback remained intact.Final tests reject the original full-buffer implementation, a first-chunk-only implementation and an implementation that retains all chunks before hashing.
Added/updated tests, and the full suite passes locally
Updated docstrings for the existing helper
Added an entry at the top of
docs/changelog.mdAdditional Notes
Local validation used the default NumPy fallback backend and the documented development/metrics dependencies. Optional framework integrations and hosted platform checks remain separate. Python 3.10-compatible APIs are retained; no dependencies or lockfile changed.
Hosted CI on
d90c81f5The hosted test matrix, integrations and documentation build passed. The links check failed on 50 historical changelog URLs returning HTTP 404; all 50 are already present in the pinned base
cdb0fa0f. The new link to this PR returned HTTP 200 in that same job. The link-check configuration is unchanged.