User-configurable model directory - #987
Open
Josef-Haupt wants to merge 1 commit into
Open
Conversation
…cal AppData The birdnet library resolves its model directory from BIRDNET_APP_DATA once, at import time. settings.apply_model_directory() now runs at package import - before anything can import birdnet - and decides it for every entry point: 1. An already-set BIRDNET_APP_DATA wins and fails fast when unusable (automation wants determinism, not fallbacks). 2. The directory picked in the GUI's settings tab (gui-settings.json) is applied in any run mode; when it is unavailable at startup (e.g. an unplugged data drive) the default is used for the session and the GUI shows a warning. 3. Otherwise the frozen app defaults to %LOCALAPPDATA%\BirdNET-Analyzer-GUI\ models - models are a multi-GB re-downloadable cache that must not sync with domain roaming profiles, unlike the small settings/state/logs in Roaming. From source or Docker the library's own default stands, so pip installs, CI caches and the baked Docker image keep their model stores. The settings tab gets the directory field with select/reset buttons. A picked directory is probed with a real test write: unusable ones are rejected, read-only but populated ones are accepted with a warning (a pre-seeded field setup is valid - analysis works, downloads don't), and under 2 GB free space a warning notes that a first model download may not fit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
The birdnet library resolves its model directory from
BIRDNET_APP_DATAonce, at import time.settings.apply_model_directory()now runs at package import — before anything can import birdnet — and decides the directory for every entry point (GUI, CLIs, frozen, source, Docker):BIRDNET_APP_DATAwins, and fails fast with a clear message when the path is unusable — automation (CI, field deployments, Docker) wants determinism, not fallbacks.gui-settings.json) applies in any run mode. If it is unavailable at startup — the classic case: the data drive isn't plugged in — the default is used for the session and the GUI shows a warning instead of crashing insideimport birdnet.%LOCALAPPDATA%\BirdNET-Analyzer-GUI\models. Models are a multi-GB re-downloadable cache and must not sync with domain roaming profiles; the small settings/state/logs stay in Roaming. From source or Docker nothing changes: the library's own default stands, so pip installs, CI caches and the baked Docker image keep their existing model stores.Picking a directory probes it with a real test write (Windows
os.accesslies about ACLs): unusable → rejected; read-only but populated → accepted with a warning, since a pre-seeded read-only field setup is valid (analysis works, downloads don't); under 2 GB free → a warning that a first model download may not fit.Nine new localization keys across all 11 languages. The PyInstaller runtime hook in the build repo shrinks to
GUI_VERSIONonly (companion change there).Verification
tests/test_model_directory.pycovers the precedence (env > setting > frozen default > library default), the fail-fast env case, the fallback warning, and the probe verdicts; a subprocess test proves the resolver runs at package import (verified to fail when the__init__call is removed).Note: merges independently of #981, but both touch
gui/utils.py(open_window) — whichever goes second may need a trivial conflict resolution.🤖 Generated with Claude Code