Skip to content

add backends - #4108

Draft
Intron7 wants to merge 9 commits into
mainfrom
add-scverse-backends
Draft

add backends#4108
Intron7 wants to merge 9 commits into
mainfrom
add-scverse-backends

Conversation

@Intron7

@Intron7 Intron7 commented May 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Add Scanpy backend dispatch for RAPIDS single-cell across preprocessing, tools, and sc.get.aggregate.
  • Require scverse-backends>=0.0.3 and exercise its lazy entry-point discovery and automatic backend-parameter signature injection.
  • Rebase the branch onto current main, preserving upstream API changes alongside dispatch decorators.

Validation

  • uv run --group test pytest -q tests/test_backends.py tests/test_package_structure.py::test_sig_conventions
  • uv run --group test pytest -q tests/test_aggregated.py tests/test_pca.py tests/test_embedding.py tests/test_rank_genes_groups.py

@codecov

codecov Bot commented May 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.32%. Comparing base (3d01c78) to head (f6aa654).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4108      +/-   ##
==========================================
+ Coverage   79.21%   79.32%   +0.10%     
==========================================
  Files         128      130       +2     
  Lines       13446    13516      +70     
==========================================
+ Hits        10651    10721      +70     
  Misses       2795     2795              
Flag Coverage Δ
hatch-test.low-vers 77.57% <100.00%> (+0.11%) ⬆️
hatch-test.pre 79.19% <100.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/scanpy/_backends.py 100.00% <100.00%> (ø)
src/scanpy/_settings/__init__.py 96.49% <100.00%> (+0.37%) ⬆️
src/scanpy/get/_aggregated.py 95.28% <100.00%> (+0.03%) ⬆️
src/scanpy/neighbors/__init__.py 82.32% <100.00%> (+0.08%) ⬆️
src/scanpy/preprocessing/_harmony/__init__.py 86.84% <100.00%> (+0.73%) ⬆️
src/scanpy/preprocessing/_highly_variable_genes.py 94.66% <100.00%> (+0.03%) ⬆️
src/scanpy/preprocessing/_normalization.py 94.80% <100.00%> (+0.13%) ⬆️
src/scanpy/preprocessing/_pca/__init__.py 91.61% <100.00%> (+0.10%) ⬆️
src/scanpy/preprocessing/_qc.py 95.91% <100.00%> (+0.05%) ⬆️
src/scanpy/preprocessing/_scale.py 89.79% <100.00%> (+0.21%) ⬆️
... and 12 more

Intron7 added 3 commits July 23, 2026 18:06
# Conflicts:
#	pyproject.toml
#	src/scanpy/get/_aggregated.py
#	src/scanpy/preprocessing/_pca/__init__.py
#	src/scanpy/tools/_diffmap.py
#	src/scanpy/tools/_embedding_density.py
#	src/scanpy/tools/_rank_genes_groups.py

@flying-sheep flying-sheep left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good! I didn’t look at the test yet (I will once you mark it ready for review)

Comment thread src/scanpy/_settings/__init__.py Outdated
Comment on lines +186 to +190
def use_backend(self, backend: str):
"""Temporarily set the active computational backend."""
from .._backends import settings as backend_settings

return backend_settings.use_backend(backend)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this should be removed, sc.settings.override(backend=...) exists, and if it doesn’t work for some reason, we should fix that

Comment thread src/scanpy/_settings/__init__.py Outdated
Comment on lines +198 to +202
def get_backend(self, name: str):
"""Look up an installed computational backend by name or alias."""
from .._backends import settings as backend_settings

return backend_settings.get_backend(name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why does this exist? Does the user ever need to access the backend object?

Comment thread src/scanpy/_backends.py Outdated
Comment thread tests/test_backends.py Outdated
return FakeRapidsBackend


DISPATCHED_FUNCTIONS = [

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don’t want to keep this in sync. Can’t the decorator just populate a list that we can access here?

One thing to note is that it probably can’t just put its function argument in the list, as other decorators might be applied after this one.

Comment thread pyproject.toml Outdated
"pynndescent>=0.5.13",
"scikit-learn>=1.6",
"scipy>=1.15",
"scverse-backends>=0.0.3,<0.1",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this has no dependencies right?

@Intron7 Intron7 Jul 31, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No None. I'll also remove the pin

Intron7 and others added 2 commits July 31, 2026 09:58
@Intron7 Intron7 added this to the 1.13.0 milestone Jul 31, 2026
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