Commit ae33df7
meson-python migration + Python 3.12 support + 4 new query strategies (#196)
* 1. Modified _hintsvm.pyx and successfully compiled the source code
2. Modified README.md (changed the order of installing dependencies && changed the installation method)
* Updated plot.py
* Removed unnecessary comment in libact/query_strategies/tests/test_density_weighted_meta.py
* Update README.md and revert unnecessary changes
* Update README.md and libact/base/dataset.py
Current Status: 2 of the tests fail and 1 throws an error
* Fix the NearestNeighbors error in libact/query_strategies/multilabel/cost_sensitive_reference_pair_encoding.py
* Update test cases and specify module versions in requirements.txt
* Update `unittest` and `coverage` usage
Resolve the [Deprecate test command](pypa/setuptools#1684) in `setuptools`.
* Update .gitignore
* Restore plot.py
* Update dataset.py
* Update density_weighted_meta.py
* Update density_weighted_uncertainty_sampling.py
* Update setup.py
* Add support for Python 3.9 and 3.11
* Update README.md
* Update requirements.txt
* Update GitHub workflows
* Added dependency management and meson files
* Finish Migration
* Update README.md and add detection for READTHEDOCS environment
* remove .pdm-python
* Fix meson build configuration for editable installs
This commit addresses the issue where editable installs fail with
"FileNotFoundError: No such file or directory: ninja" when the package
is imported in another project.
Changes:
- Added build tools (meson, ninja, cython, numpy) to dev dependencies
to ensure they're available at runtime for editable installs
- Added [tool.meson-python] configuration with editable-verbose=true
for better debugging of editable install issues
- Updated README.md with clear instructions for editable installs
using pip or UV package managers
The error occurred because meson-python's editable install creates a
loader that rebuilds on import, requiring build tools to be present.
By including these in the [dev] extra, users who install with
"pip install -e .[dev]" or "uv pip install -e .[dev]" will have
the necessary tools available.
Fixes the error:
FileNotFoundError: [Errno 2] No such file or directory:
'/path/to/.cache/uv/builds-v0/.tmp/bin/ninja'
* Improve meson build config and docs for both regular and editable installs
This commit clarifies the distinction between regular and editable installs,
making it clear that the ninja build tool error only affects editable installs.
Key changes:
1. Documentation improvements:
- Added "Regular Install" section clarifying that normal installs work
without build tools at runtime
- Reorganized "Editable/Development Install" section with two clear options:
* Option 1: pip install -e ".[dev]" (recommended)
* Option 2: --no-build-isolation with manual dependency installation
- Added troubleshooting guidance for the ninja error
- Explained why editable installs need build tools (automatic rebuild on import)
2. pyproject.toml improvements:
- Reformatted dev dependencies for better readability
- Enhanced comments explaining meson-python's editable install behavior
- Kept build tools (meson, ninja, cython, numpy) in dev dependencies
The root cause: meson-python's editable installs rebuild compiled components
on every import, requiring build tools at runtime. Regular installs compile
once during installation and don't need build tools afterward.
Users should:
- Use regular installs (pip install libact) for normal usage
- Use editable installs with [dev] dependencies for development
- Reinstall as regular if they encounter the ninja error
Resolves the issue where importing libact fails with:
FileNotFoundError: No such file or directory: '.../ninja'
* Major improvement: Simplify installation and make BLAS/LAPACK optional
This commit dramatically simplifies the installation process by making
BLAS/LAPACK optional dependencies and providing clear installation paths
for both regular and editable installs.
Key improvements:
1. **Automatic feature detection (libact/query_strategies/meson.build)**:
- BLAS/LAPACK are now only required if variance_reduction or hintsvm are enabled
- If BLAS/LAPACK not found, these features are automatically disabled with a warning
- Users can now install without system BLAS libraries
- Clear messages indicate which features are being built or skipped
2. **Simplified installation (README.md)**:
- Regular install now works out-of-the-box without BLAS/LAPACK
- Editable install instructions updated to use --no-build-isolation method
- Removed confusing multi-option approach
- Added clear troubleshooting section
3. **Configuration cleanup (pyproject.toml)**:
- Removed invalid `editable-verbose` configuration that caused build errors
- Kept dev dependencies for development workflow
- Added clear comment about editable install requirements
**Benefits**:
- ✅ Regular install: Works immediately without system dependencies
- ✅ Simple one-command install for most users: `pip install libact`
- ✅ Optional features available when BLAS/LAPACK are present
- ✅ Clear error messages guide users to solutions
- ✅ Reduces confusion and installation friction
**Testing performed**:
- Regular install tested successfully without BLAS/LAPACK
- Editable install tested with --no-build-isolation
- Import functionality verified in both modes
- Automatic feature skipping confirmed when BLAS unavailable
This resolves the ninja build tool error and makes libact much easier
to install for all users.
* Update GitHub workflows for meson-python build system
This commit updates the CI/CD workflows to work with the new meson-python
build system and to test both scenarios: with and without BLAS/LAPACK.
Changes to .github/workflows/tests.yml:
1. **Updated main test job (test-with-blas)**:
- Replaced old setup.py commands with meson-python workflow
- Install build tools explicitly (meson-python, meson, ninja, cython, numpy)
- Use `pip install --no-build-isolation -e .` for editable install
- Updated coverage command to use `python -m unittest` directly
- Better step names for clarity
2. **Added new test job (test-without-blas)**:
- Tests installation WITHOUT BLAS/LAPACK libraries
- Verifies automatic feature disabling works correctly
- Ensures basic functionality works without optional dependencies
- Tests that appropriate warning messages are shown
- Validates minimal install scenario for users without system libraries
Benefits:
- ✅ Tests full feature set with BLAS/LAPACK across Python 3.9-3.12
- ✅ Tests minimal install without BLAS/LAPACK (Python 3.11)
- ✅ Verifies automatic fallback behavior works as expected
- ✅ Compatible with new meson-python build backend
- ✅ Removed dependency on deprecated setup.py
The linting workflow remains unchanged as it doesn't need to build the package.
* Enhance optional feature testing and visibility
This commit ensures optional features (variance_reduction and hintsvm)
are properly tested and makes their build status clearly visible.
Changes:
1. **Enhanced CI testing (.github/workflows/tests.yml)**:
- Added verification step in test-with-blas job to ensure optional
features are actually built when BLAS/LAPACK are available
- Checks build log for "Building VarianceReduction" and "Building HintSVM"
- Verifies compiled modules are importable
- Fails build if optional features aren't built despite BLAS being present
- Enhanced test-without-blas job to verify features are correctly skipped
- Checks for "Skipping" messages in build output
- Verifies modules are NOT importable when BLAS is missing
- Ensures fallback behavior works as expected
2. **Improved build messaging (libact/query_strategies/meson.build)**:
- Added "Optional features requested" message at build start
- Shows variance_reduction and hintsvm status (true/false)
- Added "Build Summary" section at end showing what was actually built
- Uses ✓ and ✗ symbols for clear visual feedback
- Makes it easy to see which features were enabled in meson logs
3. **Clarified defaults (meson.options)**:
- Added comment block explaining defaults behavior
- Updated descriptions to show "(default: enabled, requires BLAS/LAPACK)"
- Makes it clear that features auto-disable if dependencies missing
Benefits:
- ✅ CI now validates optional features are tested when available
- ✅ CI ensures fallback works correctly without BLAS/LAPACK
- ✅ Clear build status in logs helps debugging
- ✅ Defaults are explicit and well-documented
- ✅ Prevents silent feature disabling from going unnoticed in CI
The optional features remain enabled by default (as they were) and are
automatically tested in CI to ensure they work correctly.
* Add cibuildwheel configuration for cross-platform binary wheels
Enable pre-built wheel distribution for Linux (x86_64/ARM64), macOS
(Intel/ARM), and Windows (x64) across Python 3.9-3.12.
Users can now install libact without compilers or BLAS/LAPACK setup.
Wheels bundle OpenBLAS and all compiled extensions (HintSVM, VarianceReduction).
Uses manylinux_2_28 for Linux, matching NumPy 2.x+ compatibility.
* add pkg-config for MacOS and Windows
* Use scipy-openblas32 for OSX
* fix pkg-config for OSX
* fix toml format
* Remove building support for Windows; use WSL2 instead
* Update README.md and workflow for building wheels
* Add version attribute and improve error handling
Add __version__ to libact package, add validation errors for invalid method/model parameters, and clean up deprecated pylintrc options.
* Optimize CI build performance with caching and native runners
Add dependency caching (pip, Homebrew, ccache) and switch to native ARM64 runners instead of slow QEMU emulation. Skip wheel tests on PRs to provide faster feedback while maintaining full test coverage on releases.
* Fix CI test failures for optional C-extensions
- Make wheel tests conditional to handle builds without BLAS/LAPACK
- Switch tests.yml from ATLAS to OpenBLAS for better compatibility
- Update GitHub Actions to v4/v5 in tests.yml
- Add pkg-config to test dependencies for proper library detection
The tests now pass whether C-extensions are built or not, while still
verifying they work when available.
* Fix macOS wheel build and enable rebuilds on workflow changes
- Force link Homebrew packages after install to fix cached package issue
- Add push trigger for build_wheels workflow on relevant file changes
- Ensures lapacke.h is found when building with cached dependencies
* Add CPPFLAGS and LDFLAGS for unlinked Homebrew packages on macOS
Homebrew refuses to link openblas and lapack on macOS because they shadow
system-provided libraries. Set CPPFLAGS and LDFLAGS to point directly to
the unlinked packages in /opt/homebrew and /usr/local, fixing the
'lapacke.h not found' error during builds.
* Force add lapack to PKG_CONFIG_PATH
* Remove Accelerate from BLAS/LAPACK search candidates
Accelerate framework lacks lapacke.h which is required by variance_reduction.c
for the LAPACK_dgesvd function. Removing it from the search list ensures
meson uses OpenBLAS instead on macOS platforms.
* Simplify macOS build and add robust fallback paths
- Use OpenBLAS (includes BLAS/LAPACK/LAPACKE) + libomp for OpenMP
- Add Cellar wildcard paths as fallback for cached packages
- Set CPPFLAGS/LDFLAGS to ensure compiler finds libraries
- Remove unnecessary packages from cache
* Use Accelerate framework + lapack headers on macOS
Re-add Accelerate to meson search list - it provides native BLAS/LAPACK
without OpenMP dependencies. Install Homebrew lapack package only for
lapacke.h headers. This avoids OpenMP issues with OpenBLAS on macOS
while keeping the code unchanged.
* Fix CI workflows: enable test re-runs and optimize caching
- Add github.run_attempt > 1 to test_wheels condition to allow manual re-runs
- Configure linting to only fail on errors (--errors-only flag)
- Remove non-functional pip and Homebrew caches
- Keep ccache for C++ compilation (most effective for cibuildwheel)
- Update GitHub Actions to v4/v5
* Update TestPyPI URL in build_wheels workflow
* Upgrade cibuildwheel to v2.22 to fix pip hash mismatch errors
* Remove irrelevant lock file
* Update README.md to document WSL usage on Windows
* Add CoreSet, BALD, and InformationDensity query strategies
Implement three new query strategies for active learning:
- CoreSet: Greedy k-center selection (Sener & Savarese, ICLR 2018)
Selects unlabeled points farthest from labeled set for geometric coverage.
- BALD: Bayesian Active Learning by Disagreement (Houlsby et al. 2011)
Maximizes mutual information using ensemble disagreement.
- InformationDensity: Uncertainty weighted by representativeness
(Settles & Craven, EMNLP 2008)
Combines uncertainty with density to avoid querying outliers.
These strategies provide complementary signals for ALBL:
- CoreSet → diversity/coverage
- BALD → epistemic uncertainty
- InformationDensity → representative uncertainty
Includes 42 unit tests (10 + 12 + 20) and documentation updates.
* update documentation config
* add the three new strategies to meson.build
* Add EpsilonUncertaintySampling (ε-US) query strategy
Implement epsilon-greedy uncertainty sampling that balances exploration
and exploitation with a fixed ratio:
- With probability ε: random sampling (exploration)
- With probability 1-ε: uncertainty sampling (exploitation)
Supports lc/sm/entropy uncertainty methods. Useful as a standalone
strategy or baseline when a fixed exploration rate is desired.
Includes 16 unit tests. Also adds missing test files to meson.build
for bald, coreset, and information_density strategies.
* Update version number to 0.2.0
* Add contributors (provisional)
* Add line break between authors and contributors
---------
Co-authored-by: Poy <ariapoy@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>1 parent 40d44b7 commit ae33df7
49 files changed
Lines changed: 3347 additions & 226 deletions
File tree
- .github/workflows
- docs
- examples
- libact
- base
- tests
- labelers
- tests
- models
- multilabel
- tests
- tests
- query_strategies
- multiclass
- tests
- multilabel
- tests
- tests
- utils
- multilabel
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
8 | 7 | | |
9 | | - | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
14 | | - | |
| 12 | + | |
15 | 13 | | |
16 | 14 | | |
17 | | - | |
| 15 | + | |
| 16 | + | |
18 | 17 | | |
19 | | - | |
| 18 | + | |
20 | 19 | | |
21 | 20 | | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | 12 | | |
15 | | - | |
| 13 | + | |
16 | 14 | | |
17 | 15 | | |
18 | | - | |
| 16 | + | |
19 | 17 | | |
20 | | - | |
| 18 | + | |
21 | 19 | | |
22 | 20 | | |
23 | | - | |
| 21 | + | |
24 | 22 | | |
25 | 23 | | |
26 | 24 | | |
| |||
29 | 27 | | |
30 | 28 | | |
31 | 29 | | |
32 | | - | |
| 30 | + | |
33 | 31 | | |
34 | 32 | | |
| 33 | + | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
39 | 41 | | |
40 | | - | |
41 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
42 | 62 | | |
43 | 63 | | |
44 | | - | |
45 | | - | |
46 | | - | |
| 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 | + | |
0 commit comments