refactor: unify env var helpers and remove magic slice in cache

- Add _getenv_num as shared core for _getenv_int/_getenv_float
- Add _getenv_optional_float for FRIGATE_SCORE_CEILING (replaces 9-line inline block)
- Add _getenv_bool; replace 11 inline .lower()-in-("true","1","yes") sites
  across config.py, jobs.py, and cli.py with single call site
- _resolve_strategy no-embedding branch: inline try/except → _getenv_int("LIMIT", 30)
- cache.py: final[:-4] → final.removesuffix(".npy") — assumption is now explicit
This commit is contained in:
2026-06-15 02:10:00 +00:00
parent fe5e1574ac
commit de6804226d
6 changed files with 54 additions and 42 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ class EmbeddingCache:
final = self._path(asset_id, model)
# Insert .tmp before .npy so np.save doesn't auto-append another .npy extension
# (np.save appends .npy to paths that don't already end in .npy).
tmp = final[:-4] + ".tmp.npy"
tmp = final.removesuffix(".npy") + ".tmp.npy"
try:
np.save(tmp, embedding)
os.replace(tmp, final)