Skip to content

The agent that grows with you

fix(stt): only rewrap Hub/network failures on the whisper download path

teknium1489ad839072a
diff --git a/tests/tools/test_transcription_tools.py b/tests/tools/test_transcription_tools.py
index 539dbbb857f..8494627d264 100644
--- a/tests/tools/test_transcription_tools.py
+++ b/tests/tools/test_transcription_tools.py
@@ -364,11 +364,14 @@ class TestLocalModelLoading:
"base", local_files_only=True, device="cpu", compute_type="int8"
)
- @pytest.mark.parametrize("download_error", [None, RuntimeError("ConnectTimeout")])
+ @pytest.mark.parametrize("download_error", [None, "Got: ConnectTimeout: [Errno 110] Connection timed out"])
def test_cache_miss_falls_back_with_actionable_download_failure(self, download_error):
from huggingface_hub.errors import LocalEntryNotFoundError
from tools.transcription_local import _create_whisper_model
+ if download_error:
+ download_error = LocalEntryNotFoundError(download_error)
+
downloaded_model = object()
online_result = download_error or downloaded_model
side_effect = [LocalEntryNotFoundError("not cached"), online_result]
diff --git a/tools/transcription_local.py b/tools/transcription_local.py
index 06ff8301109..7fb966e4c97 100644
--- a/tools/transcription_local.py
+++ b/tools/transcription_local.py
@@ -131,9 +131,12 @@ def _create_whisper_model(model_name: str, *, device: str, compute_type: str):
except LocalEntryNotFoundError:
logger.info("faster-whisper model '%s' is not cached; downloading it from the Hugging Face Hub", model_name)
+ # huggingface_hub surfaces every Hub/network failure as an OSError subclass
+ # (LocalEntryNotFoundError wrapping the ConnectTimeout, HfHubHTTPError). Anything else
+ # (CUDA runtime, invalid model size) is not a download problem and propagates untouched.
try:
return WhisperModel(model_name, local_files_only=False, **kwargs)
- except Exception as exc:
+ except OSError as exc:
raise RuntimeError(
f"Unable to download faster-whisper model '{model_name}': {exc}. "
"If huggingface.co is unreachable, set HF_ENDPOINT to an accessible mirror; "