Files
VoiceStudio/tests/test_segmented_download_default.py
T
b7cecde57e feat(setup): faster downloads by default + prominent, encouraged HF-token entry (#669)
Two changes that make first-run downloads faster and easier to speed up further.

1. Segmented (multi-connection) downloader is now ON by default. The app forces
   the legacy-LFS path (HF_HUB_DISABLE_XET=1) for clear progress, but that path
   is single-stream and slow — which is why downloads felt sluggish. The built-in
   IDM/uGet-style segmented accelerator (parallel byte-ranges, live speed/ETA)
   was already implemented but defaulted OFF. Flip it ON: it only engages when
   Xet is inactive (the default), and ANY failure falls back to snapshot_download
   ("can never compromise a correct install"). Pure-httpx, cross-platform,
   auth-safe (token never forwarded to a CDN). Override with
   OMNIVOICE_SEGMENTED_DOWNLOAD=0.

2. The Hugging Face token field is now a prominent, always-visible card right
   above Continue — was a collapsed "advanced" fold almost nobody opened. A free
   token gives authenticated downloads (higher rate limits, fewer stalls), so it
   pairs with change #1 to keep the parallel fetch from getting throttled. The
   card leads with the speed benefit, shows a saved-state, and adds a one-click
   "Get one free →" link to huggingface.co/settings/tokens.

Docs: downloading-models.md updated — the legacy-LFS section now documents the
default-on segmented accelerator + the HF-token speed tip, and the tuning table
reflects OMNIVOICE_SEGMENTED_DOWNLOAD=0 as the disable knob (docs-sync).

Test: test_segmented_download_default.py pins the new default ON and that the
env override still disables it; existing FDL-08 behavior tests stay green.

Co-authored-by: mergetest <test@local>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 12:35:57 +05:30

31 lines
1.2 KiB
Python

"""FDL-09: the segmented (multi-connection) downloader is ON by default.
The app forces the legacy-LFS path (HF_HUB_DISABLE_XET=1) for clear progress,
which is single-stream and slow. The segmented accelerator restores parallel
byte-range speed with a safe fallback to snapshot_download — so it ships ON by
default for fast first-run downloads. This pins the default so it can't silently
regress to opt-in, and that the env override still disables it.
"""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "backend"))
from api.routers.setup.download import _segmented_enabled # noqa: E402
def test_segmented_is_on_by_default(monkeypatch):
monkeypatch.delenv("OMNIVOICE_SEGMENTED_DOWNLOAD", raising=False)
assert _segmented_enabled() is True
def test_env_override_can_disable(monkeypatch):
monkeypatch.setenv("OMNIVOICE_SEGMENTED_DOWNLOAD", "0")
assert _segmented_enabled() is False
def test_env_override_truthy_keeps_it_on(monkeypatch):
for val in ("1", "true", "on", "yes"):
monkeypatch.setenv("OMNIVOICE_SEGMENTED_DOWNLOAD", val)
assert _segmented_enabled() is True