PYTEST-MPI(1) | pytest-mpi | PYTEST-MPI(1) |
pytest-mpi - pytest-mpi Documentation
pytest-mpi provides a number of things to assist with using pytest with MPI-using code, specifically:
Further features will be added in the future, and contribution of features is very much welcomed.
The important thing to remember is that pytest-mpi assists with running tests when pytest is run under MPI, rather than launching pytest under MPI. To actually run the tests under MPI, you will want to run something like:
$ mpirun -n 2 python -m pytest --with-mpi
Note that by default the MPI tests are not run—this makes it easy to run the non-MPI parts of a test suite without having to worry about installing MPI and mpi4py.
An simple test using the mpi marker managed by pytest-mpi is:
import pytest @pytest.mark.mpi def test_size():
from mpi4py import MPI
comm = MPI.COMM_WORLD
assert comm.size > 0
This test will be automatically be skipped unless --with-mpi is used. We can also specify a minimum number of processes required to run the test:
import pytest @pytest.mark.mpi(min_size=2) def test_size():
from mpi4py import MPI
comm = MPI.COMM_WORLD
assert comm.size >= 2
There are also mpi_skip, for when a test should not be run under MPI (e.g. it causes a lockup or segmentation fault), and mpi_xfail, for when a test should succeed when run normally, but fail when run under MPI.
Specify that this test requires at least min_size processes to run. If there are insufficient processes, skip this test.
For example:
import pytest @pytest.mark.mpi(minsize=4) def test_mpi_feature():
...
This function avoids the need to ensure that only one process handles the naming of temporary files.
This function avoids the need to ensure that only one process handles the naming of temporary folders.
This function avoids the need to ensure that only one process handles the naming of temporary folders.
Initial version
We welcome contributions to pytest-mpi, subject to our code of conduct whether it is improvements to the documentation or examples, bug reports or code improvements.
Bugs should be reported to https://github.com/aragilar/pytest-mpi. Please include what version of Python this occurs on, as well as which operating system. Information about your h5py and HDF5 configuration is also helpful.
The main repository is https://github.com/aragilar/pytest-mpi, please make pull requests against that repository, and the branch that pull requests should be made on is master (backporting fixes will be done separately if necessary).
pytest-mpi uses tox to run its tests. See https://tox.readthedocs.io/en/latest/ for more information about tox, but the simplest method is to run:
tox
in the top level of the git repository.
Current minimal working method (this doesn't produce a release commit, deal with DOIs needing to be preregistered, not automated, not signed etc.):
James Tocknell
2021, James Tocknell
February 2, 2021 | 0+unknown |