Skip to content

Support HF_HOME and HF_ENDPOINT#179

Merged
akshayballal95 merged 2 commits into
StarlightSearch:devfrom
DayNice:feature/envs-hf-home-and-hf-endpoint
Oct 21, 2025
Merged

Support HF_HOME and HF_ENDPOINT#179
akshayballal95 merged 2 commits into
StarlightSearch:devfrom
DayNice:feature/envs-hf-home-and-hf-endpoint

Conversation

@DayNice
Copy link
Copy Markdown
Contributor

@DayNice DayNice commented Oct 21, 2025

Changed constructor calls for hf_hub::api::sync::ApiBuilder from ApiBuilder::new into ApiBuilder::from_env. Affected files are as follows.

rust/src/embeddings/local
├── bert.rs
├── clip.rs
├── jina.rs
├── modernbert.rs
└── qwen3.rs

Checked that the following tests succeed.

Python tests

pytest -x tests/model_tests/test_bert.py \
  tests/model_tests/test_clip.py \
  tests/model_tests/test_jina.py

Rust tests

cargo test embeddings::local::bert \
&& cargo test embeddings::local::jina \
&& cargo test embeddings::local::modernbert  \
&& cargo test embeddings::local::qwen3

Note that the following test for clip was already failing before this change was introduced.

cargo test embeddings::local::clip
#    Compiling embed_anything v0.6.5 (/home/daynice/repo/EmbedAnything/rust)
#     Finished `test` profile [unoptimized + debuginfo] target(s) in 1.53s
#      Running unittests src/lib.rs (/home/daynice/repo/EmbedAnything/target/debug/deps/embed_anything-9357e31b730d5ea8)

# running 4 tests
# test embeddings::local::clip::tests::test_tokenize_sequences ... FAILED
# test embeddings::local::clip::tests::test_load_images ... ok
# test embeddings::local::clip::tests::test_load_image ... ok
# test embeddings::local::clip::tests::test_embed_image_batch ... ok
# 
# failures:
# 
# ---- embeddings::local::clip::tests::test_tokenize_sequences stdout ----
# 
# thread 'embeddings::local::clip::tests::test_tokenize_sequences' panicked at rust/src/embeddings/local/clip.rs:375:9:
# assertion `left == right` failed
#   left: [2, 77]
#  right: [2, 8]
# note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
# 
# 
# failures:
#     embeddings::local::clip::tests::test_tokenize_sequences
# 
# test result: FAILED. 3 passed; 1 failed; 0 ignored; 0 measured; 17 filtered out; finished in 9.69s
# 
# error: test failed, to rerun pass `--lib`

Closes #178

@DayNice
Copy link
Copy Markdown
Contributor Author

DayNice commented Oct 21, 2025

Checked that HF_HOME now works.

export HF_HOME=/tmp/hf_home

hf cache scan
# Cache directory not found: /tmp/hf_home/hub

# trigger local caching
cargo test embeddings::local::bert

hf cache scan
# REPO ID                                REPO TYPE SIZE ON DISK NB FILES LAST_ACCESSED  LAST_MODIFIED  REFS LOCAL PATH
# -------------------------------------- --------- ------------ -------- -------------- -------------- ---- ----------------------------------------------------------------
# sentence-transformers/all-MiniLM-L6-v2 model            91.3M        3 33 seconds ago 33 seconds ago main /tmp/hf_home/hub/models--sentence-transformers--all-MiniLM-L6-v2
# 
# Done in 0.0s. Scanned 1 repo(s) for a total of 91.3M.

@akshayballal95
Copy link
Copy Markdown
Collaborator

Works perfect! Fixed the issue with the test as well. Thanks for the contribution!

@akshayballal95 akshayballal95 merged commit 3ed0b38 into StarlightSearch:dev Oct 21, 2025
4 checks passed
@DayNice DayNice deleted the feature/envs-hf-home-and-hf-endpoint branch October 27, 2025 11:55
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.

2 participants