Skip to content

[utils] Only read a hash of 8+ hex digits from the file name in download_from_url - #2209

Merged
felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:download-hash-in-file-name
Oct 31, 2026
Merged

felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:download-hash-in-file-name

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

…oad_from_urlWhen no hash is given, download_from_url reads one from the file name with -([a-f0-9]*)\.. That also matches
short runs of hex digits that are part of the name, so for a URL ending in checkpoint-10.pt or model-face.pt,
"10" or "face" is taken as the hash. The SHA256 never starts with it, so a correct download is deleted and
reported as corrupted. This happens with load_pretrained_params(model, url) on your own checkpoints.

The hash in docTR file names is always 8 hex digits (e.g. db_resnet50-79bd7d70.pt), so the pattern now needs
at least 8. Tests: names without a hash load the cached file without downloading, and a hashed name is still checked.

@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.78%. Comparing base (c828139) to head (c1fd001).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2209      +/-   ##
==========================================
+ Coverage   97.76%   97.78%   +0.01%     
==========================================
  Files         170      170              
  Lines       10982    10986       +4     
==========================================
+ Hits        10737    10743       +6     
+ Misses        245      243       -2     
Flag Coverage Δ
unittests 97.78% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@felixdittrich92 felixdittrich92 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍🏼

@felixdittrich92 felixdittrich92 self-assigned this Oct 31, 2026
@felixdittrich92 felixdittrich92 added this to the 1.2.0 milestone Oct 31, 2026
@felixdittrich92 felixdittrich92 added type: enhancement Improvement module: utils Related to doctr.utils ext: tests Related to tests folder labels Oct 31, 2026
@felixdittrich92
felixdittrich92 merged commit 575d69a into mindee:main Oct 31, 2026
56 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext: tests Related to tests folder module: utils Related to doctr.utils type: enhancement Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants