Skip to content

Commit 186a9d4

Browse files
authored
nn_descent import issues (#499)
* import early * release note
1 parent 7a4c5f3 commit 186a9d4

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

docs/release-notes/0.13.5.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
### 0.13.5 {small}`the-future`
2+
3+
```{rubric} Features
4+
```
5+
6+
```{rubric} Performance
7+
```
8+
* Improves `pp.neighbors` performance with `all_neighbors` and `nn_descent` when a Dask cluster is active {pr}`499` {smaller}`S Dicks`
9+
10+
11+
```{rubric} Bug fixes
12+
```
13+
14+
15+
```{rubric} Misc
16+
```

docs/release-notes/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Release notes
44

55
## Version 0.13.0
6+
```{include} /release-notes/0.13.5.md
7+
```
68
```{include} /release-notes/0.13.4.md
79
```
810
```{include} /release-notes/0.13.3.md

src/rapids_singlecell/preprocessing/_neighbors/_algorithms/_all_neighbors.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
from rapids_singlecell.preprocessing._neighbors._helper import _compute_nlist
99

10+
try:
11+
from cuvs.neighbors import all_neighbors
12+
except ImportError:
13+
all_neighbors = None
1014
if TYPE_CHECKING:
1115
from collections.abc import Mapping
1216

@@ -22,9 +26,7 @@ def _all_neighbors_knn(
2226
metric_kwds: Mapping,
2327
algorithm_kwds: Mapping,
2428
) -> tuple[cp.ndarray, cp.ndarray]:
25-
try:
26-
from cuvs.neighbors import all_neighbors
27-
except ImportError:
29+
if all_neighbors is None:
2830
raise ImportError(
2931
"The 'all_neighbors' algorithm is only available in cuvs >= 25.10. "
3032
"Please update your cuvs installation."

src/rapids_singlecell/preprocessing/_neighbors/_algorithms/_nn_descent.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
from typing import TYPE_CHECKING
44

55
import cupy as cp
6-
from packaging.version import parse as parse_version
76

87
if TYPE_CHECKING:
98
from collections.abc import Mapping
109

1110
from rapids_singlecell.preprocessing._neighbors import _Metrics
1211

1312

13+
try:
14+
from cuvs.neighbors import nn_descent
15+
except ImportError:
16+
nn_descent = None
17+
18+
1419
def _nn_descent_knn(
1520
X: cp.ndarray,
1621
Y: cp.ndarray,
@@ -20,14 +25,11 @@ def _nn_descent_knn(
2025
metric_kwds: Mapping,
2126
algorithm_kwds: Mapping,
2227
) -> tuple[cp.ndarray, cp.ndarray]:
23-
from cuvs import __version__ as cuvs_version
24-
25-
if parse_version(cuvs_version) <= parse_version("24.12"):
26-
raise ValueError(
28+
if nn_descent is None:
29+
raise ImportError(
2730
"The 'nn_descent' algorithm is only available in cuvs >= 25.02. "
2831
"Please update your cuvs installation."
2932
)
30-
from cuvs.neighbors import nn_descent
3133

3234
# Extract intermediate_graph_degree from algorithm_kwds, with default
3335
intermediate_graph_degree = algorithm_kwds.get("intermediate_graph_degree", None)

0 commit comments

Comments
 (0)