Conversation
When EMBEDDING_MODEL_REVISION is unset, the phase-11 prefetch called download-hf-snapshot.py without --revision, so snapshot_download() resolved the repository's mutable default branch. The installed embeddings artifact could silently change between installs, weakening reproducibility and supply-chain integrity (Bandit B615, issue Osmantic#5658). The helper now resolves the default branch to its current commit SHA via HfApi.model_info() and always passes that immutable revision to snapshot_download(). The resolved SHA is printed so the install log records exactly which artifact was prefetched. An explicit --revision still passes through unchanged. Fixes Osmantic#5658.
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.
Why this matters
When
EMBEDDING_MODEL_REVISIONis unset � the default for fresh installs � the phase-11 embeddings prefetch callsdownload-hf-snapshot.pywith no--revision, sosnapshot_download()resolves the repository's mutable default branch. The installed embeddings artifact can silently change between two installs of the same ODS release, weakening reproducibility and supply-chain integrity (Bandit B615, high confidence). Fixes #5658.What changed
ods/scripts/download-hf-snapshot.py� when no revision is given, the helper now resolves the default branch to its current commit SHA viaHfApi().model_info(repo_id).shaand always passes that immutable revision tosnapshot_download(). The resolved SHA is printed so the install log records exactly which artifact was fetched. An explicit--revision(e.g.EMBEDDING_MODEL_REVISION) still passes through unchanged � no caller changes needed.Design choice per the issue's suggested fix: resolve-and-persist a commit SHA before download rather than reject omitted revisions � hard-failing would break every default install, while resolution keeps behavior identical and pins the artifact.
Regression test
test_hf_download_helper.py::test_download_snapshot_pins_resolved_commit_when_revision_omitted� fakeshuggingface_hubwith aHfApireturning a fixed SHA; assertssnapshot_downloadreceivesrevision=<sha>(never absent, never a branch name) and that the SHA is reported on stdout. The existing explicit-revision test still passes unchanged.Overlap check
download-hf-snapshot.py: fix(download): expand user tilde in download-hf-snapshot.py #5559/fix(scripts): expand tilde in cache_dir for download-hf-snapshot #5183/fix(download-hf-snapshot): expand tilde in cache_dir path #2869 (tilde expansion) and fix(download): catch OSError during cache directory creation in download-hf-snapshot.py #2737 (OSError catch) � orthogonal concerns, different code region. fix(embeddings): honor prefetched model revision at runtime #3584 is about runtime honoring the prefetched revision, not the download pin.Validation
download_snapshotwith fakedhuggingface_hub: omitted revision ?snapshot_download(revision=<40-hex sha>), resolution printed; explicitrevision="v1"? passes through. (Environment lacks pytest; the committed pytest test covers the same assertions.)git diff --check: clean