music-assistant-server

Branch:dev-lidarr-plugin

Commit Details

Stop the CLAP weights download from timing out sonic_analysis setup (#6053)

# What does this implement/fix?

`sonic_analysis` fails to set up with `Provider sonic_analysis did not
initialize within 300 seconds`.

Setting the provider up downloads the ~690 MB CLAP checkpoint, and that
download runs inside `PROVIDER_ASYNC_INIT_TIMEOUT = 300`. On a slow
link, or a busy host, it does not finish in time and setup fails.

From there it compounds instead of recovering:

- The download and the model build cannot be cancelled, so each retry
starts another one on top of the last. They serialise on
`huggingface_hub`'s file lock, so every attempt times out in turn, and
each one that does get through goes on to build a full CLAP model — on
hosts admitted at 4 GB of RAM.
- The failure surfaces as an untyped exception, so MA reads it as a bug
rather than a transient fault and never retries. A flaky connection
leaves the provider dead until it is reloaded by hand.
- A second, hidden download can run in the same step: when the shipped
prompt embeddings are missing or stale, the loader fell back to a
text-enabled model, which pulls the GPT2 text encoder.

After this change a setup attempt that gives up leaves the work running,
the next attempt joins it instead of repeating it, a failure on a bad
connection is retried, and setup never has more than one download or one
model build in flight.

No new dependency: `httpx` is named only for the transport errors
`huggingface_hub` re-raises, and it already ships as a hard requirement
of the `huggingface-hub` pin the provider declares.

**Related issue (if applicable):**

- none filed

## Types of changes

- [x] Bugfix (non-breaking change which fixes an issue) — `bugfix`
- [ ] New feature (non-breaking change which adds functionality) —
`new-feature`
- [ ] Enhancement to an existing feature — `enhancement`
- [ ] New music/player/metadata/plugin provider — `new-provider`
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected) — `breaking-change`
- [ ] Refactor (no behaviour change) — `refactor`
- [ ] Documentation only — `documentation`
- [ ] Maintenance / chore — `maintenance`
- [ ] CI / workflow change — `ci`
- [ ] Dependencies bump — `dependencies`

## Checklist

- [x] The code change is tested and works locally.
- [x] `pre-commit run --all-files` passes.
- [x] `pytest` passes, and tests have been added/updated under `tests/`
where applicable.
- [ ] For changes to shared models, the companion PR in
`music-assistant/models` is linked.
- [ ] For changes affecting the UI, the companion PR in
`music-assistant/frontend` is linked.
- [x] I have read and complied with the project's [AI
Policy](https://github.com/music-assistant/.github/blob/main/AI_POLICY.md)
for any AI-assisted contributions.
- [ ] I have [raised a PR against the documentation
repository](https://github.com/music-assistant/music-assistant.io/blob/main/CONTRIBUTING.md)
targeting the main or beta branch as appropriate.

---------

Co-authored-by: Marcel van der Veldt <[email protected]>
Forgejo

Author

August 28, 2026 at 10:38 PM UTC

Committer

Marcel van der Veldt<[email protected]>
August 29, 2026 at 12:28 AM UTC
382additions
21deletions
7files changed

Parent commits

Changes

7 files
+382-21

Changed Files (7)

music_assistant/providers/sonic_analysis/
music_assistant/translations/
tests/providers/sonic_analysis/
music_assistant/providers/sonic_analysis/__init__.py
+60-21
music_assistant/providers/sonic_analysis/manifest.json
music_assistant/providers/sonic_analysis/strings.json
music_assistant/translations/en.json
tests/providers/sonic_analysis/test_clap_background_load.py
tests/providers/sonic_analysis/test_load_clap_cache.py
tests/providers/sonic_analysis/test_model_setup.py
+322