fix: validate SA3 extraction mode early#516
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes SA3 cluster extraction error handling by validating the extraction mode before importing optional fast_hdbscan dependencies, ensuring invalid modes raise the intended ValueError instead of being masked by an ImportError.
Changes:
- Added early validation for
extractionvalues ("eom"/"leaf") inextract_clusters. - Removed the now-unreachable fallback
elsebranch for invalidextractionafter extraction selection.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #516 +/- ##
=====================================
Coverage 76.9% 76.9%
=====================================
Files 29 29
Lines 3700 3701 +1
=====================================
+ Hits 2846 2847 +1
Misses 854 854
🚀 New features to boost your workflow:
|
|
How does it matter which error bubbles up first? You need both - correct method and dependency. |
|
Good point, thanks. The reason I changed the order is that extraction validation is independent of optional deps, so a typo in extraction currently surfaces as a dependency error and can send users in the wrong direction. My intent was to fail fast on invalid user input first, then only check optional deps for valid extraction paths. That said, I can absolutely switch this if you prefer dependency-first error bubbling here. Happy to update to your preferred behaviour. |
|
It simply does not matter. If you make a typo, fixing it does not help you if you don't have the dependencies. And there's no path in SA3 that would avoid using them. |
This PR fixes the SA3 extraction error path by validating the extraction mode before importing optional clustering dependencies, so unsupported values now raise the expected
ValueErrorimmediately instead of being masked by anImportErrorwhenfast_hdbscanis unavailable; this keeps user-facing errors accurate and aligns runtime behaviour with the existing test expectation.