Specify OMP_NUM_THREADS for Pyhon CI scripts.
[gromacs.git] / admin / ci-scripts / build-and-test-py-gmxapi-0.1.sh
bloba48cd4ca19ba70276277bac53b7e25641eab4604
1 #!/usr/bin/env bash
3 # Build, install, and test the gmxapi 0.1.x Python package distributed with
4 # GROMACS 2020.
6 # It is assumed that this script is run in an activated Python venv with the
7 # gmxapi dependencies already installed, with `python` resolvable by the shell
8 # to the appropriate Python interpreter.
10 # This script is intended to support automated GROMACS testing infrastructure,
11 # and may be removed without notice.
13 # WARNING: This script assumes OpenMPI mpiexec. Syntax for launch wrappers from
14 # other implementations will need different syntax, and we should get a
15 # MPIRUNNER from the environment, or something.
17 # Make sure the script errors if any commands error.
18 set -e
20 # Create "sdist" source distribution archive.
21 pushd python_packaging/src
22 GMXTOOLCHAINDIR=$INSTALL_DIR/share/cmake/gromacs \
23 python setup.py sdist
24 # TODO: Identify SDIST
26 # Build and install from sdist.
27 GMXTOOLCHAINDIR=$INSTALL_DIR/share/cmake/gromacs \
28 python -m pip install \
29 --no-cache-dir \
30 --no-deps \
31 --no-index \
32 --no-build-isolation \
33 dist/gmxapi*
34 # TODO: Build and install from $SDIST instead of wildcard.
35 popd
37 # Run Python unit tests.
38 python -m pytest $PWD/python_packaging/src/test --junitxml=$PY_UNIT_TEST_XML
40 # Note: Multiple pytest processes getting --junitxml output file argument
41 # may cause problems, so we set the option on only one of the launched processes.
42 # See also Multiple Instruction Multiple Data Model for OpenMPI mpirun:
43 # https://www.open-mpi.org/doc/v3.0/man1/mpiexec.1.php
44 PROGRAM=(`which python` -m mpi4py -m pytest \
45 -p no:cacheprovider \
46 $PWD/python_packaging/src/test)
47 # shellcheck disable=SC2068
48 if [ -x `which mpiexec` ]; then
49 PYTHONDONTWRITEBYTECODE=1 \
50 mpiexec --allow-run-as-root \
51 -x OMP_NUM_THREADS=1 \
52 --mca opal_warn_on_missing_libcuda 0 \
53 --mca orte_base_help_aggregate 0 \
54 -n 1 ${PROGRAM[@]} --junitxml=$PLUGIN_MPI_TEST_XML : \
55 -n 1 ${PROGRAM[@]}
58 # Run Python acceptance tests.
59 python -m pytest $PWD/python_packaging/test --junitxml=$PY_ACCEPTANCE_TEST_XML
61 # Note: Multiple pytest processes getting --junitxml output file argument
62 # may cause problems, so we set the option on only one of the launched processes.
63 # See also Multiple Instruction Multiple Data Model for OpenMPI mpirun:
64 # https://www.open-mpi.org/doc/v3.0/man1/mpiexec.1.php
65 PROGRAM=(`which python` -m mpi4py -m pytest \
66 -p no:cacheprovider \
67 $PWD/python_packaging/test)
68 # shellcheck disable=SC2068
69 if [ -x `which mpiexec` ]; then
70 PYTHONDONTWRITEBYTECODE=1 \
71 mpiexec --allow-run-as-root \
72 -x OMP_NUM_THREADS=1 \
73 --mca opal_warn_on_missing_libcuda 0 \
74 --mca orte_base_help_aggregate 0 \
75 -n 1 ${PROGRAM[@]} --junitxml=$PLUGIN_MPI_TEST_XML : \
76 -n 1 ${PROGRAM[@]}