Skip to content

Commit

Permalink
Bump version requirements (#4312)
Browse files Browse the repository at this point in the history
Description of changes:
- require Python 3.7+, scipy 1.4.0+, numpy 1.17.4+ (as per #3421, fixes #4258)
- require Boost 1.69+ (enables #3638)
- remove OpenSUSE job from CI (Leap 15.3 doesn't package Python3 and Boost, Leap 15.2 is outdated)
  • Loading branch information
kodiakhq[bot] committed Jul 28, 2021
2 parents 2d9e8ca + 2872adc commit 1d27884
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 68 deletions.
25 changes: 5 additions & 20 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: docker.pkg.github.com/espressomd/docker/ubuntu-20.04:063f945eb434f6900402fd412f28a4486288c82b
image: docker.pkg.github.com/espressomd/docker/ubuntu-20.04:08d67d67a4d3c3279cacee975b68c02ec89b2a21

stages:
- prepare
Expand Down Expand Up @@ -127,7 +127,7 @@ no_rotation:
ubuntu:wo-dependencies:
<<: *global_job_definition
stage: build
image: docker.pkg.github.com/espressomd/docker/ubuntu-wo-dependencies:e583d4b2eb8eedd10068957f952bd67008475ee5
image: docker.pkg.github.com/espressomd/docker/ubuntu-wo-dependencies:08d67d67a4d3c3279cacee975b68c02ec89b2a21
variables:
myconfig: 'maxset'
with_cuda: 'false'
Expand All @@ -145,22 +145,7 @@ ubuntu:wo-dependencies:
debian:10:
<<: *global_job_definition
stage: build
image: docker.pkg.github.com/espressomd/docker/debian:d372d95f6906c16abd9b47b994034a22981a9ff2
variables:
with_cuda: 'false'
myconfig: 'maxset'
make_check_python: 'false'
with_stokesian_dynamics: 'true'
script:
- bash maintainer/CI/build_cmake.sh
tags:
- docker
- linux

opensuse:15.2:
<<: *global_job_definition
stage: build
image: docker.pkg.github.com/espressomd/docker/opensuse:d496478230db4e5c286680e3bdc1621af1fccffc
image: docker.pkg.github.com/espressomd/docker/debian:08d67d67a4d3c3279cacee975b68c02ec89b2a21
variables:
with_cuda: 'false'
myconfig: 'maxset'
Expand All @@ -175,7 +160,7 @@ opensuse:15.2:
fedora:32:
<<: *global_job_definition
stage: build
image: docker.pkg.github.com/espressomd/docker/fedora:4f126520866e84a4883355ffe8710040bf20051c
image: docker.pkg.github.com/espressomd/docker/fedora:08d67d67a4d3c3279cacee975b68c02ec89b2a21
variables:
with_cuda: 'false'
myconfig: 'maxset'
Expand Down Expand Up @@ -231,7 +216,7 @@ clang-sanitizer:
cuda11-maxset:
<<: *global_job_definition
stage: build
image: docker.pkg.github.com/espressomd/docker/cuda:d372d95f6906c16abd9b47b994034a22981a9ff2
image: docker.pkg.github.com/espressomd/docker/cuda:08d67d67a4d3c3279cacee975b68c02ec89b2a21
variables:
CC: 'gcc-9'
CXX: 'g++-9'
Expand Down
14 changes: 3 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ if(WITH_CUDA)
endif()
endif(WITH_CUDA)

find_package(PythonInterp 3.6 REQUIRED)
find_package(PythonInterp 3.7 REQUIRED)

if(WITH_PYTHON)
find_package(Cython 0.29 REQUIRED)
find_package(Cython 0.29.14 REQUIRED)
find_package(PythonHeaders REQUIRED)
find_package(NumPy REQUIRED)
find_program(IPYTHON_EXECUTABLE NAMES jupyter ipython3 ipython)
Expand Down Expand Up @@ -281,15 +281,7 @@ if(WITH_TESTS)
list(APPEND BOOST_COMPONENTS unit_test_framework)
endif()

set(BOOST_MINIMUM_VERSION "1.66.0")

# old Boost.MPI versions contain a use-after-free bug that seems to only cause
# crashes on 32-bit architectures
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(BOOST_MINIMUM_VERSION "1.67.0")
endif()

find_package(Boost ${BOOST_MINIMUM_VERSION} REQUIRED ${BOOST_COMPONENTS})
find_package(Boost 1.69.0 REQUIRED ${BOOST_COMPONENTS})

#
# Paths
Expand Down
10 changes: 5 additions & 5 deletions doc/sphinx/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ C++ Compiler

Boost
A number of advanced C++ features used by |es| are provided by Boost.
We strongly recommend to use at least Boost 1.67.
We strongly recommend to use at least Boost 1.71.

FFTW
For some algorithms (P\ :math:`^3`\ M), |es| needs the FFTW library
Expand Down Expand Up @@ -86,8 +86,8 @@ are required:

.. code-block:: bash
sudo apt install python3-matplotlib python3-scipy python3-pint ipython3 jupyter-notebook
pip3 install --user 'jupyter_contrib_nbextensions==0.5.1' \
sudo apt install python3-matplotlib python3-pint ipython3 jupyter-notebook
pip3 install --user 'jupyter_contrib_nbextensions==0.5.1' 'python3-scipy>=1.4.0' \
'sphinx>=1.6.7,!=2.1.0,!=3.0.0' 'sphinxcontrib-bibtex>=0.3.5' \
'MDAnalysis>=1.0.0'
jupyter contrib nbextension install --user
Expand Down Expand Up @@ -182,7 +182,7 @@ Run the following commands:
.. code-block:: bash
sudo port selfupdate
sudo port install cmake python37 py37-cython py37-numpy \
sudo port install cmake python37 py37-cython py37-numpy py37-scipy \
openmpi-default fftw-3 +openmpi boost +openmpi +python37 \
doxygen py37-opengl py37-sphinx gsl hdf5 +openmpi \
py37-matplotlib py37-ipython py37-jupyter
Expand All @@ -199,7 +199,7 @@ Run the following commands:
.. code-block:: bash
brew install cmake python cython boost boost-mpi fftw \
doxygen gsl numpy ipython jupyter
doxygen gsl numpy scipy ipython jupyter
brew install hdf5-mpi
brew link --force cython
pip install PyOpenGL matplotlib
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# required scientific packages
numpy>=1.16.2
numpy>=1.17.4
h5py>=2.7.1
# optional scientific packages
scipy>=1.1.0
scipy>=1.4.0
MDAnalysis>=1.0.0
pint>=0.10.1
# optional packages for graphics and external devices
Expand Down
11 changes: 0 additions & 11 deletions src/core/unit_tests/EspressoSystemStandAlone_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,6 @@ namespace utf = boost::unit_test;
#include <unordered_map>
#include <vector>

/* Guard against a bug in Boost versions < 1.68 where fixtures used to skip
* test are not propagated correctly to the testsuite, causing skipped tests
* to trigger a failure of the complete testsuite without any error message.
* More details in ticket https://svn.boost.org/trac10/ticket/12095
*/
#include <boost/serialization/version.hpp>
#if BOOST_VERSION / 100000 == 1 && BOOST_VERSION / 100 % 1000 < 68
int main(int argc, char **argv) {}
#else

namespace espresso {
// ESPResSo system instance
std::unique_ptr<EspressoSystemStandAlone> system;
Expand Down Expand Up @@ -329,4 +319,3 @@ int main(int argc, char **argv) {

return boost::unit_test::unit_test_main(init_unit_test, argc, argv);
}
#endif // Boost version >= 1.68
4 changes: 2 additions & 2 deletions src/python/espressomd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def missing_features(*args):

if len(args) == 1 and not isinstance(
args[0], str) and hasattr(args[0], "__iter__"):
return set(args[0]) - set(features())
return sorted(set(args[0]) - set(features()))

return set(args) - set(features())
return sorted(set(args) - set(features()))


def assert_features(*args):
Expand Down
1 change: 1 addition & 0 deletions testsuite/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ python_test(FILE observable_chain.py MAX_NUM_PROC 4)
python_test(FILE mpiio.py MAX_NUM_PROC 4)
python_test(FILE gpu_availability.py MAX_NUM_PROC 2 LABELS gpu)
python_test(FILE features.py MAX_NUM_PROC 1)
python_test(FILE decorators.py MAX_NUM_PROC 1)
python_test(FILE galilei.py MAX_NUM_PROC 32)
python_test(FILE linear_momentum.py MAX_NUM_PROC 4)
python_test(FILE linear_momentum_lb.py MAX_NUM_PROC 2 LABELS gpu)
Expand Down
84 changes: 84 additions & 0 deletions testsuite/python/decorators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright (C) 2021 The ESPResSo project
#
# This file is part of ESPResSo.
#
# ESPResSo is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ESPResSo is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import espressomd
import unittest as ut
import unittest_decorators as utx
import numpy as np


class Tests(ut.TestCase):

def get_skip_reason(self, decorator):
try:
decorator(lambda: None)()
except ut.case.SkipTest as err:
return err.args

def test_version_requirements(self):
fun = utx.skipIfUnmetModuleVersionRequirement
decorator = fun('numpy___', '>' + np.__version__)
args = self.get_skip_reason(decorator)
self.assertEqual(
args, ('Skipping test: missing python module numpy___',))
decorator = fun('numpy', '>1' + np.__version__)
args = self.get_skip_reason(decorator)
self.assertEqual(
args, ('Skipping test: version requirement not met for module numpy',))
decorator = fun('numpy', '==' + np.__version__)
args = self.get_skip_reason(decorator)
self.assertIsNone(args)

def test_missing_modules(self):
err_msg = 'Skipping test: missing python '
decorator = utx.skipIfMissingModules('numpy___')
args = self.get_skip_reason(decorator)
self.assertEqual(args, (err_msg + 'module numpy___',))
decorator = utx.skipIfMissingModules('numpy___', 'scipy___')
args = self.get_skip_reason(decorator)
self.assertEqual(args, (err_msg + 'modules numpy___, scipy___',))
decorator = utx.skipIfMissingModules(['numpy___', 'scipy___'])
args = self.get_skip_reason(decorator)
self.assertEqual(args, (err_msg + 'modules numpy___, scipy___',))

def test_missing_gpu(self):
espressomd.gpu_available = lambda: False
decorator = utx.skipIfMissingGPU()
args = self.get_skip_reason(decorator)
self.assertEqual(args, ('Skipping test: no GPU available',))
espressomd.gpu_available = lambda: True
decorator = utx.skipIfMissingGPU()
args = self.get_skip_reason(decorator)
self.assertIsNone(args)

def test_missing_features(self):
err_msg = 'Skipping test: missing features '
espressomd.has_features = lambda x: False
decorator = utx.skipIfMissingFeatures('UNKNOWN')
args = self.get_skip_reason(decorator)
self.assertEqual(args, (err_msg + 'UNKNOWN',))
decorator = utx.skipIfMissingFeatures(['UNKNOWN1', 'UNKNOWN2'])
args = self.get_skip_reason(decorator)
self.assertEqual(args, (err_msg + 'UNKNOWN1, UNKNOWN2',))
espressomd.has_features = lambda x: True
decorator = utx.skipIfMissingFeatures('KNOWN')
args = self.get_skip_reason(decorator)
self.assertIsNone(args)


if __name__ == '__main__':
ut.main()
15 changes: 4 additions & 11 deletions testsuite/python/rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import numpy as np
import scipy.spatial.transform
import unittest as ut

try:
import scipy.spatial.transform as sst
except ImportError:
pass

import espressomd.rotation
import unittest_decorators as utx


@utx.skipIfUnmetModuleVersionRequirement('scipy', '>=1.4.0')
class TestRotation(ut.TestCase):
"""
Tests for the rotation utility functions.
Expand All @@ -39,7 +33,7 @@ def setUp(self):
angle = 2.0 * np.pi * np.random.random()
quat = [np.sin(angle / 2.0), np.sin(angle / 2.0),
np.sin(angle / 2.0), np.cos(angle / 2.0)]
self.rotation = sst.Rotation.from_quat(quat)
self.rotation = scipy.spatial.transform.Rotation.from_quat(quat)

def test_quat_from_matrix(self):
"""
Expand All @@ -50,7 +44,7 @@ def test_quat_from_matrix(self):
rotated_vector_ref = self.rotation.apply(v_x)
quat_from_matrix = espressomd.rotation.matrix_to_quat(
self.rotation.as_matrix())
rotated_vector_matrix = sst.Rotation.from_quat(
rotated_vector_matrix = scipy.spatial.transform.Rotation.from_quat(
np.roll(quat_from_matrix, shift=-1)).apply(v_x)
self.assertAlmostEqual(
np.dot(rotated_vector_ref, rotated_vector_matrix), 1.0)
Expand Down Expand Up @@ -162,7 +156,6 @@ def test_right_handedness_eigenvectormatrix(self):
np.testing.assert_allclose(
np.cross(ev[0], ev[1]), ev[2], atol=1e-7)

@utx.skipIfUnmetModuleVersionRequirement('scipy', '>1.2.0')
def test_inertia_tensor_rotated_cuboid(self):
"""
Rotate the samples and check that the principal axes return by the
Expand All @@ -172,7 +165,7 @@ def test_inertia_tensor_rotated_cuboid(self):
angle = 2.0 * np.pi * np.random.random()
quat = [np.sin(angle / 2.0), np.sin(angle / 2.0),
np.sin(angle / 2.0), np.cos(angle / 2.0)]
rotation = sst.Rotation.from_quat(quat)
rotation = scipy.spatial.transform.Rotation.from_quat(quat)
rotated_samples = rotation.apply(self.samples)
_, eigenvectors = espressomd.rotation.diagonalized_inertia_tensor(
rotated_samples, self.masses)
Expand Down
4 changes: 2 additions & 2 deletions testsuite/python/unittest_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def skipIfMissingModules(*args):
args = set(args[0])
else:
args = set(args)
missing_modules = set(args) - set(sys.modules.keys())
missing_modules = sorted(set(args) - set(sys.modules.keys()))
if missing_modules:
return unittest.skip("Skipping test: missing python module{} {}".format(
's' if missing_modules else '', ', '.join(missing_modules)))
's' if len(missing_modules) > 1 else '', ', '.join(missing_modules)))
return no_skip


Expand Down
4 changes: 0 additions & 4 deletions testsuite/scripts/tutorials/test_active_matter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import unittest as ut
import importlib_wrapper
import numpy as np
import scipy
import setuptools

tutorial, skipIfMissingFeatures = importlib_wrapper.configure_and_import(
"@TUTORIALS_DIR@/active_matter/active_matter.py",
Expand Down Expand Up @@ -55,8 +53,6 @@ def test_hydrodynamics(self):
tutorial.system.analysis.linear_momentum(
include_particles=False)[2], 0)

@ut.skipIf(not setuptools.version.pkg_resources.packaging.specifiers.SpecifierSet('>=1.4.0').contains(
scipy.__version__), "Skipping test: scipy version requirement (>=1.4.0) not met")
def test_quaternion(self):
""" Check the quaternion function is correctly implemented
"""
Expand Down

0 comments on commit 1d27884

Please sign in to comment.