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:
@@ -33,9 +33,12 @@ def _model_is_loadable(path: str) -> bool:
|
||||
|
||||
vgsl.TorchVGSLModel.load_model(path)
|
||||
return True
|
||||
except Exception as e:
|
||||
except (RuntimeError, OSError, ValueError) as e:
|
||||
log.warning("Model at %s failed to load: %s", path, e)
|
||||
return False
|
||||
except Exception:
|
||||
log.debug("Unexpected error loading model at %s", path, exc_info=True)
|
||||
return False
|
||||
|
||||
|
||||
def _download_blla() -> str:
|
||||
|
||||
Reference in New Issue
Block a user