Python tests suggest that gmxapi cannot be used with GROMACS in double precision from 2021.4 on
Summary
When compiling GROMACS 2021.4 in double precision and with -DGMX_PYTHON_PACKAGE=ON, the gmxapi-related python test test_binding_protocol fails with an assertion error. For GROMACS 2021.3, the compilation protocol discussed here worked fine. Both times, the gmxapi version shipped with the GROMACS source code was used.
GROMACS version
2021.4; later versions may also be affected.
What is the current bug behavior?
============================= test session starts ==============================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: gromacs-2021.4/python_packaging/sample_restraint/tests, configfile: pytest.ini
plugins: hypothesis-6.30.0
collected 4 items
../../python_packaging/sample_restraint/tests/test_plugin.py::test_import PASSED [ 25%]
../../python_packaging/sample_restraint/tests/test_plugin.py::test_binding_protocol FAILED [ 50%]
../../python_packaging/sample_restraint/tests/test_plugin.py::test_ensemble_potential_nompi PASSED [ 75%]
../../python_packaging/sample_restraint/tests/test_plugin.py::test_ensemble_potential_withmpi SKIPPED [100%]
=================================== FAILURES ===================================
____________________________ test_binding_protocol _____________________________
spc_water_box = '/tmp/tmpq6movvnr/topol.tpr', mdrun_kwargs = {}
@pytest.mark.usefixtures("cleandir")
def test_binding_protocol(spc_water_box, mdrun_kwargs):
"""Test that gmxapi successfully attaches MD plugins."""
import myplugin>
if _MPI is not None:
_size = _MPI.COMM_WORLD.Get_size()
_rank = _MPI.COMM_WORLD.Get_rank()
else:
_size = 1
_rank = 0
tpr_filename = spc_water_box
logger.info("Testing plugin potential with input file {}".format(os.path.abspath(tpr_filename)))
assert gmx.version.api_is_at_least(0, 2, 1)
md = from_tpr([tpr_filename] * _size, append_output=False, **mdrun_kwargs)
potential = WorkElement(namespace="myplugin",
operation="null_restraint",
params={'sites': [1, 4]})
potential.name = "null restraint"
md.add_dependency(potential)
context = Context(md)
with context as session:
session.run()
# See also #3038, #3145, #4079
assert isinstance(context.potentials, list)
assert len(context.potentials) > 0
for restraint in context.potentials:
if isinstance(restraint, myplugin.NullRestraint):
> assert restraint.count() > 1
E assert 0 > 1
E + where 0 = <bound method PyCapsule.count of <myplugin.NullRestraint object at 0x7fd4d512e5f0>>()
E + where <bound method PyCapsule.count of <myplugin.NullRestraint object at 0x7fd4d512e5f0>> = > > >
<myplugin.NullRestraint object at 0x7fd4d512e5f0>.count
gromacs-2021.4/python_packaging/sample_restraint/tests/test_plugin.py:76: AssertionError
----------------------------- Captured stdout call -----------------------------
null restraint received pygmx holder containing spec of size 0
----------------------------- Captured stderr call -----------------------------
Steps to reproduce
- compiled on Ubuntu 20.04
- software/library versions: GCC 9.3, CMake 3.19, CUDA 11.2.1, OpenMPI 4.0.4, hwloc 2.4.1, fftw 3.3.9, Python 3.8.10
- CMake flags: -DGMX_OPENMP=ON -DGMX_HWLOC=ON -DGMX_PYTHON_PACKAGE=ON -DGMX_EXTERNAL_BLAS=OFF -DGMX_EXTERNAL_LAPACK=OFF -DGMX_BUILD_UNITTESTS=ON -DREGRESSIONTEST_DOWNLOAD=ON -DGMX_SIMD=SSE2/SSE4.1/AVX_256 -DGMX_GPU=OFF -DGMX_MPI=OFF -DGMX_THREAD_MPI=ON -DGMX_DOUBLE=ON