Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

test(deps): make the umap smoke test verify the JIT; correct the numba rationale

Lincoln Stein00ac7a6b5820
diff --git a/pyproject.toml b/pyproject.toml
index 72cef74d24..ac87631b38 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -98,8 +98,11 @@ dependencies = [
"PyWavelets",
# Semantic image index (image map / semantic search).
- # numba is a umap-learn transitive; guard its range because numba releases
- # tighten numpy bounds and this project pins numpy<2.0.
+ # numba is a umap-learn transitive, pinned to the range this stack has been
+ # exercised against rather than for numpy compatibility: every release from
+ # 0.59 to at least 0.63 accepts the numpy 1.26.x resolved under numpy<2.0
+ # above (0.62 widened its floor back to >=1.22). Raise the ceiling once a
+ # newer numba has been run against the image map, not just resolved.
"umap-learn~=0.5.7",
"scikit-learn~=1.5",
"numba>=0.59,<0.62",
diff --git a/tests/app/services/image_index/test_umap_import.py b/tests/app/services/image_index/test_umap_import.py
index 2c8be72286..ab109857ba 100644
--- a/tests/app/services/image_index/test_umap_import.py
+++ b/tests/app/services/image_index/test_umap_import.py
@@ -1,16 +1,35 @@
"""Smoke test for the umap-learn / scikit-learn / numba dependency stack.
-The numba/llvmlite install matrix is the most fragile part of these
-dependencies (it is sensitive to the numpy pin), so this test exists to fail
-loudly in CI if resolution or the JIT is broken, before any feature code
-relies on them. The first UMAP fit also JIT-compiles numba kernels, which is
-the slow part — hence the `slow` marker consideration; it typically takes
-tens of seconds on a cold cache.
+The numba/llvmlite install matrix is the most fragile part of these dependencies (it is
+sensitive to the numpy pin), so this test exists to fail loudly in CI if resolution or the JIT
+is broken, before any feature code relies on them.
+
+Not marked `slow`: measured at ~10s cold (numba JIT cache empty) and ~7s warm, which the
+default selection can absorb.
"""
+import numba
import numpy as np
+def test_numba_jit_is_active() -> None:
+ """A working import is not a working JIT.
+
+ UMAP produces correct output with the JIT disabled — numba just runs the kernels as plain
+ Python — so the fit below cannot tell a healthy install from one that silently lost
+ compilation and got orders of magnitude slower. Assert compilation directly.
+ """
+ assert numba.config.DISABLE_JIT == 0, "numba JIT is disabled; UMAP would fall back to Python speed"
+
+ @numba.njit(cache=False)
+ def _add(a: int, b: int) -> int:
+ return a + b
+
+ assert _add(1, 2) == 3
+ # Non-empty only if the call actually compiled a specialization.
+ assert _add.signatures, "numba did not compile the test kernel"
+
+
def test_umap_and_dbscan_smoke() -> None:
from sklearn.cluster import DBSCAN
from umap import UMAP