Skip to content

Make numba dependency optional#405

Open
mschwoer wants to merge 16 commits intomainfrom
reduce_numba
Open

Make numba dependency optional#405
mschwoer wants to merge 16 commits intomainfrom
reduce_numba

Conversation

@mschwoer
Copy link
Contributor

This would be the required changes to have the numba dependency optional. Let me know what you think.

Note that in the first two commits, I removed numba decorators. According to Claude Code, they should not have given any benefit in the first place.

Called the extra "full", as next steps could be to make rdkit optional. But maybe more fine-granular choice of dependencies is desired here?

@mschwoer mschwoer changed the title Reduce numba Make numba dependency optional Jan 28, 2026
@mschwoer mschwoer requested a review from Copilot January 28, 2026 10:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the numba dependency optional to support environments where numba is unavailable or undesired, introducing a new alphabase[full] installation option.

Changes:

  • Introduced a numba_wrapper module that provides fallback implementations when numba is not installed
  • Moved numba from core requirements to optional full dependencies
  • Added test markers to skip numba-dependent tests when the package is not available

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
alphabase/numba_wrapper.py New compatibility module providing fallback decorators and types when numba is unavailable
alphabase/constants/atom.py Replaced direct numba imports with wrapper imports
alphabase/constants/isotope.py Replaced direct numba imports with wrapper imports
alphabase/constants/modification.py Replaced direct numba imports with wrapper imports
alphabase/peptide/fragment.py Replaced direct numba imports with wrapper imports
alphabase/peptide/precursor.py Replaced direct numba imports with wrapper imports
alphabase/protein/fasta.py Replaced direct numba imports with wrapper imports
alphabase/protein/lcp_digest.py Replaced direct numba imports with wrapper imports
alphabase/psm_reader/alphapept_reader.py Removed numba decorators that provided no benefit
alphabase/psm_reader/maxquant_reader.py Removed numba decorators that provided no benefit
alphabase/spectral_library/annotate.py Replaced direct numba imports with wrapper imports
alphabase/spectral_library/translate.py Replaced direct numba imports with wrapper imports
requirements/requirements.txt Removed numba from core dependencies with clarifying comments
requirements/requirements_loose.txt Removed numba and contextlib2 from loose requirements
requirements/requirements_full.txt New file pinning numba version for full installation
requirements/requirements_full_loose.txt New file for unpinned numba requirement
pyproject.toml Added full and full-stable optional dependencies
tests/integration/conftest.py Added pytest marker for skipping tests requiring numba
tests/unit/constants/test_isotope.py Added requires_numba marker
tests/unit/constants/test_modification_functions.py Added requires_numba marker
tests/unit/protein/test_fasta.py Added requires_numba marker
tests/unit/spectral_library/test_annotate.py Added requires_numba marker
tests/test_fragment.py Added requires_numba marker
nbs_tests/conftest.py New conftest to skip notebook tests when numba unavailable
nbs_tests/test_thread.ipynb Removed test notebook that directly used numba
README.md Updated installation instructions for optional numba dependency
.github/workflows/pip_installation.yml Added test jobs for both with and without numba installation
.github/workflows/branch-checks.yaml Updated to test both full and not-full installations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.



@numba.njit
def truncate_isotope(isotopes: np.ndarray, mono_idx: int) -> tuple:
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @numba.njit decorator was removed from truncate_isotope, but this function is still called from numba-compiled code in reset_elements. When numba is installed, numba cannot compile calls to undecorated functions. This will cause compilation errors in reset_elements when numba is available.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yikes.. fixed this using a conditional decorator

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