Skip to content

Commit 5dc2c73

Browse files
committed
Set up Docker-based workflow for macOS
1 parent e9ecbfb commit 5dc2c73

File tree

7 files changed

+153
-14
lines changed

7 files changed

+153
-14
lines changed

.gitignore

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,31 @@
11
.snakemake
2-
site
2+
site
3+
4+
# macOS system files
5+
.DS_Store
6+
7+
# Python cache files
8+
__pycache__/
9+
*.py[cod]
10+
11+
# Benchmark and workflow output files
12+
benchmarks/linear-elastic-plate-with-hole/element_size_vs_stress.pdf
13+
benchmarks/linear-elastic-plate-with-hole/metadata4ing_provenance.zip
14+
benchmarks/linear-elastic-plate-with-hole/workflow_config.json
15+
16+
# Generated folders and outputs
17+
benchmarks/linear-elastic-plate-with-hole/metadata4ing_provenance/
18+
benchmarks/linear-elastic-plate-with-hole/snakemake_results/
19+
20+
# (Optional) ignore all ZIP and PDF files in benchmarks if they are always generated
21+
# benchmarks/**/*.zip
22+
# benchmarks/**/*.pdf
23+
24+
# VS Code / IDE settings (optional, if you use editors)
25+
.vscode/
26+
.idea/
27+
28+
# Conda and environment files (optional safety)
29+
*.lock
30+
*.log
31+
.env

benchmarks/linear-elastic-plate-with-hole/Snakefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ rule create_mesh:
2121
parameters = lambda wildcards: configuration_to_parameter_file[wildcards.configuration],
2222
output:
2323
mesh = f"{result_dir}/mesh/mesh_{{configuration}}.msh",
24-
conda: "environment_mesh.yml"
24+
# conda: "environment_mesh.yml"
2525
shell:
2626
"""
27+
source /opt/miniforge/etc/profile.d/conda.sh
28+
conda activate mesh
2729
python3 {input.script} --input_parameter_file {input.parameters} --output_mesh_file {output.mesh}
2830
"""
2931

@@ -54,9 +56,11 @@ rule summary:
5456
),
5557
output:
5658
summary_json = f"{result_dir}/{{tool}}/summary.json",
57-
conda: "environment_postprocessing.yml",
59+
# conda: "environment_postprocessing.yml",
5860
shell:
5961
"""
62+
source /opt/miniforge/etc/profile.d/conda.sh
63+
conda activate postprocessing
6064
python3 {input.script} \
6165
--input_configuration {configurations} \
6266
--input_parameter_file {input.parameters} \

benchmarks/linear-elastic-plate-with-hole/fenics/Snakefile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,23 @@ rule run_fenics_simulation:
1515
output:
1616
zip = f"{result_dir}/{{tool}}/solution_field_data_{{configuration}}.zip",
1717
metrics = f"{result_dir}/{{tool}}/solution_metrics_{{configuration}}.json",
18-
conda:
19-
"environment_simulation.yml",
18+
# conda:
19+
# "environment_simulation.yml",
2020
shell:
2121
"""
22-
python3 {input.script} --input_parameter_file {input.parameters} --input_mesh_file {input.mesh} --output_solution_file_zip {output.zip} --output_metrics_file {output.metrics}
22+
# Disable 'unbound variable' errors to avoid ADDR2LINE issues
23+
set +u
24+
# Load conda
25+
source /opt/miniforge/etc/profile.d/conda.sh
26+
# Activate the FEniCS environment
27+
conda activate fenics-sim
28+
# Prevent OpenMP crash under qemu (macOS/arm64 emulation)
29+
export OMP_NUM_THREADS=1
30+
31+
# Run the actual simulation
32+
python3 {input.script} \
33+
--input_parameter_file {input.parameters} \
34+
--input_mesh_file {input.mesh} \
35+
--output_solution_file_zip {output.zip} \
36+
--output_metrics_file {output.metrics}
2337
"""

benchmarks/linear-elastic-plate-with-hole/kratos/Snakefile

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ rule mesh_to_mdpa:
1616
script = f"{tool}/msh_to_mdpa.py",
1717
output:
1818
mdpa = f"{result_dir}/{tool}/mesh_{{configuration}}.mdpa",
19-
conda:
20-
"environment_simulation.yml",
19+
# conda:
20+
# "environment_simulation.yml",
2121
shell:
2222
"""
23+
source /opt/miniforge/etc/profile.d/conda.sh
24+
conda activate kratos-sim
2325
python3 {input.script} \
2426
--input_parameter_file {input.parameters} \
2527
--input_mesh_file {input.mesh} \
@@ -44,10 +46,12 @@ rule create_kratos_input_and_run_simulation:
4446
kratos_inputfile = f"{result_dir}/{tool}/ProjectParameters_{{configuration}}.json",
4547
kratos_materialfile = f"{result_dir}/{tool}/MaterialParameters_{{configuration}}.json",
4648
result_vtk = f"{result_dir}/{tool}/{{configuration}}/Structure_0_1.vtk",
47-
conda:
48-
"environment_simulation.yml",
49+
# conda:
50+
# "environment_simulation.yml",
4951
shell:
5052
"""
53+
source /opt/miniforge/etc/profile.d/conda.sh
54+
conda activate kratos-sim
5155
python3 {input.script_create_kratos_input} \
5256
--input_parameter_file {input.parameters} \
5357
--input_mdpa_file {input.mdpa} \
@@ -70,10 +74,12 @@ rule postprocess_kratos_results:
7074
output:
7175
zip = f"{result_dir}/{tool}/solution_field_data_{{configuration}}.zip",
7276
metrics = f"{result_dir}/{tool}/solution_metrics_{{configuration}}.json",
73-
conda:
74-
"environment_simulation.yml",
77+
# conda:
78+
# "environment_simulation.yml",
7579
shell:
7680
"""
81+
source /opt/miniforge/etc/profile.d/conda.sh
82+
conda activate kratos-sim
7783
python3 {input.script} \
7884
--input_parameter_file {input.parameters} \
7985
--input_result_vtk {input.result_vtk} \

benchmarks/linear-elastic-plate-with-hole/kratos/environment_simulation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77
- python-gmsh
88
- pint
99
- pyvista
10+
- sympy
1011
- pip
1112
- pip:
12-
- KratosMultiphysics-all
13-
- sympy
13+
- KratosMultiphysics-all==9.0.2

dockerfiles/Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# -----------------------------
2+
# Dockerfile for NFDI_Benchmark
3+
# -----------------------------
4+
5+
# Base image similar to GitHub Actions ubuntu-latest
6+
FROM --platform=linux/amd64 ubuntu:22.04
7+
8+
# Avoid interactive prompts during apt installs
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
11+
# Install basic dependencies
12+
RUN apt-get update && apt-get install -y \
13+
wget curl git unzip zip bzip2 libbz2-dev python3 python3-pip \
14+
build-essential && \
15+
rm -rf /var/lib/apt/lists/*
16+
17+
# Install Miniforge3 for amd64 architecture
18+
RUN wget https://github.com/conda-forge/miniforge/releases/download/24.11.0-0/Miniforge3-24.11.0-0-Linux-x86_64.sh && \
19+
bash Miniforge3-24.11.0-0-Linux-x86_64.sh -b -p /opt/miniforge && \
20+
rm Miniforge3-24.11.0-0-Linux-x86_64.sh
21+
22+
# Add conda/mamba to PATH
23+
ENV PATH="/opt/miniforge/bin:$PATH"
24+
25+
ENV OMP_NUM_THREADS=1
26+
ENV KMP_AFFINITY=disabled
27+
ENV OMP_PROC_BIND=FALSE
28+
29+
# Set working directory inside container
30+
WORKDIR /NFDI_Benchmark
31+
32+
# Copy only environment yaml first to leverage Docker caching
33+
COPY environment_benchmarks.yml /NFDI_Benchmark/
34+
35+
# Create model-validation environment
36+
RUN mamba env create -n model-validation -f environment_benchmarks.yml && \
37+
echo "conda activate model-validation" >> ~/.bashrc
38+
39+
# Copy the rest of the repo into container
40+
COPY . /NFDI_Benchmark
41+
42+
# Use bash login shell by default
43+
SHELL ["bash", "-l", "-c"]
44+
45+
# Drop into interactive bash shell when container starts
46+
CMD ["/bin/bash"]
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Use Ubuntu base image under x86_64 emulation for Apple Silicon Macs
2+
FROM --platform=linux/amd64 ubuntu:22.04
3+
4+
# Prevent interactive prompts during package installs
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
# Update system and install required packages
8+
RUN apt-get update && apt-get install -y \
9+
wget git build-essential curl unzip \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
# Install Miniforge (Conda for ARM/x86 compatible builds)
13+
ENV CONDA_DIR=/opt/miniforge
14+
RUN wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -O /tmp/miniforge.sh && \
15+
bash /tmp/miniforge.sh -b -p $CONDA_DIR && \
16+
rm /tmp/miniforge.sh
17+
ENV PATH=$CONDA_DIR/bin:$PATH
18+
19+
# Initialize Conda shell integration
20+
RUN conda init bash
21+
22+
# Create default working directory
23+
WORKDIR /NFDI_Benchmark
24+
25+
# Copy your repository into the image (optional; or mount it later)
26+
# COPY . /NFDI_Benchmark
27+
28+
# Pre-install mamba (faster environment management)
29+
RUN conda install -y mamba -n base -c conda-forge
30+
31+
# Create and activate a base environment for model validation
32+
RUN mamba create -n model-validation python=3.10 -y && \
33+
echo "source $CONDA_DIR/etc/profile.d/conda.sh && conda activate model-validation" >> ~/.bashrc
34+
35+
# Set environment variables for stability under emulation
36+
ENV OMP_NUM_THREADS=1
37+
ENV KMP_AFFINITY=disabled
38+
39+
# Default command starts bash with Conda activated
40+
ENTRYPOINT ["/bin/bash", "-l"]

0 commit comments

Comments
 (0)