fix(ocr): narrow exception handling and add unit tests for ensure_blla_model

- _model_is_loadable: narrow bare except to (RuntimeError, OSError, ValueError)
  with DEBUG-level fallback for unexpected exceptions — prevents silent masking
  of missing kraken install or AttributeError on vgsl
- _run_segtrain: replace bare except:pass with log.warning so height-check
  fallback is visible in container logs
- New test_ensure_blla_model.py: covers model-OK early return, incompatible
  model rename+replace, and missing model download paths

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-14 15:24:04 +02:00
parent 9b6b6f4f7e
commit fdae60a528
3 changed files with 75 additions and 3 deletions

View File

@@ -494,8 +494,8 @@ async def segtrain_model(
"will train from scratch at 800px",
_m.input[2],
)
except Exception:
pass
except Exception as exc:
log.warning("Could not inspect base model height, training from scratch: %s", exc)
if use_base_model:
cmd += ["-i", blla_model_path, "--resize", "union", "-s", seg_spec]