Skip to content

fix: catch RuntimeError during numba import fallback#86

Merged
florent-pajot merged 6 commits intomainfrom
fix/handle-numba-runtime-error
Feb 17, 2026
Merged

fix: catch RuntimeError during numba import fallback#86
florent-pajot merged 6 commits intomainfrom
fix/handle-numba-runtime-error

Conversation

@florent-pajot
Copy link
Contributor

Summary

  • When numba is installed but cannot initialize its cache (e.g., read-only filesystem in Docker containers), it raises RuntimeError instead of ImportError
  • The except ImportError clause in slicefinder.py did not catch this, causing the import to crash instead of falling back to NumPy
  • Changed to except (ImportError, RuntimeError) so both failure modes gracefully disable numba acceleration

Context

This was observed in production with tr-lucene-finder==0.7.0 (which depends on sliceline==0.3.0). The Docker job environment has numba installed but the filesystem doesn't allow cache writes, producing:

RuntimeError: cannot cache function 'score_slices_numba': no locator available for file '.../sliceline/_numba_ops.py'

Test plan

  • Added TestNumbaFallback test class with 3 tests covering RuntimeError, ImportError, and Slicefinder functionality without numba
  • All 74 existing tests pass

🤖 Generated with Claude Code

When numba is installed but cannot initialize its cache (e.g., on
read-only filesystems in Docker), it raises RuntimeError instead of
ImportError. The except clause now catches both exception types to
gracefully fall back to the NumPy implementation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
adedaran
adedaran previously approved these changes Feb 16, 2026
Remove tests that only verify Python try/except works. Keep the
functional test that validates Slicefinder produces correct results
with NUMBA_AVAILABLE=False.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
adedaran
adedaran previously approved these changes Feb 16, 2026
Notebook depends on OpenML API which causes flaky CI due to rate
limiting. The notebook is a demo artifact, not a test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@florent-pajot florent-pajot merged commit 2688b6d into main Feb 17, 2026
8 checks passed
@florent-pajot florent-pajot deleted the fix/handle-numba-runtime-error branch February 17, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants