Skip to content

Commit

Permalink
Merge branch 'main' into brendt/iso-tv-norm
Browse files Browse the repository at this point in the history
  • Loading branch information
bwohlberg committed Jan 3, 2024
2 parents 5ea6b2b + 85c1a1c commit 4511082
Show file tree
Hide file tree
Showing 23 changed files with 186 additions and 122 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pytest_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ jobs:
pip install pytest-split
pip install -r requirements.txt
pip install -r dev_requirements.txt
mamba install -c conda-forge svmbir>=0.3.3
mamba install -c astra-toolbox astra-toolbox
mamba install -c conda-forge pyyaml
pip install --upgrade --force-reinstall scipy>=1.6.0 # Temporary fix for GLIBCXX_3.4.30 not found in conda forge version
pip install bm3d>=4.0.0
pip install bm4d>=4.0.0
pip install "ray[tune]>=2.0.0"
pip install "ray[tune]>=2.5.0"
pip install hyperopt
# Install package to be tested
- name: Install package to be tested
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/pytest_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ jobs:
pip install pytest-split
pip install -r requirements.txt
pip install -r dev_requirements.txt
mamba install -c conda-forge svmbir>=0.3.3
mamba install -c astra-toolbox astra-toolbox
mamba install -c conda-forge pyyaml
pip install --upgrade --force-reinstall scipy>=1.6.0 # Temporary fix for GLIBCXX_3.4.30 not found in conda forge version
pip install bm3d>=4.0.0
pip install bm4d>=4.2.2
pip install "ray[tune]>=2.0.0"
pip install "ray[tune]>=2.5.0"
pip install hyperopt
# Install package to be tested
- name: Install package to be tested
Expand Down
11 changes: 9 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ SCICO Release Notes
===================


Version 0.0.5 (unreleased)
Version 0.0.6 (unreleased)
----------------------------

• No significant changes.



Version 0.0.5 (2023-12-18)
----------------------------

• New functionals ``functional.AnisotropicTVNorm``,
Expand All @@ -18,7 +25,7 @@ Version 0.0.5 (unreleased)
• Rename ``solver.ATADSolver`` to ``solver.MatrixATADSolver``.
• Rename some ``__init__`` parameters of ``linop.DiagonalStack`` and
``linop.VerticalStack``.
• Support ``jaxlib`` and ``jax`` versions 0.4.3 to 0.4.21.
• Support ``jaxlib`` and ``jax`` versions 0.4.3 to 0.4.23.
• Support ``flax`` versions up to 0.7.5.
• Use ``orbax`` for checkpointing ``flax`` models.

Expand Down
19 changes: 18 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,25 @@ def pytest_addoption(parser, pluginmanager):
Level definitions:
1 Critical tests only
2 Skip tests that do have a significant impact on coverage
3 All tests
3 All standard tests
4 Run all tests, including those marked as slow to run
"""
parser.addoption(
"--level", action="store", default=3, type=int, help="Set test level to be run"
)


def pytest_configure(config):
"""Add marker description."""
config.addinivalue_line("markers", "slow: mark test as slow to run")


def pytest_collection_modifyitems(config, items):
"""Skip slow tests depending on selected testing level."""
if config.getoption("--level") >= 4:
# don't skip tests at level 4 or higher
return
level_skip = pytest.mark.skip(reason="test not appropriate for selected level")
for item in items:
if "slow" in item.keywords:
item.add_marker(level_skip)
2 changes: 1 addition & 1 deletion data
1 change: 1 addition & 0 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-r requirements.txt
pylint
pytest>=7.3.0
pytest-runner
Expand Down
24 changes: 15 additions & 9 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,32 @@ GPU Support
The instructions above install a CPU-only version of SCICO. To install
a version with GPU support:

1. Follow the CPU only instructions, above
1. Follow the CPU-only instructions, above

2. Install the version of jaxlib with GPU support, as described in the `JAX installation
instructions <https://github.com/google/jax#installation>`_.
instructions <https://jax.readthedocs.io/en/latest/installation.html>`_.
In the simplest case, the appropriate command is

::

pip install --upgrade "jax[cuda]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
pip install --upgrade "jax[cuda11]"

for CUDA 11, or

but it may be necessary to explicitly specify the ``jaxlib``
version if the most recent release is not yet supported by SCICO
(as specified in the ``requirements.txt`` file), or if using a
version of CUDA older than 11.4, or CuDNN older than 8.2, in which
case the command would be of the form ::
::

pip install --upgrade "jax[cuda12]"

for CUDA 12, but it may be necessary to explicitly specify the
``jaxlib`` version if the most recent release is not yet supported
by SCICO (as specified in the ``requirements.txt`` file), or if
using a version of CUDA older than 11.4, or CuDNN older than 8.2,
in which case the command would be of the form ::

pip install --upgrade "jaxlib==0.4.2+cuda11.cudnn82" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html

with appropriate substitution of ``jaxlib``, CUDA, and CuDNN version numbers.
with appropriate substitution of ``jaxlib``, CUDA, and CuDNN version
numbers.



Expand Down
5 changes: 4 additions & 1 deletion examples/examples_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
astra-toolbox
-r ../requirements.txt
tifffile
colour_demosaicing
svmbir>=0.3.3
astra-toolbox
xdesign>=0.5.5
ray[tune,train]>=2.5.0
hyperopt
Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-r examples-requirements.txt
nbformat
nbconvert
nb_conda_kernels
psutil
py2jn
pypandoc
ray[tune]
2 changes: 1 addition & 1 deletion examples/scriptcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ for f in $SCRIPTPATH/scripts/*.py; do
sed -E -e "$re1$re2$re3$re4$re5$re6$re7$re8" $f > $g

# Run temporary script and print status message.
if output=$(timeout 60s python $g 2>&1); then
if output=$(timeout 180s python $g 2>&1); then
printf "%s\n" succeeded
else
printf "%s\n" FAILED
Expand Down
95 changes: 58 additions & 37 deletions misc/conda/make_conda_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ REPOPATH=$(realpath $(dirname $0))
USAGE=$(cat <<-EOF
Usage: $SCRIPT [-h] [-y] [-g] [-p python_version] [-e env_name]
[-h] Display usage information
[-v] Verbose operation
[-t] Display actions that would be taken but do nothing
[-y] Do not ask for confirmation
[-p python_version] Specify Python version (e.g. 3.9)
[-e env_name] Specify conda environment name
EOF
)

AGREE=no
VERBOSE=no
TEST=no
PYVER="3.9"
ENVNM=py$(echo $PYVER | sed -e 's/\.//g')

Expand All @@ -46,13 +50,13 @@ EOF
)
# Requirements that cannot be installed via conda (i.e. have to use pip)
NOCONDA=$(cat <<-EOF
flax bm3d bm4d faculty-sphinx-theme py2jn colour_demosaicing ray[tune]
flax bm3d bm4d py2jn colour_demosaicing ray[tune,train]
EOF
)


OPTIND=1
while getopts ":hyp:e:" opt; do
while getopts ":hvtyp:e:" opt; do
case $opt in
p|e) if [ -z "$OPTARG" ] || [ "${OPTARG:0:1}" = "-" ] ; then
echo "Error: option -$opt requires an argument" >&2
Expand All @@ -61,6 +65,8 @@ while getopts ":hyp:e:" opt; do
fi
;;&
h) echo "$USAGE"; exit 0;;
t) VERBOSE=yes;TEST=yes;;
v) VERBOSE=yes;;
y) AGREE=yes;;
p) PYVER=$OPTARG;;
e) ENVNM=$OPTARG;;
Expand Down Expand Up @@ -125,31 +131,6 @@ JLVER=$($SED -n 's/^jaxlib>=.*<=\([0-9\.]*\).*/\1/p' \
JXVER=$($SED -n 's/^jax>=.*<=\([0-9\.]*\).*/\1/p' \
$REPOPATH/../../requirements.txt)

CONDAHOME=$(conda info --base)
ENVDIR=$CONDAHOME/envs/$ENVNM
if [ -d "$ENVDIR" ]; then
echo "Error: environment $ENVNM already exists"
exit 9
fi

if [ "$AGREE" == "no" ]; then
RSTR="Confirm creation of conda environment $ENVNM with Python $PYVER"
RSTR="$RSTR [y/N] "
read -r -p "$RSTR" CNFRM
if [ "$CNFRM" != 'y' ] && [ "$CNFRM" != 'Y' ]; then
echo "Cancelling environment creation"
exit 10
fi
else
echo "Creating conda environment $ENVNM with Python $PYVER"
fi

if [ "$AGREE" == "yes" ]; then
CONDA_FLAGS="-y"
else
CONDA_FLAGS=""
fi

# Construct merged list of all requirements
if [ "$OS" == "Darwin" ]; then
ALLREQUIRE=$(/usr/bin/mktemp -t condaenv)
Expand Down Expand Up @@ -177,15 +158,56 @@ sort $ALLREQUIRE | uniq | $SED -E 's/(>|<|\|)/\\\1/g' \
| $SED -E 's/\#.*$//g' \
| $SED -E '/^-r.*|^jaxlib.*|^jax.*/d' > $FLTREQUIRE
# Remove requirements that cannot be installed via conda
PIPREQ=""
for nc in $NOCONDA; do
# Escape [ and ] for use in regex
nc=$(echo $nc | sed -E 's/(\[|\])/\\\1/g')
nc=$(echo $nc | $SED -E 's/(\[|\])/\\\1/g')
# Add package to pip package list
PIPREQ="$PIPREQ "$(grep "$nc" $FLTREQUIRE | $SED 's/\\//g')
# Remove package $nc from conda package list
$SED -i "/^$nc.*\$/d" $FLTREQUIRE
done
# Get list of requirements to be installed via conda
CONDAREQ=$(cat $FLTREQUIRE | xargs)

if [ "$VERBOSE" == "yes" ]; then
echo "Create python $PYVER environment $ENVNM in conda installation"
echo " $CONDAHOME"
echo "Packages to be installed via conda:"
echo " $CONDAREQ" | fmt -w 79
echo "Packages to be installed via pip:"
echo " jaxlib==$JLVER jax==$JXVER $PIPREQ" | fmt -w 79
if [ "$TEST" == "yes" ]; then
exit 0
fi
fi

CONDAHOME=$(conda info --base)
ENVDIR=$CONDAHOME/envs/$ENVNM
if [ -d "$ENVDIR" ]; then
echo "Error: environment $ENVNM already exists"
exit 9
fi

if [ "$AGREE" == "no" ]; then
RSTR="Confirm creation of conda environment $ENVNM with Python $PYVER"
RSTR="$RSTR [y/N] "
read -r -p "$RSTR" CNFRM
if [ "$CNFRM" != 'y' ] && [ "$CNFRM" != 'Y' ]; then
echo "Cancelling environment creation"
exit 10
fi
else
echo "Creating conda environment $ENVNM with Python $PYVER"
fi

if [ "$AGREE" == "yes" ]; then
CONDA_FLAGS="-y"
else
CONDA_FLAGS=""
fi


# Update conda, create new environment, and activate it
conda update $CONDA_FLAGS -n base conda
conda create $CONDA_FLAGS -n $ENVNM python=$PYVER
Expand Down Expand Up @@ -215,7 +237,7 @@ fi
pip install --upgrade jaxlib==$JLVER jax==$JXVER

# Install other packages that require installation via pip
pip install $NOCONDA
pip install $PIPREQ

# Warn if libopenblas-dev not installed on debian/ubuntu
if [ "$(which dpkg 2>/dev/null)" ]; then
Expand All @@ -233,13 +255,12 @@ echo " conda activate $ENVNM"
echo "The environment can be deactivated with the command"
echo " conda deactivate"
echo
echo "Jax installed without GPU support. To avoid warning messages,"
echo "add the following to your .bashrc or .bash_aliases file"
echo " export JAX_PLATFORM_NAME=cpu"
echo "To include GPU support, reinstall the astra-toolbox conda"
echo "package on a host with GPUs, and see the instructions at"
echo " https://github.com/google/jax#pip-installation-gpu-cuda"
echo "for additional steps required after running this script and"
echo "activating the environment created by it."
echo "JAX installed without GPU support. To enable GPU support, install a"
echo "version of jaxlib with CUDA support following the instructions at"
echo " https://jax.readthedocs.io/en/latest/installation.html#nvidia-gpu"
echo "ASTRA Toolbox installed without GPU support if this script was"
echo "run on a host without CUDA drivers installed. To enable GPU support,"
echo "uninstall and then reinstall the astra-toolbox conda package on a"
echo "host with CUDA drivers installed."

exit 0
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
typing_extensions
numpy>=1.20.0
scipy>=1.6.0
tifffile
imageio>=2.17
matplotlib
jaxlib>=0.4.3,<=0.4.21
jax>=0.4.3,<=0.4.21
jaxlib>=0.4.3,<=0.4.23
jax>=0.4.3,<=0.4.23
orbax-checkpoint
flax>=0.6.1,<=0.7.5
svmbir>=0.3.3
pyabel>=0.9.0
2 changes: 1 addition & 1 deletion scico/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
solving the inverse problems that arise in scientific imaging applications.
"""

__version__ = "0.0.5.dev0"
__version__ = "0.0.6.dev0"

import logging
import sys
Expand Down
3 changes: 2 additions & 1 deletion scico/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def package_version(split: bool = False) -> Union[str, Tuple[str, str]]: # prag
Package version string or tuple of strings.
"""
version = init_variable_assign_value("__version_")
if re.match(r"^[0-9\.]+$", version): # don't extend purely numeric version numbers
# don't extend purely numeric version numbers, possibly ending with post<n>
if re.match(r"^[0-9\.]+(post[0-9]+)?$", version):
git_hash = None
else:
git_hash = current_git_hash()
Expand Down
Loading

0 comments on commit 4511082

Please sign in to comment.