From cfc9a84020e854be174d1930619d4d25010a85c2 Mon Sep 17 00:00:00 2001 From: deegan Date: Wed, 18 Sep 2024 15:31:49 +0200 Subject: [PATCH] nightly data docker image --- res/docker/nightly/Dockerfile | 12 ++++++++++ res/docker/nightly/build_and_push_image.sh | 8 +++++++ res/docker/nightly/build_image.sh | 6 +++++ res/docker/nightly/run.sh | 24 +++++++++++++++++++ tools/data/generate.sh | 8 +++++++ .../tests/simulator/test_init_from_samrai.py | 22 +++++++++++++++++ 6 files changed, 80 insertions(+) create mode 100644 res/docker/nightly/Dockerfile create mode 100755 res/docker/nightly/build_and_push_image.sh create mode 100755 res/docker/nightly/build_image.sh create mode 100755 res/docker/nightly/run.sh create mode 100755 tools/data/generate.sh create mode 100644 tools/data/tests/simulator/test_init_from_samrai.py diff --git a/res/docker/nightly/Dockerfile b/res/docker/nightly/Dockerfile new file mode 100644 index 000000000..8e117de00 --- /dev/null +++ b/res/docker/nightly/Dockerfile @@ -0,0 +1,12 @@ +ARG RELEASE=40 +FROM 129.104.6.165:32219/phare/teamcity-fedora_dep:$RELEASE + +ENV OMPI_ALLOW_RUN_AS_ROOT=1 +ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 +ENV TMPDIR=/tmp +ENV MODULEPATH=/etc/scl/modulefiles:/etc/scl/modulefiles:/usr/share/Modules/modulefiles:/etc/modulefiles:/usr/share/modulefiles +ENV PYTHONPATH="/root/phare:/root/phare/build:/root/phare/pyphare" + +WORKDIR /root +COPY run.sh /root +RUN chmod +x run.sh && ./run.sh diff --git a/res/docker/nightly/build_and_push_image.sh b/res/docker/nightly/build_and_push_image.sh new file mode 100755 index 000000000..83dd10a7f --- /dev/null +++ b/res/docker/nightly/build_and_push_image.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +BASEDIR=$(dirname "$0") +RELEASE=${1:-40} +REGISTRY=${2:-"129.104.6.165:32219"} +IMAGE="phare/teamcity-fedora_data" +FULL_NAME="${REGISTRY}/${IMAGE}:${RELEASE}" +$BASEDIR/build_image.sh $RELEASE $REGISTRY +docker push $FULL_NAME diff --git a/res/docker/nightly/build_image.sh b/res/docker/nightly/build_image.sh new file mode 100755 index 000000000..fcb558de2 --- /dev/null +++ b/res/docker/nightly/build_image.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +RELEASE=${1:-40} +REGISTRY=${2:-"129.104.6.165:32219"} +IMAGE="phare/teamcity-fedora_data" +FULL_NAME="${REGISTRY}/${IMAGE}:${RELEASE}" +docker build --build-arg RELEASE=$RELEASE -t ${FULL_NAME} . diff --git a/res/docker/nightly/run.sh b/res/docker/nightly/run.sh new file mode 100755 index 000000000..264ea9f00 --- /dev/null +++ b/res/docker/nightly/run.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +set -xe + +eval "$(modulecmd bash load mpi/openmpi-x86_64)" + +( + cd /root + git clone https://github.com/PHAREHUB/PHARE --depth 10 --recursive --shallow-submodules phare + cd phare && mkdir build && cd build + + # we are not keeping these binaries, only output data - portability is not an issue + CMAKE_CXX_FLAGS="-DNDEBUG -g0 -O3 -march=native -mtune=native" + CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -DPHARE_DIAG_DOUBLES=1" + CMAKE_CONFIG="-DCMAKE_BUILD_TYPE=Release" + cmake -G Ninja ${CMAKE_CONFIG} -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" .. + ninja +) + +( + cd /root/phare + export PYTHONPATH="$PWD:$PWD/build:$PWD/pyphare" + ./tools/data/generate.sh +) +rm -rf /root/phare diff --git a/tools/data/generate.sh b/tools/data/generate.sh new file mode 100755 index 000000000..67f6fa485 --- /dev/null +++ b/tools/data/generate.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -ex +CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +( + cd $CWD + mpirun -n 4 tests/simulator/test_init_from_samrai.py +) diff --git a/tools/data/tests/simulator/test_init_from_samrai.py b/tools/data/tests/simulator/test_init_from_samrai.py new file mode 100644 index 000000000..9d2114995 --- /dev/null +++ b/tools/data/tests/simulator/test_init_from_samrai.py @@ -0,0 +1,22 @@ +import copy +import numpy as np +import pyphare.pharein as ph +from pyphare.simulator.simulator import Simulator +from tests.simulator import test_restarts +from tests.diagnostic import dump_all_diags +from pathlib import Path + +time_step = 0.001 +time_step_nbr = 5 +final_time = time_step_nbr * time_step +timestamps = np.arange(0, final_time + time_step, time_step) +first_out = str(Path.home() / "phare_data" / "tests/simulator/test_from_init") + +if __name__ == "__main__": + simput = copy.deepcopy(test_restarts.simArgs) + simput["restart_options"]["dir"] = first_out + simput["restart_options"]["timestamps"] = timestamps + simput["diag_options"]["options"]["dir"] = first_out + sim = ph.Simulation(**simput) + dump_all_diags(test_restarts.setup_model().populations, timestamps=timestamps) + Simulator(sim).run()