| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # shellcheck disable=SC2086 |
| 3 | |
| 4 | RUNscip-shell shell shell-project 0.0.0 RUN().() { echoscip-shell system . . echo. + "$@"; "$@"; } |
| 5 | RUNscip-shell shell shell-project 0.0.0 RUN(). export ANACONDA=${ANACONDA-/opt/conda} |
| 6 | |
| 7 | install-miniforgescip-shell shell shell-project 0.0.0 install-miniforge().() { |
| 8 | local PROJECT=https://github.com/conda-forge/miniforge |
| 9 | local BASEURL=$PROJECT/releases/latest/download |
| 10 | local INSTALLER=Miniforge3-Linux-x86_64.sh |
| 11 | RUNscip-shell shell shell-project 0.0.0 RUN(). curl -sSL -o ~/$INSTALLER $BASEURL/$INSTALLER |
| 12 | RUNscip-shell shell shell-project 0.0.0 RUN(). bash ~/$INSTALLER -b -f -p $ANACONDA |
| 13 | RUNscip-shell shell shell-project 0.0.0 RUN(). source $ANACONDA/bin/activate base |
| 14 | RUNscip-shell shell shell-project 0.0.0 RUN(). conda config --set channel_priority strict |
| 15 | RUNscip-shell shell shell-project 0.0.0 RUN(). conda config --set show_channel_urls yes |
| 16 | RUNscip-shell shell shell-project 0.0.0 RUN(). conda deactivate |
| 17 | } |
| 18 | |
| 19 | parse-argsscip-shell shell shell-project 0.0.0 parse-args().() { |
| 20 | unset PY |
| 21 | unset MPI |
| 22 | unset RUNTESTS |
| 23 | unset COVERAGE |
| 24 | for arg in "$@"; do |
| 25 | case $arg in |
| 26 | python=?*) |
| 27 | PY="${arg#*=}";; |
| 28 | py=?*) |
| 29 | PY="${arg#*=}";; |
| 30 | MPI=?*) |
| 31 | MPI="${arg#*=}";; |
| 32 | mpi=?*) |
| 33 | MPI="${arg#*=}";; |
| 34 | runtests=?*) |
| 35 | RUNTESTS="${arg#*=}";; |
| 36 | coverage=?*) |
| 37 | COVERAGE="${arg#*=}";; |
| 38 | *) |
| 39 | break |
| 40 | esac |
| 41 | done |
| 42 | PY=${PY-3} |
| 43 | MPI=${MPI-mpich} |
| 44 | ENV=py$PY-$MPI |
| 45 | RUNTESTS=${RUNTESTS-no} |
| 46 | COVERAGE=${COVERAGE-no} |
| 47 | } |
| 48 | |
| 49 | create-envscip-shell shell shell-project 0.0.0 create-env().() { |
| 50 | parse-argsscip-shell shell shell-project 0.0.0 parse-args(). "$@" |
| 51 | RUNscip-shell shell shell-project 0.0.0 RUN(). rm -rf $ANACONDA/envs/$ENV |
| 52 | RUNscip-shell shell shell-project 0.0.0 RUN(). source $ANACONDA/bin/activate base |
| 53 | local packages=( |
| 54 | python="$PY" "$MPI" "$MPI-mpicc" |
| 55 | setuptools numpy cython'<3.1' coverage |
| 56 | ) |
| 57 | RUNscip-shell shell shell-project 0.0.0 RUN(). mamba create --yes -n $ENV "${packages[@]}" |
| 58 | RUNscip-shell shell shell-project 0.0.0 RUN(). conda deactivate |
| 59 | } |
| 60 | |
| 61 | package-installscip-shell shell shell-project 0.0.0 package-install().() { |
| 62 | parse-argsscip-shell shell shell-project 0.0.0 parse-args(). "$@" |
| 63 | RUNscip-shell shell shell-project 0.0.0 RUN(). source $ANACONDA/bin/activate $ENV |
| 64 | RUNscip-shell shell shell-project 0.0.0 RUN(). python setup.py build_src --force |
| 65 | RUNscip-shell shell shell-project 0.0.0 RUN(). python setup.py install |
| 66 | RUNscip-shell shell shell-project 0.0.0 RUN(). python setup.py --quiet clean --all |
| 67 | RUNscip-shell shell shell-project 0.0.0 RUN(). conda deactivate |
| 68 | } |
| 69 | |
| 70 | package-testingscip-shell shell shell-project 0.0.0 package-testing().() { |
| 71 | parse-argsscip-shell shell shell-project 0.0.0 parse-args(). "$@" |
| 72 | RUNscip-shell shell shell-project 0.0.0 RUN(). source $ANACONDA/bin/activate $ENV |
| 73 | RUNscip-shell shell shell-project 0.0.0 RUN(). python -m mpi4py --version |
| 74 | if [[ "$RUNTESTS" == "yes" ]]; then |
| 75 | if [[ "$MPI" == "mpich" ]]; then local P=2; else local P=5; fi |
| 76 | local MPIEXEC=${MPIEXEC-mpiexec} |
| 77 | RUNscip-shell shell shell-project 0.0.0 RUN(). $MPIEXEC -n 1 python $PWD/test/main.py |
| 78 | RUNscip-shell shell shell-project 0.0.0 RUN(). $MPIEXEC -n $P python $PWD/test/main.py -f |
| 79 | RUNscip-shell shell shell-project 0.0.0 RUN(). $MPIEXEC -n 1 python $PWD/demo/futures/test_futures.py |
| 80 | RUNscip-shell shell shell-project 0.0.0 RUN(). $MPIEXEC -n $P python $PWD/demo/futures/test_futures.py -f |
| 81 | RUNscip-shell shell shell-project 0.0.0 RUN(). $MPIEXEC -n 1 python -m mpi4py.futures $PWD/demo/futures/test_futures.py |
| 82 | RUNscip-shell shell shell-project 0.0.0 RUN(). $MPIEXEC -n $P python -m mpi4py.futures $PWD/demo/futures/test_futures.py -f |
| 83 | RUNscip-shell shell shell-project 0.0.0 RUN(). python $PWD/demo/test-run/test_run.py |
| 84 | fi |
| 85 | if [[ "$COVERAGE" == "yes" ]]; then |
| 86 | RUNscip-shell shell shell-project 0.0.0 RUN(). test/coverage.sh |
| 87 | RUNscip-shell shell shell-project 0.0.0 RUN(). coverage report |
| 88 | RUNscip-shell shell shell-project 0.0.0 RUN(). coverage xml |
| 89 | RUNscip-shell shell shell-project 0.0.0 RUN(). mv coverage.xml coverage-"py$PY-$MPI-$(unamescip-shell system . . uname.)".xml |
| 90 | fi |
| 91 | RUNscip-shell shell shell-project 0.0.0 RUN(). conda deactivate |
| 92 | } |