Skip to content

Commit

Permalink
Fix travis based on new pysap flow and add support to python3.8 (#107)
Browse files Browse the repository at this point in the history
* Remove unwanted travis installs and add python 3.8

* Version bump and point to right repositories

* Adon bump for pypi release

* Fix Commit for travis pytest runner

* Update codes for circleci

* Move clock() call to perf_counter()

* Adding extra to queue just in case, and also keeping rtol=1e-5

* Update config.yml

* Remove upgrade option as we not moved to latest

* Adding caching for faster build

* Remove support for n_jobs for ISAP wavelets

* Fix PEP8 errors

* Minute fix for #102

* add upgrade as clearing cache will take long

Co-authored-by: chaithyagr <[email protected]>
  • Loading branch information
chaithyagr and chaithyagr authored Jul 7, 2020
1 parent 3bccf77 commit b79a5da
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 56 deletions.
7 changes: 1 addition & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ jobs:
python3 -m venv venv
. venv/bin/activate
pip install --upgrade pip
pushd ../
git clone https://github.com/CEA-COSMIC/pysap
cd pysap
python setup.py install
echo "export PATH=$PATH:$PWD/build/temp.linux-x86_64-3.6/extern/bin" >> $BASH_ENV
popd
pip install --upgrade git+https://github.com/cea-cosmic/pysap
pip install -r doc/requirements.txt
pip list > doc/state.txt
- save_cache:
Expand Down
34 changes: 6 additions & 28 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
sudo: required
dist: xenial
language: python

cache: pip
matrix:
include:
- python: 3.5
- python: 3.6
- python: 3.7
- python: 3.8
dist: xenial
sudo: true

before_install:
- sudo apt-get update
- sudo updatedb
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
- if [ $TRAVIS_PYTHON_VERSION == "3.5" ]; then
export CPLUS_INCLUDE_PATH=/opt/python/3.5.6/include/python3.5m;
fi
- if [ $TRAVIS_PYTHON_VERSION == "3.6" ]; then
export CPLUS_INCLUDE_PATH=/opt/python/3.6.3/include/python3.6m;
fi
- if [ $TRAVIS_PYTHON_VERSION == "3.7" ]; then
export CPLUS_INCLUDE_PATH=/opt/python/3.7.1/include/python3.7m;
- if [ $TRAVIS_OS_NAME = 'linux' ]; then
export CPLUS_INCLUDE_PATH=$(cd /opt/python/3.*/include/python3.*; pwd);
fi
- chmod +x miniconda.sh
- ./miniconda.sh -b -p $HOME/miniconda
Expand All @@ -40,28 +35,11 @@ install:
- ln -s $HOME/.local/share/pysap/pysap-data/pysap-data/* $HOME/.local/share/pysap
- ls -l $HOME/.local/share/pysap
- pip install --upgrade pip
- pip install matplotlib
- pip install coverage nose pytest pytest-cov
- pip install coveralls
- pip install pycodestyle
- pip install pybind11 nibabel pyqt5 pyqtgraph astropy
- pip install coverage nose pytest pytest-cov coveralls pycodestyle
- pip install git+https://github.com/CEA-COSMIC/ModOpt.git
- pip install git+https://github.com/AGrigis/pysphinxdoc.git
- pip install sphinx==2.2.1
- pushd ../
- git clone https://github.com/CEA-COSMIC/pysap
- cd pysap
- python setup.py install
- if [ $TRAVIS_PYTHON_VERSION == "3.5" ]; then
export PATH=$PATH:$PWD/build/temp.linux-x86_64-3.5/extern/bin;
fi
- if [ $TRAVIS_PYTHON_VERSION == "3.6" ]; then
export PATH=$PATH:$PWD/build/temp.linux-x86_64-3.6/extern/bin;
fi
- if [ $TRAVIS_PYTHON_VERSION == "3.7" ]; then
export PATH=$PATH:$PWD/build/temp.linux-x86_64-3.7/extern/bin;
fi
- popd
- pip install git+https://github.com/CEA-COSMIC/pysap.git
- export PYTHONPATH=$TRAVIS_BUILD_DIR/install:$PYTHONPATH
- pip install -b $TRAVIS_BUILD_DIR/build -t $TRAVIS_BUILD_DIR/install --no-clean --upgrade .

Expand Down
2 changes: 1 addition & 1 deletion examples/gridsearch_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
to carry out grid search. We will search for best regularisation weight
and the best wavelet for reconstruction.
For this the search space works on :
mu ==> 5 Values on log scale between 1e-8 and 1e-9
mu ==> 5 Values on log scale between 1e-8 and 1e-6
Wavelets ==> sym8 and sym12
nb_scale ==> 3 and 4
"""
Expand Down
2 changes: 1 addition & 1 deletion mri/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Module current version
version_major = 0
version_minor = 2
version_micro = 0
version_micro = 2

# Expected by setup.py: string of form "X.Y.Z"
__version__ = "{0}.{1}.{2}".format(version_major, version_minor, version_micro)
Expand Down
9 changes: 9 additions & 0 deletions mri/operators/linear/wavelet.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
import pysap
from pysap.base.utils import flatten
from pysap.base.utils import unflatten
from pysap.utils import wavelist

# Third party import
import joblib
from joblib import Parallel, delayed
import numpy as np
import warnings


class WaveletN(OperatorBase):
Expand Down Expand Up @@ -66,6 +68,13 @@ def __init__(self, wavelet_name, nb_scale=4, verbose=0, dim=2,
n_proc = self.n_jobs
if n_proc < 0:
n_proc = joblib.cpu_count() + self.n_jobs + 1
if n_proc > 0:
if wavelet_name in wavelist()['isap-2d'] or \
wavelet_name in wavelist()['isap-3d']:
warnings.warn("n_jobs is currently unsupported "
"for ISAP wavelets, setting n_jobs=1")
self.n_jobs = 1
n_proc = 1
# Create transform queue for parallel execution
for i in range(min(n_proc, self.n_coils)):
self.transform_queue.append(transform_klass(
Expand Down
8 changes: 4 additions & 4 deletions mri/optimizers/forward_backward.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def fista(gradient_op, linear_op, prox_op, cost_op,
metrics: dict
the requested metrics values during the optimization.
"""
start = time.clock()
start = time.perf_counter()

# Define the initial primal and dual solutions
if x_init is None:
Expand Down Expand Up @@ -111,7 +111,7 @@ def fista(gradient_op, linear_op, prox_op, cost_op,
if verbose > 0:
print("Starting optimization...")
opt.iterate(max_iter=max_nb_of_iter)
end = time.clock()
end = time.perf_counter()
if verbose > 0:
# cost_op.plot_cost()
if hasattr(cost_op, "cost"):
Expand Down Expand Up @@ -170,7 +170,7 @@ def pogm(gradient_op, linear_op, prox_op, cost_op=None,
metrics: dict
the requested metrics values during the optimization.
"""
start = time.clock()
start = time.perf_counter()

# Define the initial values
im_shape = (gradient_op.linear_op.n_coils, *gradient_op.fourier_op.shape)
Expand Down Expand Up @@ -214,7 +214,7 @@ def pogm(gradient_op, linear_op, prox_op, cost_op=None,
if verbose > 0:
print("Starting optimization...")
opt.iterate(max_iter=max_nb_of_iter)
end = time.clock()
end = time.perf_counter()
if verbose > 0:
# cost_op.plot_cost()
if hasattr(cost_op, "cost"):
Expand Down
4 changes: 2 additions & 2 deletions mri/optimizers/primal_dual.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def condatvu(gradient_op, linear_op, dual_regularizer, cost_op,
the estimated dual CONDAT-VU solution
"""
# Check inputs
start = time.clock()
start = time.perf_counter()
if std_est_method not in (None, "primal", "dual"):
raise ValueError(
"Unrecognize std estimation method '{0}'.".format(std_est_method))
Expand Down Expand Up @@ -206,7 +206,7 @@ def condatvu(gradient_op, linear_op, dual_regularizer, cost_op,
opt.iterate(max_iter=max_nb_of_iter)

# Goodbye message
end = time.clock()
end = time.perf_counter()
if verbose > 0:
if hasattr(cost_op, "cost"):
print(" - final iteration number: ", cost_op._iteration)
Expand Down
8 changes: 4 additions & 4 deletions mri/tests/test_wavelet_adjoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_Wavelet2D_ISAP(self):
I_p = wavelet_op_adj.adj_op(f)
x_d = np.vdot(Img, I_p)
x_ad = np.vdot(f_p, f)
np.testing.assert_allclose(x_d, x_ad, rtol=1e-6)
np.testing.assert_allclose(x_d, x_ad, rtol=1e-5)
print(" Wavelet2 adjoint test passes")

def test_Wavelet2D_PyWt(self):
Expand All @@ -77,7 +77,7 @@ def test_Wavelet2D_PyWt(self):
I_p = wavelet_op_adj.adj_op(f)
x_d = np.vdot(Img, I_p)
x_ad = np.vdot(f_p, f)
np.testing.assert_allclose(x_d, x_ad, rtol=1e-6)
np.testing.assert_allclose(x_d, x_ad, rtol=1e-5)
print(" Wavelet2 adjoint test passes")

def test_Wavelet3D_PyWt(self):
Expand Down Expand Up @@ -105,7 +105,7 @@ def test_Wavelet3D_PyWt(self):
I_p = wavelet_op_adj.adj_op(f)
x_d = np.vdot(Img, I_p)
x_ad = np.vdot(f_p, f)
np.testing.assert_allclose(x_d, x_ad, rtol=1e-6)
np.testing.assert_allclose(x_d, x_ad, rtol=1e-5)
print(" Wavelet3 adjoint test passes")

def test_Wavelet_UD_2D(self):
Expand All @@ -128,7 +128,7 @@ def test_Wavelet_UD_2D(self):
i_p = wavelet_op.adj_op(f)
x_d = np.vdot(img, i_p)
x_ad = np.vdot(f_p, f)
np.testing.assert_allclose(x_d, x_ad, rtol=1e-6)
np.testing.assert_allclose(x_d, x_ad, rtol=1e-5)
print("Undecimated Wavelet 2D adjoint test passes")


Expand Down
21 changes: 11 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
Philippe Ciuciu <[email protected]>
"""
# Write setup
setup_requires = ["numpy", "cython", "pytest-runner", "scikit-image"]
setup_requires = ["numpy>=1.16.4", "cython>=0.27.3", "pytest-runner"]

pip_main(['install'] + setup_requires)

Expand All @@ -42,17 +42,18 @@
classifiers="CLASSIFIERS",
author=AUTHOR,
author_email="XXX",
version="0.1.1",
version="0.2.2",
url="https://github.com/CEA-COSMIC/pysap-mri",
packages=find_packages(),
setup_requires=setup_requires,
install_requires=["scikit-learn",
"progressbar2",
"joblib",
"scipy<=1.3.3",
"psutil",
"pynfft@git+https://github.com/ghisvail/pyNFFT@master"],
dependency_links=['https://github.com/ghisvail/pyNFFT/tarball/master#egg=pynfft-1.3.0'],
tests_require=['pytest>=5.0.1', 'pytest-cov>=2.7.1', 'pytest-pep8'],
install_requires=[
"scikit-learn>=0.19.1",
"progressbar2>=3.34.3",
"joblib",
"scipy>=1.3.0",
"pynfft2>=1.3.3",
"scikit-image",
],
tests_require=['pytest>=5.0.1', 'pytest-cov>=2.7.1', 'pytest-pep8', 'pytest-runner'],
platforms="OS Independent"
)

0 comments on commit b79a5da

Please sign in to comment.