Skip to content

Commit 5afba0b

Browse files
committed
update mmdetection 3 test numpy error
1 parent 7a527a6 commit 5afba0b

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

label_studio_ml/examples/mmdetection-3/Dockerfile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,29 @@ COPY requirements.txt .
5555
RUN --mount=type=cache,target=${PIP_CACHE_DIR},sharing=locked \
5656
pip install -r requirements.txt
5757

58-
# Install test requirements if needed
58+
# Install test requirements if needed (install before mim to ensure numpy is available)
5959
COPY requirements-test.txt .
6060
# build only when TEST_ENV="true"
6161
RUN --mount=type=cache,target=${PIP_CACHE_DIR},sharing=locked \
6262
if [ "$TEST_ENV" = "true" ]; then \
6363
pip install -r requirements-test.txt; \
6464
fi
6565

66-
RUN mim install mmengine==0.10.3
67-
RUN mim install mmcv==2.1.0
68-
RUN mim install mmdet==3.3.0
66+
# Ensure numpy is available and pinned before mim installs (mim packages may depend on it)
67+
RUN python -c "import numpy; print(f'numpy version: {numpy.__version__}')" || pip install "numpy~=1.26"
68+
69+
# Install mim packages, but prevent numpy from being upgraded
70+
RUN mim install mmengine==0.10.3 && \
71+
mim install mmcv==2.1.0 && \
72+
mim install mmdet==3.3.0 && \
73+
pip install --force-reinstall --no-deps "numpy~=1.26" || true
6974
RUN mim download mmdet --config yolov3_mobilenetv2_8xb24-320-300e_coco --dest .
7075

7176
COPY . .
7277

78+
# Final verification that numpy is available (important for tests)
79+
RUN python -c "import numpy; print(f'✓ numpy {numpy.__version__} is available')" || (echo "ERROR: numpy is not available!" && exit 1)
80+
7381
EXPOSE 9090
7482

7583
CMD gunicorn --preload --bind :$PORT --workers $WORKERS --threads $THREADS --timeout 0 _wsgi:app
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pytest
22
pytest-cov
3+
numpy~=1.26

label_studio_ml/examples/mmdetection-3/test_model.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import requests
22

3+
# Ensure numpy is available before importing mmdetection (which depends on mmdet)
4+
try:
5+
import numpy
6+
except ImportError:
7+
raise ImportError("numpy is not available. Please install numpy before running tests.")
8+
39
from mmdetection import MMDetection
410

511
from label_studio_ml.utils import compare_nested_structures

0 commit comments

Comments
 (0)