From 76a985a34404a203474a60a3c6441f2125e38e42 Mon Sep 17 00:00:00 2001 From: JM Etancelin <jean-matthieu.metancelin@univ-pau.fr> Date: Wed, 13 Nov 2024 23:02:28 +0100 Subject: [PATCH] cleanup in ci scripts --- README.md | 76 ++------- ci/scripts/build.sh | 53 ------ ci/scripts/build_and_debug.sh | 61 ------- ci/scripts/change_string_files_recursive.sh | 1 - ci/scripts/clean_ci.sh | 147 ---------------- ci/scripts/git_tag_from_hysop_version.sh | 33 ---- ci/scripts/hysop_user_tests.sh | 26 --- ci/scripts/install.sh | 56 ------ ci/scripts/test.sh | 178 -------------------- ci/scripts/version.sh | 3 +- ci/{scripts => utils}/build_and_test.sh | 6 +- ci/utils/build_docker_image.bat | 26 --- ci/utils/build_docker_image.sh | 27 --- ci/utils/pull_docker_image.bat | 31 ---- ci/utils/pull_docker_image.sh | 31 ---- ci/utils/push_docker_image.bat | 25 --- ci/utils/push_docker_image.sh | 31 ---- ci/utils/run_ci.bat | 43 ----- ci/utils/run_ci.sh | 8 +- ci/utils/run_debug.bat | 43 ----- ci/utils/run_debug.sh | 46 ----- ci/utils/run_docker_image.bat | 27 --- ci/utils/run_docker_image.sh | 3 +- ci/utils/run_user_docker_image.sh | 49 ------ 24 files changed, 25 insertions(+), 1005 deletions(-) delete mode 100755 ci/scripts/build.sh delete mode 100755 ci/scripts/build_and_debug.sh delete mode 100755 ci/scripts/change_string_files_recursive.sh delete mode 100755 ci/scripts/clean_ci.sh delete mode 100755 ci/scripts/git_tag_from_hysop_version.sh delete mode 100755 ci/scripts/hysop_user_tests.sh delete mode 100755 ci/scripts/install.sh delete mode 100755 ci/scripts/test.sh rename ci/{scripts => utils}/build_and_test.sh (89%) delete mode 100755 ci/utils/build_docker_image.bat delete mode 100755 ci/utils/build_docker_image.sh delete mode 100755 ci/utils/pull_docker_image.bat delete mode 100755 ci/utils/pull_docker_image.sh delete mode 100755 ci/utils/push_docker_image.bat delete mode 100755 ci/utils/push_docker_image.sh delete mode 100644 ci/utils/run_ci.bat delete mode 100644 ci/utils/run_debug.bat delete mode 100755 ci/utils/run_debug.sh delete mode 100755 ci/utils/run_docker_image.bat delete mode 100755 ci/utils/run_user_docker_image.sh diff --git a/README.md b/README.md index 46a7a5a52..9eed8f55c 100644 --- a/README.md +++ b/README.md @@ -85,60 +85,24 @@ git clone https://gricad-gitlab.univ-grenoble-alpes.fr/hysop.git cd hysop ``` -Then HySoP Docker Container can be submitted with this script: -``` -./ci/utils/run_user_docker_image.sh [imgname] -``` -This script downloads the HySoP Docker Image (if required), -mounts your local directory 'hysop' inside the Docker Container -and launches a shell `(base) xxx@yyyyyyy:/home/$USER`. - -Now there's a connection between your Docker Container and -the 'hysop' directory on your host machine. -You can read and write to the 'hysop' directory -directly from the Docker Container. -When you leave your Docker Container, -changes made in the 'hysop' directory will still be available. - -To quickly test HySoP inside a Docker Container you can submit this script -``` -./ci/scripts/hysop_user_tests.sh -``` -which will build HySoP using [meson build system](https://mesonbuild.com/) (if needed) and submit tests. +Then HySoP Docker Container can run with everything needed to use hysop, but hysop: -By default, `[imgname]` is `hysop_user_cpu_intel`, -which corresponds to Ubuntu 22.04 running with python3.12 on Intel CPU. -Try out this command to run HySoP on Nvidia GPUs: ``` -./ci/utils/run_user_docker_image.sh hysop_user_gpu_nvidia +docker run -v $(pwd):/home/hysop-user/shared --rm -ti gricad-registry.univ-grenoble-alpes.fr/particle_methods/hysop/[imagename] ``` -(it requires host system driver compatible with cuda 12.0). - -**Build a HySoP Docker Image:** - -Root HySoP Docker Images can be build locally by using the -`./ci/utils/build_docker_image.sh [imgname]` script. -It is advised to build Docker Image only if the pull fails or if you want -to add/update dependencies (modification of a Dokerfile). +Your local directory 'hysop' is then shared inside the Docker Container in `shared` directory. -By default, `[imgname]` is `ci_cpu_intel`, -which corresponds to Ubuntu 22.04 running with python3.12 on Intel CPU. -`ci_gpu_nvidia` is also available for Nvidia GPUs. +* `[imgname]` is either `ci_cpu_intel`, +which corresponds to Ubuntu 22.04 running with python3.12 and an Intel CPU OpenCL platform, or `ci_gpu_nvidia`, with an Nvidia GPU OpenCL platform (it requires host system driver compatible with cuda 12.0). -To quickly test HySoP inside a Docker Container you can run -`./ci/scripts/build_and_test.sh` which will build HySoP -using meson and submit tests. - -There are equivalent `*.bat` scripts to run on Windows (not tested). -Please note that the nvidia enabled images currently do not work -on Windows due to this [bug](https://github.com/microsoft/WSL/issues/6951). +Next step is to install HySoP manually inside this containeri (see [installation instruction](#installation)). From Sources: ============ -Installation: ------------- +Prerequisites: +-------------- [Micomamba packaged manager](https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html) is used to manage HySoP environments. Download lastest HySoP: @@ -147,26 +111,27 @@ git clone https://gricad-gitlab.univ-grenoble-alpes.fr/hysop.git cd hysop ``` -Create and activate a micromamba environment for HySoP: +We recommend to create and activate a micromamba environment for HySoP: ``` micromamba create -n hysop_cpu_intel python=3.12.4 -f ci/hysopenv_cpu_intel.yaml micromamba activate hysop_cpu_intel ``` -or +for Intel CPU OpenCL platform or ``` micromamba create -n hysop_gpu_nvidia python=3.12.4 -f ci/hysopenv_gpu_nvidia.yaml micromamba activate hysop_gpu_nvidia ``` +with Nvidia OpenCL platform. -**Before installing the HySoP library, you may need to install some dependencies!** -(see below) +Installation: +------------- Install HySoP using [pip](https://pypi.org/project/pip/): ``` pip install --no-build-isolation --no-deps . ``` -Install HySoP using [meson](https://mesonbuild.com/): +Install HySoP manually step by step using [meson](https://mesonbuild.com/): ``` export BUILD_DIR=builddir meson setup ${BUILD_DIR} @@ -214,17 +179,6 @@ HySoP installation: ``` python3 -c "import hysop; print(hysop); print(dir(hysop))" python3 -c "from hysop import f2hysop; print(f2hysop);print(dir(f2hysop))" -``` - -Warning: some tests may FAIL if all dependencies are not installed. See below - -HySoP tests: -``` -./ci/scripts/test.sh -``` - -Using meson: -``` meson test -C ${BUILD_DIR} ``` @@ -244,7 +198,7 @@ Installing HySoP dependencies can be a lengthy process. That's why we prefer to The quickest and easiest way to discover all the HySoP dependencies and how to install them is to explore the `Dockerfile`: ``` -./ci/docker_images/ci_cpu_intel/Dockerfile +./ci/docker_images/ci_user/Dockerfile ``` **NVIDIA driver**: diff --git a/ci/scripts/build.sh b/ci/scripts/build.sh deleted file mode 100755 index 08cb44a21..000000000 --- a/ci/scripts/build.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash -## -## Copyright (c) HySoP 2011-2024 -## -## This file is part of HySoP software. -## See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -## for further info. -## -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## -set -feu -o pipefail - -# /hysop should be mounted as read only by run_tests_in_docker.sh -if [[ ! -d '/hysop' ]]; then - echo "This script should not be called from host, but from within a docker image." - echo " => /hysop has not been mounted (see hysop/ci/utils/run_ci.sh)." - exit 1 -fi - -HYSOP_DIR='/tmp/hysop' -HYSOP_BUILD_DIR="builddir" -SCRIPT_DIR="${HYSOP_DIR}/ci/scripts" -export CI_PROJECT_DIR=${HYSOP_DIR} -export BUILD_DIR=${HYSOP_DIR}/${HYSOP_BUILD_DIR} - -\rm -fr ${HYSOP_DIR} -cp -r /hysop "${HYSOP_DIR}" - -cd "${HYSOP_DIR}" -#${SCRIPT_DIR}/version.sh -meson setup ${HYSOP_BUILD_DIR} -meson compile -C ${HYSOP_BUILD_DIR} -meson install -C ${HYSOP_BUILD_DIR} - -# NG 19 mars 2024: TODO build PYTHONPATH ! -echo "" -echo "***********" -echo "IMPORTANT:" -echo "- directory where hysop source codes are" -echo "$> cd ${HYSOP_DIR}" -echo "***********" - -exit 0 diff --git a/ci/scripts/build_and_debug.sh b/ci/scripts/build_and_debug.sh deleted file mode 100755 index fe5908cd9..000000000 --- a/ci/scripts/build_and_debug.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env bash -## -## Copyright (c) HySoP 2011-2024 -## -## This file is part of HySoP software. -## See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -## for further info. -## -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## -set -feu -o pipefail - -# Ensure that required variables are set. -: ${CI_PROJECT_DIR:?"Please set environment variable CI_PROJECT_DIR equal to the path to hysop sources."} - -BUILD_DIR="${BUILD_DIR:=$HOME/build}" - -meson setup $BUILD_DIR $CI_PROJECT_DIR -meson compile -C $BUILD_DIR - -# /hysop should be mounted as read only by run_tests_in_docker.sh -#if [[ ! -d '/hysop' ]]; then -# echo "This script should not be called from host, but from within a docker image." -# echo " => /hysop has not been mounted (see hysop/ci/utils/run_debug.sh)." -# exit 1 -#fi - -##CC=gcc -#CXX=g++ -#FC=gfortran - -#HYSOP_DIR='/tmp/hysop' - -#cp -r /hysop "${HYSOP_DIR}" -#find "${HYSOP_DIR}" -name '*.sh' -exec sed -i 's/\r//' '{}' \; -#rm -rf "${HYSOP_DIR}/build" - -#cd "${HYSOP_DIR}" -#mkdir build -#cd build -#cmake -DCMAKE_BUILD_TYPE=Debug -DVERBOSE=OFF -DWITH_SCALES=ON -DFIND_FFTW_STATIC_ONLY=ON -DFIND_FFTW_VERBOSE=ON -DPython3_EXECUTABLE="${PYTHON_EXECUTABLE}" -DPython3_INCLUDE_DIR="${PYTHON_INCLUDE_DIR}" -DPython3_LIBRARY="${PYTHON_LIBRARY}" .. -#make -j8 -#make install -#cd - -#rm -rf build - -#export OMPI_ALLOW_RUN_AS_ROOT=1 -#export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 -#export OMPI_MCA_rmaps_base_oversubscribe=1 - -bash diff --git a/ci/scripts/change_string_files_recursive.sh b/ci/scripts/change_string_files_recursive.sh deleted file mode 100755 index 6936324c4..000000000 --- a/ci/scripts/change_string_files_recursive.sh +++ /dev/null @@ -1 +0,0 @@ -grep -rl tools.types ./hysop | xargs sed -i s@tools.types@tools.htypes@g diff --git a/ci/scripts/clean_ci.sh b/ci/scripts/clean_ci.sh deleted file mode 100755 index 59521d11e..000000000 --- a/ci/scripts/clean_ci.sh +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env bash -## -## Copyright (c) HySoP 2011-2024 -## -## This file is part of HySoP software. -## See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -## for further info. -## -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## -set -feu -o pipefail - -############################################################################ -# /!\ This script will delete old CI pipelines with logs and atrifacts /!\ # -############################################################################ - -# This script is adapted from https://gist.github.com/mgoellnitz/45f4cbe6fa4d757a1e9803094361b846 -# to conform with gitlab API v4 and requires python2.7 with the json module available - -function print_help { - echo "GitLab continuous integration pipeline cleanup 'clean_ci.sh'" - echo "" - echo "$0 [-u url] [-d date] [-t token] [-p project]" - echo "" - echo " -u instance base url - default https://gricad-gitlab.univ-grenoble-alpes.fr" - echo "" - echo " -n gitlab namespace - defaults to 'particle_methods'." - echo "" - echo " -p project name - defaults to 'hysop'." - echo "" - echo " -d yyyy-mm-dd - date to clean builds before - defaults to one month ago" - echo "" - echo " -t gitlab api token - defaults to \$GITLAB_API_TOKEN" - echo "" - echo "You need a maintainer or owner gitlab token to be able to delete pipeline jobs." - echo "Error message 'Job is not erasable!' means the job has already been erased." - echo "Some job removal may also fail because they did not complete in the pipeline." - exit 1 -} - -function extract_json { - script=${1-"print data['id'];"} - python2.7 -c "import sys, json, operator as op; data=json.load(sys.stdin); ${script}" -} -function api_request { - curl -H "${CONTENT}" -H "${HEADER}" "${1}" 2>/dev/null -} - -GITLAB='https://gricad-gitlab.univ-grenoble-alpes.fr' -NAMESPACE='particle_methods' -PROJECT='hysop' -DATE="$[ $(date +%s) - 2592000 ]" -TOKEN="${GITLAB_API_TOKEN:-}" - -# Parse args -if [[ ${#} -gt 0 ]]; then - PSTART=$(echo ${1} | sed -e 's/^\(.\).*/\1/g') - while [ "$PSTART" = "-" ] ; do - if [ "${1}" = "-u" ] ; then - shift - GITLAB="${1}" - elif [ "${1}" = "-n" ] ; then - shift - NAMESPACE="${1}" - elif [ "${1}" = "-p" ] ; then - shift - PROJECT="${1}" - elif [ "${1}" = "-t" ] ; then - shift - TOKEN="${1}" - elif [ "${1}" = "-d" ] ; then - shift - DATE="$(date -d ${1} +%s)" - else - print_help - fi - shift - PSTART=$(echo ${1} | sed -e 's/^\(.\).*/\1/g') - done - echo "PSTART='${PSTART}'" -fi - -if [[ -z "${GITLAB}" ]]; then - echo "Gitlab url has not been specified." - exit 1 -fi -if [[ -z "${NAMESPACE}" ]]; then - echo "Namespace has not been specified." - exit 1 -fi -if [[ -z "${PROJECT}" ]]; then - echo "Project has not been specified." - exit 1 -fi -if [[ "${TOKEN}" == "" ]]; then - echo "Could not determine gitlab API token, please define GITLAB_API_TOKEN or pass it explicitely." - exit 1 -fi - -echo "Cleaning CI pipelines older than $(date -d @${DATE}) for project ${GITLAB}/${NAMESPACE}/${PROJECT} with token ${TOKEN}." - -CONTENT='Content-Type: application/json' -HEADER="PRIVATE-TOKEN: ${TOKEN}" - -PROJECT_ID="$(api_request "${GITLAB}/api/v4/projects/${NAMESPACE}%2F${PROJECT}" | extract_json)" -API_URL="${GITLAB}/api/v4/projects/${PROJECT_ID}" -if [[ -z "${PROJECT_ID}" ]]; then - echo "Could not determine project id for project ${GITLAB}/${NAMESPACE}/${PROJECT}." - exit 1 -fi - -page=1 -pipelines=$(api_request "${API_URL}/pipelines?page=${page}&per_page=100" | extract_json "print('\n'.join('{}@{}'.format(d['id'], d['created_at']) for d in sorted(data, reverse=True)))") -until [[ -z "${pipelines}" ]]; do - for pipeline in ${pipelines}; do - pipeline_id="$(echo "${pipeline}" | cut -f1 -d'@')" - pipeline_date="$(echo "${pipeline}" | cut -f2 -d'@' | sed -e 's/^\(.*\)T.*/\1/g')" - PDATE="$(date -d "${pipeline_date}" +%s)" - if [[ "${PDATE}" -ge ${DATE} ]]; then - continue - fi - echo "Found pipeline ${pipeline_id} created on ${pipeline_date}:" - set +e - for job_id in $(api_request "${API_URL}/pipelines/${pipeline_id}/jobs" | extract_json "print '\n'.join(map(str, sorted(map(op.itemgetter('id'), data), reverse=True)))"); do - status="$(curl -H "${CONTENT}" -H "${HEADER}" --request POST "${API_URL}/jobs/${job_id}/erase" 2>/dev/null | extract_json "print data.get('message', data.get('status', 'fail'));")" - echo " | removing job ${job_id}... ${status}" - done - #status="$(curl -H "${CONTENT}" -H "${HEADER}" --request 'DELETE' "${API_URL}/pipelines/${pipeline_id}" 2>/dev/null | extract_json "print data.get('status', data.get('message', 'fail'));")" - #echo " | removing pipeline ${pipeline_id}... ${status}" - # Not working yet, requires to be owner ? - set -e - done; - page=$((${page}+1)) - pipelines=$(api_request "${API_URL}/pipelines?page=${page}&per_page=100" | extract_json "print('\n'.join('{}@{}'.format(d['id'], d['created_at']) for d in sorted(data, reverse=True)))") - break -done; -exit 0 diff --git a/ci/scripts/git_tag_from_hysop_version.sh b/ci/scripts/git_tag_from_hysop_version.sh deleted file mode 100755 index 0409a0e3a..000000000 --- a/ci/scripts/git_tag_from_hysop_version.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -## -## Copyright (c) HySoP 2011-2024 -## -## This file is part of HySoP software. -## See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -## for further info. -## -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## - - -# Only show most recent tag without trailing commit information -git describe --tags | awk "{split(\$0,a,\"-\"); print a[1];}" > version.tmp - -# Only proceed if version number has actually changed (i.e. a new tag has been created) -if [ ! $(cmp --silent version.tmp hysop_version.txt) ] -then - NEWVER=$(cat hysop_version.txt) - echo Adding tag $NEWVER - git tag -a $NEWVER -m '' - rm version.tmp -fi diff --git a/ci/scripts/hysop_user_tests.sh b/ci/scripts/hysop_user_tests.sh deleted file mode 100755 index 4f64b6ee9..000000000 --- a/ci/scripts/hysop_user_tests.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -## -## Copyright (c) HySoP 2011-2024 -## -## This file is part of HySoP software. -## See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -## for further info. -## -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## -set -feu -o pipefail - -HYSOP_BUILD_DIR="builddir" - -meson setup ${HYSOP_BUILD_DIR} -meson test -C ${HYSOP_BUILD_DIR} diff --git a/ci/scripts/install.sh b/ci/scripts/install.sh deleted file mode 100755 index fc4f6fc31..000000000 --- a/ci/scripts/install.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash -## -## Copyright (c) HySoP 2011-2024 -## -## This file is part of HySoP software. -## See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -## for further info. -## -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## - -# PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE:-"$(which python3)"} -# PYTHON_VERSION=$(${PYTHON_EXECUTABLE} -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")') - -# if [ $# -ne 2 ]; then -# echo "Usage ./install build_folder install_folder" -# exit 1 -# fi - -# if [ ! -d "$1" ]; then -# echo "Build folder $1 does not exist." -# exit 1 -# fi - -# if [ -d "$2" ]; then -# echo "Install folder $2 already exists." -# exit 1 -# fi - -# BUILD_FOLDER="$1" -# INSTALL_FOLDER="$2" - -# cd "${BUILD_FOLDER}" -# -cd ${BUILD_DIR} -make install - -if [ ! -d "${INSTALL_FOLDER}/lib/python${PYTHON_VERSION}/site-packages/hysop" ]; then - echo "${INSTALL_FOLDER}/lib/python${PYTHON_VERSION}/site-packages/hysop was not created." - exit 1 -fi - -export PYTHONPATH="${INSTALL_FOLDER}/lib/python${PYTHON_VERSION}/site-packages" -"${PYTHON_EXECUTABLE}" -c 'import hysop; print(hysop)' - -exit 0 diff --git a/ci/scripts/test.sh b/ci/scripts/test.sh deleted file mode 100755 index c37096de8..000000000 --- a/ci/scripts/test.sh +++ /dev/null @@ -1,178 +0,0 @@ -#!/usr/bin/env bash -## -## Copyright (c) HySoP 2011-2024 -## -## This file is part of HySoP software. -## See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -## for further info. -## -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## -set -feu -o pipefail - -PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE:-"$(which python3)"} -PYTHON_VERSION=$(${PYTHON_EXECUTABLE} -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")') - -HYSOP_DIR=${CI_PROJECT_DIR:-.}/hysop - -HYSOP_CACHE_DIR=${HYSOP_CACHE_DIR:-"${HOME}/.cache"} - -##NG 26 sep 2023: comment lines -##NG if [[ -z "${BACKUP_CACHE_DIR}" ]]; then -##NG HAS_BACKUP_CACHE_DIR=false -##NG else -##NG HAS_BACKUP_CACHE_DIR=true -##NG fi -##NG -##NG if [[! -z "${CACHE_DIR}" ]]; then -##NG mkdir -p "${HYSOP_CACHE_DIR}" -##NG if [ -d "${CACHE_DIR}" ]; then -##NG echo "Cache directory '$CACHE_DIR' was found." -##NG rsync -rtu "${CACHE_DIR}/" "${HYSOP_CACHE_DIR}/" -##NG else - -##NG # Untill gitlab allows cache on failure we need -##NG # to provide initial cache so that CI succeeds (< 1h tests) -##NG # See https://gitlab.com/gitlab-org/gitlab/-/issues/18969 -##NG # Initial cache can be injected in the docker image, see hysop/ci/utils/run_ci.sh. -##NG echo "Cache directory '$CACHE_DIR' does not exist, trying to use backup cache directory." -##NG if [[ "${HAS_BACKUP_CACHE_DIR}" = true ]]; then -##NG if [[ -d "${BACKUP_CACHE_DIR}" ]]; then -##NG echo "Backup cache directory '${BACKUP_CACHE_DIR}' was found." -##NG rsync -rtu "${BACKUP_CACHE_DIR}/" "${HYSOP_CACHE_DIR}/" -##NG else -##NG echo "Backup directory '${BACKUP_CACHE_DIR}' does not exist." -##NG fi -##NG else -##NG echo "No backup cache directory has been specified." -##NG fi -##NG fi -##NG mkdir -p "${CACHE_DIR}" -##NG fi -##NG 26 sep 2023: end - -# Environment variables -export PYTHONHASHSEED=42 # get consistent hashes accross MPI processes -export PYOPENCL_COMPILER_OUTPUT=0 -export MPLBACKEND='cairo' - -# OpenMPI specific variables -export OMPI_ALLOW_RUN_AS_ROOT=1 -export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 -export OMPI_MCA_rmaps_base_oversubscribe=1 - -# HySoP specific variables -export HYSOP_VERBOSE=0 -export HYSOP_DEBUG=0 -export HYSOP_PROFILE=0 -export HYSOP_KERNEL_DEBUG=0 -export HYSOP_TRACE_WARNINGS=1 - -echo "Trying to load hysop module:" -${PYTHON_EXECUTABLE} -c 'import hysop; print(hysop); print(dir(hysop))' -echo "module import successful !" -echo - -echo "Default testing OpenCL platform is:" -${PYTHON_EXECUTABLE} -c 'import hysop; from hysop.testsenv import iter_clenv, __HAS_OPENCL_BACKEND__; print(next(iter(iter_clenv())) if __HAS_OPENCL_BACKEND__ else "");' - -RUN_TESTS=${RUN_TESTS:-true} -RUN_EXAMPLES=${RUN_EXAMPLES:-true} -RUN_LONG_TESTS=${RUN_LONG_TESTS:-false} - -# Some examples need fftw, scales, and opencl -if [ $(python3 -c 'import hysop;from hysop import __FFTW_ENABLED__, __SCALES_ENABLED__; from hysop.testsenv import __HAS_OPENCL_BACKEND__; print("true" if not (__FFTW_ENABLED__ and __SCALES_ENABLED__ and __HAS_OPENCL_BACKEND__) else "false")') = true ]; then - RUN_EXAMPLES=false -fi - -COMMON_TEST_OPTIONS='' -TEST_DIR="${HYSOP_DIR}" -COMMON_EXAMPLE_OPTIONS='-VNC -d16 -cp float -maxit 2 --autotuner-max-candidates 1 --save-checkpoint --checkpoint-dump-freq 0 --checkpoint-dump-period 0 --checkpoint-dump-last --checkpoint-dump-times' -EXAMPLE_DIR="${HYSOP_DIR}/../hysop_examples/examples" - -hysop_test() { - test=$1 - echo - echo "TESTING $1" - echo "========$(printf '=%.0s' `seq ${#1}`)" - ${PYTHON_EXECUTABLE} -Wd "${TEST_DIR}/${1}" ${@:2} ${COMMON_TEST_OPTIONS} - echo -} -example_test() { - test=$1 - echo - echo "EXAMPLE $1" - echo "========$(printf '=%.0s' `seq ${#1}`)" - ${PYTHON_EXECUTABLE} -Wd "${EXAMPLE_DIR}/${1}" ${@:2} ${COMMON_EXAMPLE_OPTIONS} - echo -} - - -if [ "$RUN_TESTS" = true ]; then - hysop_test "core/arrays/tests/test_array.py" - hysop_test "core/graph/tests/test_graph.py" - hysop_test "fields/tests/test_fields.py" - hysop_test "numerics/tests/test_fft.py" - hysop_test "operator/tests/test_analytic.py" - hysop_test "operator/tests/test_transpose.py" - hysop_test "operator/tests/test_fd_derivative.py" - hysop_test "operator/tests/test_absorption.py" - hysop_test "operator/tests/test_penalization.py" - hysop_test "operator/tests/test_velocity_correction.py" - hysop_test "operator/tests/test_restriction_filter.py" - hysop_test "operator/tests/test_scales_advection.py" - hysop_test "operator/tests/test_bilevel_advection.py" - hysop_test "operator/tests/test_directional_advection.py" - hysop_test "operator/tests/test_directional_diffusion.py" - hysop_test "operator/tests/test_directional_stretching.py" - hysop_test "operator/tests/test_custom_symbolic.py" - hysop_test "operator/tests/test_custom.py" - hysop_test "operator/tests/test_spectral_derivative.py" - hysop_test "operator/tests/test_spectral_curl.py" - hysop_test "operator/tests/test_diffusion.py" - hysop_test "operator/tests/test_poisson.py" - hysop_test "operator/tests/test_solenoidal_projection.py" - hysop_test "operator/tests/test_poisson_curl.py" - ${HYSOP_DIR}/fields/tests/test_cartesian.sh - ${HYSOP_DIR}/core/tests/test_checkpoint.sh - ${HYSOP_DIR}/core/tests/test_tasks.sh -fi - -if [ "${RUN_LONG_TESTS}" = true ]; then - hysop_test "backend/device/codegen/kernels/tests/test_directional_advection.py" - hysop_test "backend/device/codegen/kernels/tests/test_directional_remesh.py" -fi - -if [ "${RUN_EXAMPLES}" = true ]; then - example_test "analytic/analytic.py" - example_test "scalar_diffusion/scalar_diffusion.py" - example_test "scalar_advection/scalar_advection.py" - example_test "scalar_advection/levelset.py" - example_test "multiresolution/scalar_advection.py" - example_test "shear_layer/shear_layer.py" - example_test "taylor_green/taylor_green.py" '-impl python' - example_test "taylor_green/taylor_green.py" '-impl opencl' - example_test "bubble/periodic_bubble.py" - example_test "bubble/periodic_bubble_levelset.py" - example_test "bubble/periodic_bubble_levelset_penalization.py" #LLVM bug for DP - example_test "bubble/periodic_jet_levelset.py" - example_test "particles_above_salt/particles_above_salt_periodic.py" - example_test "particles_above_salt/particles_above_salt_symmetrized.py" -fi - -##NG if [ "${HAS_CACHE_DIR}" = true ]; then -##NG rsync -rtu "${HYSOP_CACHE_DIR}/" "${CACHE_DIR}/" -##NG find "${CACHE_DIR}" -name '*.lock' -delete -##NG fi - -exit 0 diff --git a/ci/scripts/version.sh b/ci/scripts/version.sh index 17ac70206..97aebf7d1 100755 --- a/ci/scripts/version.sh +++ b/ci/scripts/version.sh @@ -23,8 +23,7 @@ echo "HOST" uname -a echo echo "BUILD TOOLS:" -echo $(cmake --version | head -1) -echo $(make --version | head -1) +echo $(meson --version | head -1) echo $(gcc --version | head -1) echo "f2py version $(f2py -v)" echo diff --git a/ci/scripts/build_and_test.sh b/ci/utils/build_and_test.sh similarity index 89% rename from ci/scripts/build_and_test.sh rename to ci/utils/build_and_test.sh index 7d916c2bb..202968bc3 100755 --- a/ci/scripts/build_and_test.sh +++ b/ci/utils/build_and_test.sh @@ -21,9 +21,9 @@ set -feu -o pipefail # /hysop should be mounted as read only by run_tests_in_docker.sh -if [[ ! -d '/hysop' ]]; then +if [[ ! -d '/home/hysop-user/shared' ]]; then echo "This script should not be called from host, but from within a docker image." - echo " => /hysop has not been mounted (see hysop/ci/utils/run_ci.sh)." + echo " => hysop has not been mounted (see hysop/ci/utils/run_docker_image.sh)." exit 1 fi @@ -34,7 +34,7 @@ export CI_PROJECT_DIR=${HYSOP_DIR} export BUILD_DIR=${HYSOP_DIR}/${HYSOP_BUILD_DIR} \rm -fr ${HYSOP_DIR} -cp -r /hysop "${HYSOP_DIR}" +cp -r /home/hysop-user/shared "${HYSOP_DIR}" cd "${HYSOP_DIR}" ${SCRIPT_DIR}/version.sh diff --git a/ci/utils/build_docker_image.bat b/ci/utils/build_docker_image.bat deleted file mode 100755 index 6121b4e6c..000000000 --- a/ci/utils/build_docker_image.bat +++ /dev/null @@ -1,26 +0,0 @@ -:: -:: Copyright (c) HySoP 2011-2024 -:: -:: This file is part of HySoP software. -:: See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -:: for further info. -:: -:: Licensed under the Apache License, Version 2.0 (the "License"); -:: you may not use this file except in compliance with the License. -:: You may obtain a copy of the License at -:: -:: http://www.apache.org/licenses/LICENSE-2.0 -:: -:: Unless required by applicable law or agreed to in writing, software -:: distributed under the License is distributed on an "AS IS" BASIS, -:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -:: See the License for the specific language governing permissions and -:: limitations under the License. -:: -pushd %~dp0 -set "SCRIPT_DIR=%CD%" -popd -set "NTHREADS=%NUMBER_OF_PROCESSORS%" -set "HYSOP_REGISTRY_URL=gricad-registry.univ-grenoble-alpes.fr" -if "%~1" NEQ "" (set "DOCKER_IMAGE_TAG=%~1") else (set "DOCKER_IMAGE_TAG=ci_cpu_intel") -docker build --rm=true --build-arg "NTHREADS=%NTHREADS%" -t "%HYSOP_REGISTRY_URL%/particle_methods/hysop/%DOCKER_IMAGE_TAG%:latest" -f "%SCRIPT_DIR%\..\docker_images\%DOCKER_IMAGE_TAG%\Dockerfile" "%SCRIPT_DIR%\..\.." diff --git a/ci/utils/build_docker_image.sh b/ci/utils/build_docker_image.sh deleted file mode 100755 index 02c8a658c..000000000 --- a/ci/utils/build_docker_image.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -## -## Copyright (c) HySoP 2011-2024 -## -## This file is part of HySoP software. -## See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -## for further info. -## -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## -set -feu -o pipefail -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -NTHREADS="$(nproc)" -DOCKER_IMAGE_TAG=${1:-ci_cpu_intel} -HYSOP_REGISTRY_URL='gricad-registry.univ-grenoble-alpes.fr' - -docker build --rm=true --build-arg "NTHREADS=$NTHREADS" -t "${HYSOP_REGISTRY_URL}/particle_methods/hysop/${DOCKER_IMAGE_TAG}:latest" -f "${SCRIPT_DIR}/../docker_images/${DOCKER_IMAGE_TAG}/Dockerfile" "${SCRIPT_DIR}/../.." diff --git a/ci/utils/pull_docker_image.bat b/ci/utils/pull_docker_image.bat deleted file mode 100755 index c74669dab..000000000 --- a/ci/utils/pull_docker_image.bat +++ /dev/null @@ -1,31 +0,0 @@ -:: -:: Copyright (c) HySoP 2011-2024 -:: -:: This file is part of HySoP software. -:: See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -:: for further info. -:: -:: Licensed under the Apache License, Version 2.0 (the "License"); -:: you may not use this file except in compliance with the License. -:: You may obtain a copy of the License at -:: -:: http://www.apache.org/licenses/LICENSE-2.0 -:: -:: Unless required by applicable law or agreed to in writing, software -:: distributed under the License is distributed on an "AS IS" BASIS, -:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -:: See the License for the specific language governing permissions and -:: limitations under the License. -:: -pushd %~dp0 -set "SCRIPT_DIR=%CD%" -popd - -set "HYSOP_REGISTRY_URL=gricad-registry.univ-grenoble-alpes.fr" - -if "%~1" NEQ "" (set "DOCKER_IMAGE_TAG=%~1") else (set "DOCKER_IMAGE_TAG=ci_cpu_intel") - -docker logout -docker login "%HYSOP_REGISTRY_URL%" -docker pull "%HYSOP_REGISTRY_URL%/particle_methods/hysop:%DOCKER_IMAGE_TAG%" -docker logout diff --git a/ci/utils/pull_docker_image.sh b/ci/utils/pull_docker_image.sh deleted file mode 100755 index c3deaf176..000000000 --- a/ci/utils/pull_docker_image.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -## -## Copyright (c) HySoP 2011-2024 -## -## This file is part of HySoP software. -## See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -## for further info. -## -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## -set -ef -o pipefail -DOCKER_IMAGE_TAG=${1:-ci_cpu_intel} -HYSOP_REGISTRY_URL='gricad-registry.univ-grenoble-alpes.fr' -docker logout -if [[ -z "${HYSOP_REGISTRY_USERNAME}" ]] || [[ -z "${HYSOP_REGISTRY_TOKEN}" ]]; then - docker login "${HYSOP_REGISTRY_URL}" -else - echo "${HYSOP_REGISTRY_TOKEN}" | docker login "${HYSOP_REGISTRY_URL}" --username "${HYSOP_REGISTRY_USERNAME}" --password-stdin -fi -docker pull "${HYSOP_REGISTRY_URL}/particle_methods/hysop/${DOCKER_IMAGE_TAG}:latest" -docker logout diff --git a/ci/utils/push_docker_image.bat b/ci/utils/push_docker_image.bat deleted file mode 100755 index 061eee381..000000000 --- a/ci/utils/push_docker_image.bat +++ /dev/null @@ -1,25 +0,0 @@ -:: -:: Copyright (c) HySoP 2011-2024 -:: -:: This file is part of HySoP software. -:: See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -:: for further info. -:: -:: Licensed under the Apache License, Version 2.0 (the "License"); -:: you may not use this file except in compliance with the License. -:: You may obtain a copy of the License at -:: -:: http://www.apache.org/licenses/LICENSE-2.0 -:: -:: Unless required by applicable law or agreed to in writing, software -:: distributed under the License is distributed on an "AS IS" BASIS, -:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -:: See the License for the specific language governing permissions and -:: limitations under the License. -:: -set HYSOP_REGISTRY_URL=gricad-registry.univ-grenoble-alpes.fr - -if "%~1" NEQ "" (set DOCKER_IMAGE_TAG=%~1) else (set DOCKER_IMAGE_TAG=ci_cpu_intel) - -docker push "%HYSOP_REGISTRY_URL%/particle_methods/hysop:%DOCKER_IMAGE_TAG%" -docker logout diff --git a/ci/utils/push_docker_image.sh b/ci/utils/push_docker_image.sh deleted file mode 100755 index a79e531c6..000000000 --- a/ci/utils/push_docker_image.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -## -## Copyright (c) HySoP 2011-2024 -## -## This file is part of HySoP software. -## See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -## for further info. -## -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## -set -ef -o pipefail -DOCKER_IMAGE_TAG=${1:-ci_cpu_intel} -HYSOP_REGISTRY_URL='gricad-registry.univ-grenoble-alpes.fr' -docker logout -if [[ -z "${HYSOP_REGISTRY_USERNAME}" ]] || [[ -z "${HYSOP_REGISTRY_TOKEN}" ]]; then - docker login "${HYSOP_REGISTRY_URL}" -else - echo "${HYSOP_REGISTRY_TOKEN}" | docker login "${HYSOP_REGISTRY_URL}" --username "${HYSOP_REGISTRY_USERNAME}" --password-stdin -fi -docker push "${HYSOP_REGISTRY_URL}/particle_methods/hysop/${DOCKER_IMAGE_TAG}:latest" -docker logout diff --git a/ci/utils/run_ci.bat b/ci/utils/run_ci.bat deleted file mode 100644 index 51e3dae68..000000000 --- a/ci/utils/run_ci.bat +++ /dev/null @@ -1,43 +0,0 @@ -:: -:: Copyright (c) HySoP 2011-2024 -:: -:: This file is part of HySoP software. -:: See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -:: for further info. -:: -:: Licensed under the Apache License, Version 2.0 (the "License"); -:: you may not use this file except in compliance with the License. -:: You may obtain a copy of the License at -:: -:: http://www.apache.org/licenses/LICENSE-2.0 -:: -:: Unless required by applicable law or agreed to in writing, software -:: distributed under the License is distributed on an "AS IS" BASIS, -:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -:: See the License for the specific language governing permissions and -:: limitations under the License. -:: -pushd %~dp0 -set SCRIPT_DIR=%CD% -popd - -set "HYSOP_REGISTRY_URL=gricad-registry.univ-grenoble-alpes.fr" -if "%~1" NEQ "" (set DOCKER_IMAGE_TAG=%~1) else (set DOCKER_IMAGE_TAG=ci_cpu_intel) -set "DOCKER_IMAGE_TAG_POSTFIX=%DOCKER_IMAGE_TAG:~-4%" -IF "%DOCKER_IMAGE_TAG_POSTFIX%" == "nvidia" (set "EXTRA_ARGS=--gpus all") else (set "EXTRA_ARGS=") -set "DOCKER_IMG=%HYSOP_REGISTRY_URL%/particle_methods/hysop/%DOCKER_IMAGE_TAG%:latest" -set "CONTAINER_ID=hysop_build_and_test" - -docker stop %CONTAINER_ID% -docker rm %CONTAINER_ID% - -docker create %EXTRA_ARGS% -v "%SCRIPT_DIR%\..\..:/hysop:ro" --name=%CONTAINER_ID% -it %DOCKER_IMG% - -docker start %CONTAINER_ID% - -docker exec %CONTAINER_ID% /hysop/ci/scripts/build_and_test.sh - -docker commit %CONTAINER_ID% %DOCKER_IMG% - -docker stop %CONTAINER_ID% -docker rm %CONTAINER_ID% diff --git a/ci/utils/run_ci.sh b/ci/utils/run_ci.sh index 3a13a9683..baa10832d 100755 --- a/ci/utils/run_ci.sh +++ b/ci/utils/run_ci.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +II#!/usr/bin/env bash ## ## Copyright (c) HySoP 2011-2024 ## @@ -36,8 +36,8 @@ function remove_img() { } trap remove_img INT TERM EXIT KILL -docker create --cap-add=SYS_PTRACE ${EXTRA_ARGS} --name="${CONTAINER_ID}" -it -v "${SCRIPT_DIR}/../..:/hysop:ro" "${HYSOP_REGISTRY_URL}/particle_methods/hysop/${DOCKER_IMAGE_TAG}:latest" +docker create --cap-add=SYS_PTRACE ${EXTRA_ARGS} --name="${CONTAINER_ID}" -it -v "${SCRIPT_DIR}/../..:/home/hysop-user/shared:ro" "${HYSOP_REGISTRY_URL}/particle_methods/hysop/${DOCKER_IMAGE_TAG}:latest" docker start "${CONTAINER_ID}" # Interactive shell is asked to activate micromamba in shell. Interactivity is not needed -docker exec -it "${CONTAINER_ID}" bash -i -c "MESON_TESTTHREADS=1 /hysop/ci/scripts/build_and_test.sh" -docker exec -it "${CONTAINER_ID}" bash -i -c "MESON_TESTTHREADS=1 EXAMPLE_DIR=/hysop/hysop_examples/examples /hysop/ci/scripts/run_examples.sh" +docker exec -it "${CONTAINER_ID}" bash -i -c "MESON_TESTTHREADS=1 /home/hysop-user/shared/ci/utils/build_and_test.sh" +docker exec -it "${CONTAINER_ID}" bash -i -c "MESON_TESTTHREADS=1 EXAMPLE_DIR=/home/hysop-user/shared/hysop_examples/examples /home/hysop-user/shared/ci/scripts/run_examples.sh" diff --git a/ci/utils/run_debug.bat b/ci/utils/run_debug.bat deleted file mode 100644 index 04a2842dd..000000000 --- a/ci/utils/run_debug.bat +++ /dev/null @@ -1,43 +0,0 @@ -:: -:: Copyright (c) HySoP 2011-2024 -:: -:: This file is part of HySoP software. -:: See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -:: for further info. -:: -:: Licensed under the Apache License, Version 2.0 (the "License"); -:: you may not use this file except in compliance with the License. -:: You may obtain a copy of the License at -:: -:: http://www.apache.org/licenses/LICENSE-2.0 -:: -:: Unless required by applicable law or agreed to in writing, software -:: distributed under the License is distributed on an "AS IS" BASIS, -:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -:: See the License for the specific language governing permissions and -:: limitations under the License. -:: -pushd %~dp0 -set SCRIPT_DIR=%CD% -popd - -set "HYSOP_REGISTRY_URL=gricad-registry.univ-grenoble-alpes.fr" -if "%~1" NEQ "" (set DOCKER_IMAGE_TAG=%~1) else (set DOCKER_IMAGE_TAG=ci_cpu_intel) -set "DOCKER_IMAGE_TAG_POSTFIX=%DOCKER_IMAGE_TAG:~-4%" -IF "%DOCKER_IMAGE_TAG_POSTFIX%" == "nvidia" (set "EXTRA_ARGS=--gpus all") else (set "EXTRA_ARGS=") -set "DOCKER_IMG=%HYSOP_REGISTRY_URL%/particle_methods/hysop/%DOCKER_IMAGE_TAG%:latest" -set "CONTAINER_ID=hysop_build_and_test" - -docker stop %CONTAINER_ID% -docker rm %CONTAINER_ID% - -docker create %EXTRA_ARGS% -v "%SCRIPT_DIR%\..\..:/hysop:ro" --name=%CONTAINER_ID% -it %DOCKER_IMG% - -docker start %CONTAINER_ID% - -docker exec %CONTAINER_ID% /hysop/ci/scripts/build_and_debug.sh - -docker commit %CONTAINER_ID% %DOCKER_IMG% - -docker stop %CONTAINER_ID% -docker rm %CONTAINER_ID% diff --git a/ci/utils/run_debug.sh b/ci/utils/run_debug.sh deleted file mode 100755 index 51a28a090..000000000 --- a/ci/utils/run_debug.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash -## -## Copyright (c) HySoP 2011-2024 -## -## This file is part of HySoP software. -## See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -## for further info. -## -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## -set -feu -o pipefail -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -DOCKER_IMAGE_TAG=${1:-ci_cpu_intel} -HYSOP_REGISTRY_URL='gricad-registry.univ-grenoble-alpes.fr' -DOCKER_IMG="${HYSOP_REGISTRY_URL}/particle_methods/hysop/${DOCKER_IMAGE_TAG}:latest" -CONTAINER_ID='hysop_build_and_debug' - -if [[ ${DOCKER_IMAGE_TAG} == *_nvidia ]]; then - EXTRA_ARGS="--gpus all" -else - EXTRA_ARGS="" -fi - -function remove_img() { - docker stop "${CONTAINER_ID}" || true - docker rm "${CONTAINER_ID}" || true -} -trap remove_img INT TERM EXIT KILL - -remove_img - -docker create --cap-add=SYS_PTRACE ${EXTRA_ARGS} -v "${SCRIPT_DIR}/../..:/hysop:ro" --name="${CONTAINER_ID}" -it "${DOCKER_IMG}" - -docker start "${CONTAINER_ID}" - -docker exec -it "${CONTAINER_ID}" /hysop/ci/scripts/build_and_debug.sh diff --git a/ci/utils/run_docker_image.bat b/ci/utils/run_docker_image.bat deleted file mode 100755 index e1240ea83..000000000 --- a/ci/utils/run_docker_image.bat +++ /dev/null @@ -1,27 +0,0 @@ -:: -:: Copyright (c) HySoP 2011-2024 -:: -:: This file is part of HySoP software. -:: See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -:: for further info. -:: -:: Licensed under the Apache License, Version 2.0 (the "License"); -:: you may not use this file except in compliance with the License. -:: You may obtain a copy of the License at -:: -:: http://www.apache.org/licenses/LICENSE-2.0 -:: -:: Unless required by applicable law or agreed to in writing, software -:: distributed under the License is distributed on an "AS IS" BASIS, -:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -:: See the License for the specific language governing permissions and -:: limitations under the License. -:: -pushd %~dp0 -set "SCRIPT_DIR=%CD%" -popd -set "HYSOP_REGISTRY_URL=gricad-registry.univ-grenoble-alpes.fr" -if "%~1" NEQ "" (set "DOCKER_IMAGE_TAG=%~1") else (set "DOCKER_IMAGE_TAG=ci_cpu_intel") -set "DOCKER_IMAGE_TAG_POSTFIX=%DOCKER_IMAGE_TAG:~-4%" -if "%DOCKER_IMAGE_TAG_POSTFIX%" == "nvidia" (set "EXTRA_ARGS=--gpus all") else (set "EXTRA_ARGS=") -docker run --rm --cap-add=SYS_PTRACE %EXTRA_ARGS% -it -v "%SCRIPT_DIR%\..\..:/hysop:ro" "%HYSOP_REGISTRY_URL%/particle_methods/hysop/%DOCKER_IMAGE_TAG%:latest" diff --git a/ci/utils/run_docker_image.sh b/ci/utils/run_docker_image.sh index 6d428d495..a58637559 100755 --- a/ci/utils/run_docker_image.sh +++ b/ci/utils/run_docker_image.sh @@ -21,6 +21,7 @@ set -feu -o pipefail SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" DOCKER_IMAGE_TAG=${1:-ci_cpu_intel} +HOST_DIRECTORY=${2:-$(realpath ${SCRIPT_DIR}/../..)} HYSOP_REGISTRY_URL='gricad-registry.univ-grenoble-alpes.fr' if [[ ${DOCKER_IMAGE_TAG} == *_nvidia* ]]; then @@ -29,4 +30,4 @@ else EXTRA_ARGS="" fi -docker run --rm --cap-add=SYS_PTRACE ${EXTRA_ARGS} -it -v "${SCRIPT_DIR}/../..:/hysop:ro" "${HYSOP_REGISTRY_URL}/particle_methods/hysop/${DOCKER_IMAGE_TAG}:latest" +docker run --rm --cap-add=SYS_PTRACE ${EXTRA_ARGS} -it -v "${HOST_DIRECTORY}:/home/hysop-user/shared" "${HYSOP_REGISTRY_URL}/particle_methods/hysop/${DOCKER_IMAGE_TAG}:latest" diff --git a/ci/utils/run_user_docker_image.sh b/ci/utils/run_user_docker_image.sh deleted file mode 100755 index 7dadb8779..000000000 --- a/ci/utils/run_user_docker_image.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash -## -## Copyright (c) HySoP 2011-2024 -## -## This file is part of HySoP software. -## See "https://particle_methods.gricad-pages.univ-grenoble-alpes.fr/hysop-doc/" -## for further info. -## -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## -set -feu -o pipefail -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -DOCKER_IMAGE_TAG=${1:-hysop_user_cpu_intel} - -# Get your host's UID and GID -export HOST_UID=$(id -u) -export HOST_GID=$(id -g) -export HOST_LOGIN=$(whoami) -export HOST_GROUP=$(id -g -n $HOST_LOGIN) - -echo "$HOST_UID $HOST_GID $HOST_LOGIN $HOST_GROUP" - -# Build the Docker image -docker build \ - --build-arg UID=${HOST_UID} \ - --build-arg GID=${HOST_GID} \ - --build-arg LOGIN=${HOST_LOGIN} \ - --build-arg GROUP=${HOST_GROUP} \ - -t ${DOCKER_IMAGE_TAG}_img \ - -f "${SCRIPT_DIR}/../docker_images/${DOCKER_IMAGE_TAG}/Dockerfile" \ - . - -if [[ ${DOCKER_IMAGE_TAG} == *_nvidia ]]; then - EXTRA_ARGS="--runtime=nvidia --gpus all" -else - EXTRA_ARGS="" -fi -# Run the Docker container -docker run --rm ${EXTRA_ARGS} -it -v "$(pwd):/home/$LOGNAME" ${DOCKER_IMAGE_TAG}_img -- GitLab