fix(ml): degrade to statistical features on any extractor failure, implement download-models#154
Conversation
…plement download-models extract_features only caught ImportError, but the ResNet18 path also downloads ImageNet weights from download.pytorch.org on first use — in an air-gapped environment that raises URLError/RuntimeError and crashed the whole ml_analysis step instead of falling back. Any extractor failure now degrades to the statistical features with a logged reason. The 'medcheck download-models' stub is now implemented: it pre-caches the weights so local analysis runs fully offline afterwards, and the README documents the one-time download (the previous wording implied no network access at all). Fixes #137 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4svt5QTs4WUMSy4HwiVt9
|
Warning Review limit reached
Next review available in: 26 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Summary
extract_featuresonly caughtImportError("torch not installed"), but the ResNet18 path also downloads ImageNet weights fromdownload.pytorch.orgon first use. In an air-gapped environment — the deployment the "on-device" pitch targets — that download raisesURLError/RuntimeErrorand crashed the wholeml_analysisstep instead of falling back.Fixes #137
Changes
src/medcheck/pipeline/ml_analysis.py: split into_resnet_features/_statistical_features;extract_featuresnow degrades to the statistical fallback on any extractor failure, logging the reasonsrc/medcheck/main.py: implement thedownload-modelsstub — builds the feature extractor once to pre-cache the weights (clear error + exit 1 when torch is missing or the download fails)README.md: document the one-time model download and themedcheck download-modelspre-fetch for offline environments (previous wording implied no network access at all)extract_featuresfallback tests (RuntimeError download failure, ImportError), 2 new CLI tests fordownload-modelsTesting
uv run pytest) — 184 passeduv run pytest --cov-fail-under=85) — 88.28%uv run ruff check .)uv run mypy src/medcheck --strict)🤖 Generated with Claude Code
https://claude.ai/code/session_01W4svt5QTs4WUMSy4HwiVt9
Generated by Claude Code