add backends - #4108
Conversation
❌ 2 Tests Failed:
View the top 2 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
# 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
left a comment
There was a problem hiding this comment.
looks good! I didn’t look at the test yet (I will once you mark it ready for review)
| 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) |
There was a problem hiding this comment.
this should be removed, sc.settings.override(backend=...) exists, and if it doesn’t work for some reason, we should fix that
| 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) |
There was a problem hiding this comment.
Why does this exist? Does the user ever need to access the backend object?
| return FakeRapidsBackend | ||
|
|
||
|
|
||
| DISPATCHED_FUNCTIONS = [ |
There was a problem hiding this comment.
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.
| "pynndescent>=0.5.13", | ||
| "scikit-learn>=1.6", | ||
| "scipy>=1.15", | ||
| "scverse-backends>=0.0.3,<0.1", |
There was a problem hiding this comment.
this has no dependencies right?
There was a problem hiding this comment.
No None. I'll also remove the pin
Co-authored-by: Philipp A. <flying-sheep@web.de>
| host_name="scanpy", | ||
| trusted_backends={ | ||
| "rapids-singlecell": { | ||
| "aliases": ["cuda", "rapids", "rapids_singlecell"], |
There was a problem hiding this comment.
Does it make sense to have that many aliases that mean the same thing? Could be confusing.
I think aliases are mostly useful for backwards-compatibility.
Summary
sc.get.aggregate.scverse-backends>=0.0.3and exercise its lazy entry-point discovery and automatic backend-parameter signature injection.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_conventionsuv run --group test pytest -q tests/test_aggregated.py tests/test_pca.py tests/test_embedding.py tests/test_rank_genes_groups.py