Skip to content

Load Whisper at startup; lock dependencies with uv - #43

Merged
pungoyal merged 2 commits into
mainfrom
uv-and-whisper-warmup
Oct 29, 2026
Merged

pungoyal merged 2 commits into
mainfrom
uv-and-whisper-warmup

Conversation

@pungoyal

@pungoyal pungoyal commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Whisper loads at startup. It used to load on the first voice note after every deploy. Now Bot.run() loads it on a background thread and logs whisper loaded seconds=…. A voice note that arrives during the load waits for that same load.

The production logs show that loading wasn't the main cost. For the 17.3 s voice note on 28 Oct, the model loaded in about 1.4 s, and transcribing 1.85 s of audio took about 16 s. Whisper always processes a 30 s window, beam 5 on CPU, so the clip's length barely matters.

Dependencies are locked with uv. uv.lock pins all 40 packages. The image runs uv sync --locked, with uv mounted only for that step and pinned by digest, which replaces the placeholder-package workaround. CI runs the same uv version. The project itself is no longer built: imports come from src.

To change a dependency: edit pyproject.toml, then run uv lock.

Verified:

  • ruff, 179 tests and actionlint pass.
  • The image builds on arm64.
  • End to end in the image, running as uid 1001: Bot.run() with only Telegram stubbed loaded Whisper, transcribed a real speech clip, replied, and drained.

🤖 Generated with Claude Code

pungoyal and others added 2 commits October 29, 2026 11:21
The bot now loads the Whisper model on a background thread when it starts, so the
first voice note after a deploy no longer waits for it. A voice note that arrives
during the load waits for that same load rather than starting a second one.

Dependencies are now locked in uv.lock (40 packages, including the indirect ones
such as numpy, onnxruntime and ctranslate2). The image installs exactly those
versions with `uv sync --locked`, which also removes the placeholder package the
Dockerfile used to create. CI installs from the same lock, and the dev tools
move to a dependency group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The project is no longer built: imports come from src through PYTHONPATH and
pytest's pythonpath, so setuptools and --no-install-project go. uv is mounted for
the sync instead of copied into the image, and is pinned by digest. CI uses the
same uv version as the image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pungoyal
pungoyal marked this pull request as ready for review October 29, 2026 11:34
@pungoyal
pungoyal merged commit 0b805df into main Oct 29, 2026
2 checks passed
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.

1 participant