fix: fall back to HuggingFace for local encoder paths when sentence-transformers is absent#701
Open
sunnyguntuka wants to merge 1 commit into
Open
Conversation
…ransformers is absent
Coverage Report for CI Build 27662659891Warning No base build found for commit Coverage: 92.489%Details
Uncovered Changes
Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
Author
|
Hi @yzhao062 - gentle ping on this one whenever you have a moment. It's a small follow-up to #696 that closes the Codex review comment from #700: on a pyod[huggingface]-only install, a local model path now falls back to the HuggingFace backend instead of raising ImportError, with tests that run without sentence-transformers or torch. CI is green and patch coverage is ~98%. Happy to rebase or adjust anything if it'd help before merge. Thanks for all the work on PyOD! |
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.
Follow-up to #696. Resolves the Codex review comment on release PR #700.
Problem
In resolve_encoder, the local-path branch forced the SentenceTransformer backend unconditionally. On a pyod[huggingface]-only install (no sentence-transformers), passing a local model path raised ImportError before the existing HuggingFace fallback could run - a regression for local-path usage in HF-only environments.
Fix
The local-path branch now tries the SentenceTransformer backend first and, on ImportError, falls back to the HuggingFace backend (mirroring the existing auto-resolve pattern below it). If neither backend is available it raises a clear ImportError with install hints. Both backends load from a local directory without any Hub/network call.
Tests
Adds TestLocalPathEncoderFallback (resolver fallback control flow with _create_encoder mocked) and TestSentenceTransformerEncoderLoading (encoder local-path / remote / pre-instantiated / bad-type loading branches via a fake SentenceTransformer). All new tests run without sentence-transformers or torch installed.
No breaking API changes.
All Submissions Basics:
All Submissions Cores: