Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MTN use new xfail functionality to skip cyanure/lightning and julia on OSX #21

Merged
merged 21 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 42 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,63 @@ on:
pull_request:
branches:
- master
schedule:
# Run every day at 7:42am UTC.
- cron: '42 7 * * *'

jobs:
build-linux:
runs-on: ubuntu-latest
test-benchmark:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 5
matrix:
include:
- os: ubuntu-latest
- os: macos-latest
env:
CONDA_ENV: 'test_env'
VERSION_PYTHON: ${{ matrix.version_python }}
BENCHOPT_BRANCH: benchopt:master

defaults:
run:
# Need to use this shell to get conda working properly.
# See https://github.com/marketplace/actions/setup-miniconda#important
shell: bash -l {0}

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- name: Setup Conda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: ${{ env.CONDA_ENV }}
python-version: 3.8
# Use miniforge to only get conda-forge as default channel.
miniforge-version: latest

- name: Install dependencies
env:
BENCH_BRANCH: master
- run: conda info

- name: Install benchopt and its dependencies
run: |
eval "$(conda shell.bash hook)"
conda activate base
# make sure we have the latest version of pip to correctly install benchopt in sub conda env
pip install --upgrade pip
pip install -U git+https://github.com/benchopt/benchopt@$BENCH_BRANCH
conda info
conda install -yq pip

# Get the correct branch of benchopt
user=${BENCHOPT_BRANCH%:*}
branch=${BENCHOPT_BRANCH##*:}
pip install -U git+https://github.com/$user/benchopt@$branch

- name: Test
env:
BENCHOPT_DEBUG: 1
BENCHOPT_DEBUG: 1
run: |
eval "$(conda shell.bash hook)"
conda activate base
benchopt test . --env-name bench_test_env -vl

echo '-----------------------------------------'
conda activate bench_test_env
conda config --show channels
conda activate ${{ env.CONDA_ENV }}
echo '-----------------------------------------'

benchopt test . --env-name bench_test_env -vl --skip-install


Expand Down
2 changes: 1 addition & 1 deletion solvers/cyanure.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Solver(BaseSolver):
name = 'Cyanure'

install_cmd = 'conda'
requirements = ['pip:cyanure-mkl']
requirements = ['mkl', 'pip:cyanure-mkl']
references = [
'J. Mairal, "Cyanure: An Open-Source Toolbox for Empirical Risk'
' Minimization for Python, C++, and soon more," '
Expand Down
2 changes: 1 addition & 1 deletion solvers/modopt_fista.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def set_objective(self, X, y, lmbd):
self.fb = ForwardBackward(
x=np.zeros(n_features), # this is the coefficient w
grad=GradBasic(
input_data=y,
op=lambda w: self.X@w,
trans_op=lambda res: self.X.T@res,
data=y,
),
prox=SparseThreshold(Identity(), lmbd),
beta_param=1.0,
Expand Down
2 changes: 1 addition & 1 deletion solvers/modopt_pogm.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def set_objective(self, X, y, lmbd):
y=var_init,
z=var_init,
grad=GradBasic(
input_data=y,
op=lambda w: self.X@w,
trans_op=lambda res: self.X.T@res,
data=y,
),
prox=SparseThreshold(Identity(), lmbd),
beta_param=1.0,
Expand Down
7 changes: 3 additions & 4 deletions solvers/r_pgd.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Solver(BaseSolver):
name = "R-PGD"

install_cmd = 'conda'
requirements = ['r-base', '-c conda-forge r rpy2']
requirements = ['r-base', 'rpy2']
stop_strategy = 'iteration'
support_sparse = False
references = [
Expand All @@ -35,15 +35,14 @@ class Solver(BaseSolver):

def set_objective(self, X, y, lmbd):
self.X, self.y, self.lmbd = X, y, lmbd
self.lmbd_max = np.max(np.abs(X.T @ y))
self.r_pgd = robjects.r['proximal_gradient_descent']

def run(self, n_iter):
coefs = self.r_pgd(
self.X, self.y[:, None], self.lmbd,
n_iter=n_iter)
as_matrix = robjects.r['as']
self.w = np.array(as_matrix(coefs, "matrix"))
as_r = robjects.r['as']
self.w = np.array(as_r(coefs, "vector"))

def get_result(self):
return self.w.flatten()
2 changes: 1 addition & 1 deletion solvers/spams.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Solver(BaseSolver):
name = 'spams'

install_cmd = 'conda'
requirements = ['mkl', 'pip:spams']
requirements = ['python-spams']
references = [
'J. Mairal, F. Bach, J. Ponce and G. Sapiro, '
'"Online dictionary learning for sparse coding", '
Expand Down
29 changes: 29 additions & 0 deletions test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import sys

import pytest


def check_test_solver_install(solver_class):

if solver_class.name.lower() == 'cyanure' and sys.platform == 'darwin':
pytest.xfail('Cyanure is not easy to install on macos.')

# Skip test_solver_install for julia in OSX as there is a version
# conflict with conda packages for R
# See issue benchopt/benchopt#64.
if 'julia' in solver_class.name.lower() and sys.platform == 'darwin':
pytest.xfail('Julia causes segfault on OSX for now.')

# Lightning install is broken on python3.9+.
# See issue scikit-learn-contrib/lightning#153.
if (solver_class.name.lower() == 'lightning'
and sys.version_info >= (3, 9)):
pytest.xfail('Lightning install is broken on python3.9+.')

# Lightning install is broken on python3.9+.
# See CEA-COSMIC/ModOpt#144.
if ('modopt' in solver_class.name.lower()):
pytest.skip(
'Modopt breaks other package installation by changing '
'numpy version. Skipping for now.'
)