From 4df32c9e7be9219df06f25eda6defbc8736ff08e Mon Sep 17 00:00:00 2001
From: Sven Marcus <sven.marcus@tu-braunschweig.de>
Date: Thu, 15 Sep 2022 14:12:23 +0200
Subject: [PATCH] Adds hpc-rocket config. Python bindings don't need CUDA if
 only CPU. Multistage PoiseuilleTestContainer

---
 .../poiseuille/PoiseuilleTestContainer.def    | 30 +++++++++++++++++--
 .../poiseuille/simulation_runner.py           |  2 +-
 Python/SlurmTests/poiseuille/slurm.job        |  5 +++-
 pythonbindings/CMakeLists.txt                 |  9 +++++-
 rocket.yml                                    | 23 ++++++++++++++
 5 files changed, 63 insertions(+), 6 deletions(-)
 create mode 100644 rocket.yml

diff --git a/Python/SlurmTests/poiseuille/PoiseuilleTestContainer.def b/Python/SlurmTests/poiseuille/PoiseuilleTestContainer.def
index a3836e790..a275c88a6 100644
--- a/Python/SlurmTests/poiseuille/PoiseuilleTestContainer.def
+++ b/Python/SlurmTests/poiseuille/PoiseuilleTestContainer.def
@@ -1,11 +1,13 @@
 BootStrap: docker
 From: ubuntu:20.04
+Stage: build
 
 %files
     3rdParty 3rdParty
     apps apps
     CMake CMake
     Python Python
+    pythonbindings pythonbindings
     src src
     CMakeLists.txt CMakeLists.txt
     cpu.cmake cpu.cmake
@@ -19,7 +21,8 @@ From: ubuntu:20.04
     apt-get update &&          \
     apt-get install -y         \
     build-essential            \
-    cmake=3.16.3-1ubuntu1      \
+    ccache                     \
+    git                        \
     python3                    \
     python3-dev                \
     python3-pip                \
@@ -27,10 +30,31 @@ From: ubuntu:20.04
     libomp-dev                 \
     libgl1
 
-    pip3 install setuptools wheel numpy scipy pyvista
+    pip3 install setuptools wheel cmake numpy scipy pyvista
 
     export PYTHONPATH=Python
-    python3 /setup.py install
+    python3 /setup.py bdist_wheel build_ext --build-temp=build
+    pip3 install $(find dist/*.whl)
+
+
+BootStrap: docker
+From: ubuntu:20.04
+Stage: runtime
+
+%files from build
+    Python Python
+    dist dist
+
+%post
+    export DEBIAN_FRONTEND=noninteractive
+    apt-get update &&          \
+    apt-get install -y         \
+    python3                    \
+    python3-pip                \
+    mpich                      \
+    libgl1
+
+    pip3 install $(find dist/*.whl)
 
 %environment
     export PYTHONPATH=/Python
diff --git a/Python/SlurmTests/poiseuille/simulation_runner.py b/Python/SlurmTests/poiseuille/simulation_runner.py
index 03fb24be7..d54a35e72 100644
--- a/Python/SlurmTests/poiseuille/simulation_runner.py
+++ b/Python/SlurmTests/poiseuille/simulation_runner.py
@@ -5,7 +5,7 @@ from poiseuille.simulation import run_simulation
 from pyfluids.cpu.writer import Writer, OutputFormat
 
 
-scale_level = int(os.environ["PYFLUIDS_SCALE_LEVEL"])
+scale_level = int(os.environ.get("PYFLUIDS_SCALE_LEVEL", 1))
 grid_params, physical_params, runtime_params, kernel = Scaling.configuration_for_scale_level(scale_level)
 
 writer = Writer()
diff --git a/Python/SlurmTests/poiseuille/slurm.job b/Python/SlurmTests/poiseuille/slurm.job
index 8115b13e1..b4e4da271 100644
--- a/Python/SlurmTests/poiseuille/slurm.job
+++ b/Python/SlurmTests/poiseuille/slurm.job
@@ -1,6 +1,6 @@
 #!/bin/bash
 #SBATCH -J PyFluidsTest
-#SBATCH -o POISEUILLE_TEST.out
+#SBATCH -o poiseuille_test/POISEUILLE_TEST.out
 #SBATCH --nodes=1
 #SBATCH --ntasks-per-node=1
 #SBATCH --cpus-per-task=20
@@ -10,6 +10,9 @@
 #SBATCH --partition=standard
 
 source $HOME/.bashrc
+module load singularity/3.9.9
+
+cd poiseuille_test
 
 echo "PyFluids Poiseuille Test Case"
 echo "Number of tasks: ${SLURM_NTASKS}"
diff --git a/pythonbindings/CMakeLists.txt b/pythonbindings/CMakeLists.txt
index 644b308c9..ea6ff833a 100644
--- a/pythonbindings/CMakeLists.txt
+++ b/pythonbindings/CMakeLists.txt
@@ -1,4 +1,11 @@
-project(VirtualFluidsPython LANGUAGES CUDA CXX)
+set(PYFLUIDS_LANGUAGES CXX)
+
+if(BUILD_VF_GPU)
+    set(PYFLUIDS_LANGUAGES CUDA CXX)
+endif()
+
+project(VirtualFluidsPython LANGUAGES ${PYFLUIDS_LANGUAGES})
+
 pybind11_add_module(python_bindings MODULE src/VirtualFluids.cpp)
 
 set_target_properties(  python_bindings PROPERTIES
diff --git a/rocket.yml b/rocket.yml
new file mode 100644
index 000000000..da64a48cd
--- /dev/null
+++ b/rocket.yml
@@ -0,0 +1,23 @@
+host: $REMOTE_HOST
+user: $REMOTE_USER
+private_keyfile: $PRIVATE_KEY
+
+copy:
+  - from: Python/SlurmTests/poiseuille/slurm.job
+    to: poiseuille_test/slurm.job
+    overwrite: true
+
+  - from: Containers/PoiseuilleTestContainer.sif
+    to: poiseuille_test/PoiseuilleTestContainer.sif
+    overwrite: true
+
+collect:
+  - from: poiseuille_test/POISEUILLE_TEST.out
+    to: POISEUILLE_TEST.out
+    overwrite: true
+
+clean:
+  - poiseuille_test/*
+
+sbatch: poiseuille_test/slurm.job
+continue_if_job_fails: true
-- 
GitLab