-
Notifications
You must be signed in to change notification settings - Fork 172
143 lines (138 loc) · 5.49 KB
/
tests.yml
File metadata and controls
143 lines (138 loc) · 5.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Libact tests
on: [push, pull_request]
jobs:
test-with-blas:
name: Test with BLAS/LAPACK (full features)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies
run: |
if [ "$RUNNER_OS" = "macOS" ]; then
brew update
brew install openblas
mkdir -p ~/.matplotlib
echo "backend: TkAgg" >> ~/.matplotlib/matplotlibrc
else
sudo apt-get update -qq
sudo apt-get install -y build-essential gfortran libopenblas-dev liblapacke-dev pkg-config
sudo apt-get install -y python3-dev
fi
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install pylint coverage codecov
- name: Install build tools
run: |
pip install meson-python meson ninja cython numpy
- name: Install libact in editable mode
run: |
pip install --no-build-isolation -e . 2>&1 | tee build.log
- name: Verify optional features were built
run: |
# Check build log for feature messages
if grep -q "Building VarianceReduction" build.log; then
echo "✓ VarianceReduction feature was built"
else
echo "✗ ERROR: VarianceReduction feature was NOT built (expected with BLAS/LAPACK)"
exit 1
fi
if grep -q "Building HintSVM" build.log; then
echo "✓ HintSVM feature was built"
else
echo "✗ ERROR: HintSVM feature was NOT built (expected with BLAS/LAPACK)"
exit 1
fi
# Verify the compiled modules are importable
python -c "from libact.query_strategies._variance_reduction import *; print('✓ _variance_reduction module imports successfully')"
python -c "from libact.query_strategies._hintsvm import *; print('✓ _hintsvm module imports successfully')"
- name: Run unittests
run: |
python -m unittest -v
- name: Run coverage
run: |
coverage run --source libact --omit */tests/* -m unittest
- name: Report coverage
run: |
coverage report
- name: Upload coverage to Codecov
run: |
codecov
test-without-blas:
name: Test without BLAS/LAPACK (minimal install)
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
python-version: ['3.11'] # Test with one Python version to verify minimal install
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install minimal system dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y build-essential python3-dev
# Intentionally NOT installing BLAS/LAPACK to test fallback behavior
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
- name: Install build tools
run: |
pip install meson-python meson ninja cython numpy
- name: Install libact (should skip variance_reduction and hintsvm)
run: |
pip install --no-build-isolation -e . 2>&1 | tee install.log
- name: Verify optional features were skipped
run: |
# Verify warning message appears
if grep -q "BLAS/LAPACK libraries not found" install.log; then
echo "✓ BLAS/LAPACK warning message found (as expected)"
else
echo "✗ WARNING: Expected BLAS/LAPACK warning message not found"
fi
# Verify features were skipped
if grep -q "Skipping VarianceReduction" install.log; then
echo "✓ VarianceReduction was correctly skipped"
else
echo "✗ ERROR: VarianceReduction skip message not found"
exit 1
fi
if grep -q "Skipping HintSVM" install.log; then
echo "✓ HintSVM was correctly skipped"
else
echo "✗ ERROR: HintSVM skip message not found"
exit 1
fi
# Verify the modules don't exist (shouldn't be importable)
python -c "try:
from libact.query_strategies._variance_reduction import *
print('✗ ERROR: _variance_reduction should not be importable without BLAS')
exit(1)
except ImportError:
print('✓ _variance_reduction correctly not available (as expected)')" || exit 1
python -c "try:
from libact.query_strategies._hintsvm import *
print('✗ ERROR: _hintsvm should not be importable without BLAS')
exit(1)
except ImportError:
print('✓ _hintsvm correctly not available (as expected)')" || exit 1
- name: Test basic import
run: |
python -c "from libact.base.dataset import Dataset; print('SUCCESS: Basic import works without BLAS/LAPACK')"
- name: Run basic unittests
run: |
# Run tests but don't fail on tests that require variance_reduction or hintsvm
python -m unittest discover -s libact/base/tests -v || true
python -m unittest discover -s libact/labelers/tests -v || true