From ee1daf5401117ae3ed241c54983542c946c7f8b2 Mon Sep 17 00:00:00 2001 From: yangarbiter Date: Wed, 4 Aug 2021 09:21:37 -0700 Subject: [PATCH 1/3] Migrate CI to Github action (#190) --- .github/workflows/linting.yml | 26 ++++++++++ .github/workflows/tests.yml | 44 ++++++++++++++++ .pylintrc | 2 +- .travis.yml | 51 ------------------- .../variance_reduction/variance_reduction.c | 5 -- 5 files changed, 71 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/linting.yml create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 00000000..4b63b712 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,26 @@ +name: Libact linting + +on: [push, pull_request] + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + continue-on-error: True + matrix: + os: [ubuntu-latest] + python-version: [3.9] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pylint + - run: pylint libact diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..d3e2127a --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,44 @@ +name: Libact tests + +on: [push, pull_request] + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + python-version: [2.7, 3.6, 3.7, 3.8, 3.9] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + if [ "$RUNNER_OS" = "macOS" ]; then + brew update + brew install openblas lapack + export LDFLAGS="-L/usr/local/opt/lapack/lib" + export CPPFLAGS="-I/usr/local/opt/lapack/include" + export PKG_CONFIG_PATH="/usr/local/opt/lapack/lib/pkgconfig" + else + sudo apt-get update -qq + sudo apt-get install -y build-essential gfortran libatlas-base-dev liblapacke-dev + sudo apt-get install -y python3-dev + fi + python -m pip install --upgrade pip + pip install pylint coverage codecov + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Install Libact + run: ./setup.py build_ext --inplace + - name: Unittests + run: | + python -m unittest -v + - run: coverage run --source libact --omit */tests/* setup.py test + - run: coverage report + - run: codecov diff --git a/.pylintrc b/.pylintrc index e5c04a89..cb53b843 100644 --- a/.pylintrc +++ b/.pylintrc @@ -84,7 +84,7 @@ generated-members= [FORMAT] # Maximum number of characters on a single line. -max-line-length=79 +max-line-length=120 # List of optional constructs for which whitespace checking is disabled. `dict- # separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4485a0f8..00000000 --- a/.travis.yml +++ /dev/null @@ -1,51 +0,0 @@ -language: python -python: - - "2.7" - - "3.4" - - "3.5" - - "3.6" -os: - - linux - - osx -sudo: required -dist: trusty -matrix: - allow_failures: - - os: osx # Python 3 not supported in Travis OSX environment - - os: linux - python: - - "nightly" - - "3.7-dev" - -notifications: - email: false - -cache: - directories: - - $HOME/.cache/pip - -before_install: - - if [ "$TRAVIS_OS_NAME" = "osx" ]; then - brew update; - brew tap homebrew/science; - brew install openblas; - else - sudo apt-get update -qq; - sudo apt-get install -y build-essential gfortran libatlas-base-dev liblapacke-dev; - sudo apt-get install -y python3-dev; - fi - - python -V - - travis_retry pip install --upgrade pip wheel # get pip >= 7, which caches built packages - - travis_wait 20 pip install -r requirements.txt - - pip install coverage - - pip install codecov - - pip install pylint -install: - - ./setup.py build_ext --inplace -script: - - python -m unittest -v - - coverage run --source libact --omit */tests/* setup.py test - - coverage report -after_success: - - pylint libact - - codecov diff --git a/libact/query_strategies/src/variance_reduction/variance_reduction.c b/libact/query_strategies/src/variance_reduction/variance_reduction.c index 1f141aa1..245d8cc4 100644 --- a/libact/query_strategies/src/variance_reduction/variance_reduction.c +++ b/libact/query_strategies/src/variance_reduction/variance_reduction.c @@ -4,11 +4,6 @@ #include #include -/* DGESVD prototype */ -extern void LAPACK_dgesvd( char* jobu, char* jobvt, int* m, int* n, double* a, - int* lda, double* s, double* u, int* ldu, double* vt, int* ldvt, - double* work, int* lwork, int* info ); - double** An(double *pi, double *x, int labs, int dims); double** A(double **PI, double **X, int labs, int dims, int n_pool); double** Fisher(double *pi, double *x, double sigma, int labs, int dims); From b5246a73f1c536ccd209cd3b9a6e5dd627ac75ad Mon Sep 17 00:00:00 2001 From: yangarbiter Date: Wed, 4 Aug 2021 10:16:37 -0700 Subject: [PATCH 2/3] Fix CI on MacOS (#191) --- .github/workflows/linting.yml | 2 +- .github/workflows/tests.yml | 10 +++++----- setup.py | 8 ++++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 4b63b712..5fa477d1 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -6,9 +6,9 @@ jobs: build: runs-on: ${{ matrix.os }} + continue-on-error: True strategy: fail-fast: false - continue-on-error: True matrix: os: [ubuntu-latest] python-version: [3.9] diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d3e2127a..5b1c1b9f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,10 +22,9 @@ jobs: run: | if [ "$RUNNER_OS" = "macOS" ]; then brew update - brew install openblas lapack - export LDFLAGS="-L/usr/local/opt/lapack/lib" - export CPPFLAGS="-I/usr/local/opt/lapack/include" - export PKG_CONFIG_PATH="/usr/local/opt/lapack/lib/pkgconfig" + 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 libatlas-base-dev liblapacke-dev @@ -35,7 +34,8 @@ jobs: pip install pylint coverage codecov if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Install Libact - run: ./setup.py build_ext --inplace + run: | + ./setup.py build_ext --inplace - name: Unittests run: | python -m unittest -v diff --git a/setup.py b/setup.py index 9bc22dc3..706db008 100755 --- a/setup.py +++ b/setup.py @@ -26,9 +26,13 @@ print("Platform Detection: Mac OS X. Link to openblas...") extra_link_args = [] libraries = ['openblas'] - library_dirs = ['/opt/local/lib'] + library_dirs = [ + '/opt/local/lib', + '/usr/local/opt/openblas/lib', # for brew installs + ] include_dirs = (numpy.distutils.misc_util.get_numpy_include_dirs() + - ['/opt/local/include']) + ['/opt/local/include', + '/usr/local/opt/openblas/include']) # for brew installs else: # assume linux otherwise, unless we support Windows in the future... print("Platform Detection: Linux. Link to liblapacke...") From 1079085b27bcb5d929ab3d9d0bbc2a132ec8cbdc Mon Sep 17 00:00:00 2001 From: Poy Date: Wed, 11 Aug 2021 09:37:03 +0800 Subject: [PATCH 3/3] [MRG] Upgrade to support newest scikit-learn version (#188) * Upgrade to sklearn==0.20. * Upgrade to sklearn==0.22. * Upgrade to sklearn==0.23. * Upgrade to sklearn==0.24. * Change the spacing style back to the original ver. * Pass CI with specific version range of sklearn. * Change the spacing style back to the original ver. * Change the spacing style back to the original ver. * Update libact/query_strategies/multiclass/mdsp.py Change the import style. Co-authored-by: yangarbiter Co-authored-by: yangarbiter --- libact/models/tests/test_svm.py | 2 +- libact/query_strategies/multiclass/mdsp.py | 4 ++-- .../multiclass/tests/test_hierarchical_sampling.py | 10 +++++----- .../multilabel/tests/test_multilabel_realdata.py | 2 +- requirements.txt | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libact/models/tests/test_svm.py b/libact/models/tests/test_svm.py index fb329fe6..06abab1b 100644 --- a/libact/models/tests/test_svm.py +++ b/libact/models/tests/test_svm.py @@ -29,7 +29,7 @@ def setUp(self): def test_svm(self): svc_clf = SVC(gamma="auto") svc_clf.fit(self.X_train, self.y_train) - svm = SVM() + svm = SVM(gamma="auto") svm.train(Dataset(self.X_train, self.y_train)) assert_array_equal( diff --git a/libact/query_strategies/multiclass/mdsp.py b/libact/query_strategies/multiclass/mdsp.py index 84631a89..4ec4e46e 100644 --- a/libact/query_strategies/multiclass/mdsp.py +++ b/libact/query_strategies/multiclass/mdsp.py @@ -16,8 +16,8 @@ from sklearn.base import BaseEstimator from sklearn.metrics import euclidean_distances from sklearn.utils import check_random_state, check_array, check_symmetric -from sklearn.externals.joblib import Parallel -from sklearn.externals.joblib import delayed +from joblib import Parallel, delayed + from sklearn.isotonic import IsotonicRegression diff --git a/libact/query_strategies/multiclass/tests/test_hierarchical_sampling.py b/libact/query_strategies/multiclass/tests/test_hierarchical_sampling.py index 62c4df79..05529b46 100644 --- a/libact/query_strategies/multiclass/tests/test_hierarchical_sampling.py +++ b/libact/query_strategies/multiclass/tests/test_hierarchical_sampling.py @@ -29,8 +29,8 @@ def test_hs_random_selecting(self): qseq = run_qs(ds, qs, self.y, len(self.y)-10) assert_array_equal( np.concatenate([qseq[:10], qseq[-10:]]), - np.array([48, 143, 13, 142, 88, 130, 29, 87, 36, 28, - 58, 137, 49, 105, 76, 71, 63, 47, 64, 55]) + np.array([39, 126, 66, 135, 37, 33, 118, 132, 142, 144, + 71, 28, 63, 41, 140, 34, 20, 110, 136, 36]) ) def test_hs_active_selecting(self): @@ -39,8 +39,8 @@ def test_hs_active_selecting(self): qseq = run_qs(ds, qs, self.y, len(self.y)-10) assert_array_equal( np.concatenate([qseq[:10], qseq[-10:]]), - np.array([48, 143, 13, 64, 101, 108, 51, 87, 36, 28, - 43, 118, 47, 25, 81, 82, 95, 40, 67, 120]) + np.array([39, 126, 66, 135, 37, 33, 118, 132, 142, 144, + 89, 117, 48, 67, 75, 14, 79, 62, 105, 19]) ) def test_hs_subsampling(self): @@ -52,7 +52,7 @@ def test_hs_subsampling(self): assert_array_equal( np.concatenate([qseq[:10], qseq[-10:]]), np.array([120, 50, 33, 28, 78, 133, 52, 124, 102, 109, - 81, 108, 12, 10, 89, 114, 92, 126, 48, 25]) + 81, 108, 10, 89, 126, 114, 92, 48, 25, 13]) ) def test_hs_report_all_label(self): diff --git a/libact/query_strategies/multilabel/tests/test_multilabel_realdata.py b/libact/query_strategies/multilabel/tests/test_multilabel_realdata.py index bed29968..3c14239f 100644 --- a/libact/query_strategies/multilabel/tests/test_multilabel_realdata.py +++ b/libact/query_strategies/multilabel/tests/test_multilabel_realdata.py @@ -47,7 +47,7 @@ def test_mmc(self): qs = MMC(trn_ds, random_state=1126) qseq = run_qs(trn_ds, qs, self.y, self.quota) assert_array_equal(qseq, - np.array([117, 655, 1350, 909, 1003, 1116, 546, 1055, 165, 1441])) + np.array([117, 655, 234, 1419, 1350, 1224, 427, 890, 1447, 103])) def test_multilabel_with_auxiliary_learner_hlr(self): trn_ds = Dataset(self.X, diff --git a/requirements.txt b/requirements.txt index 19a588ec..85c09f3b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ setuptools numpy scipy -scikit-learn<=0.19.2 +scikit-learn>=0.24 matplotlib Cython joblib