Skip to content

Commit

Permalink
Add starts of viz work to container, along with working mpi4py jupyte…
Browse files Browse the repository at this point in the history
…r example.
  • Loading branch information
cameronrutherford committed Nov 9, 2023
1 parent 6650618 commit 6feab41
Show file tree
Hide file tree
Showing 7 changed files with 1,850 additions and 347 deletions.
21 changes: 18 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,23 @@ RUN mkdir /opt/spack-environment \
# This is manual, and required to build Ipopt
COPY coinhsl-archive-2019.05.21.tar.gz /opt/spack-environment/coinhsl-archive-2019.05.21.tar.gz

# Find external packages
RUN cd /opt/spack-environment && spack env activate . && spack external find --all

# Do this separate of install to cache keys...
RUN spack mirror add develop https://binaries.spack.io/develop && spack buildcache keys --install --trust
RUN cd /opt/spack-environment && spack env activate . && spack mirror add develop https://binaries.spack.io/develop && spack buildcache keys --install --trust && spack concretize -f && spack mirror create -a

# Install Ipopt w/ CoinHSL (and other deps) in stages to cache builds
RUN cd /opt/spack-environment && spack env activate . && spack install --fail-fast ipopt

# Install PETSc
RUN cd /opt/spack-environment && spack env activate . && spack install --fail-fast petsc

# Install py-jupyterlab
RUN cd /opt/spack-environment && spack env activate . && spack install --fail-fast py-jupyterlab

# Install py-ipyparallel
RUN cd /opt/spack-environment && spack env activate . && spack install --fail-fast py-ipyparallel

# Install the software, remove unnecessary deps
RUN cd /opt/spack-environment && spack env activate . && spack install --fail-fast && spack gc -y
Expand Down Expand Up @@ -87,14 +102,14 @@ RUN echo "source /entrypoint.sh" >> /home/vscode/.bashrc
RUN . /entrypoint.sh && \
python3 -m ipykernel install \
--name py311-exago \
--display-name ExaGO \
--display-name "ExaGO" \
--prefix=

# Install the mpi4py Jupyter kernel
RUN . /entrypoint.sh && \
python3 -m ipykernel install \
--name py311-mpi4py-exago \
--display-name ExaGO w/ MPI \
--display-name "ExaGO w/ MPI" \
--prefix=

# Make modifications that are necessary to run mpi4py in kernelspec
Expand Down
18 changes: 13 additions & 5 deletions .devcontainer/create_dockerfile_devcontainer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,17 @@ spack containerize > ./.devcontainer/Dockerfile
# Add Docker command before "# Install" that copies CoinHSL into image
sed -i "" "s|# Install the software|# This is manual, and required to build Ipopt\nCOPY coinhsl-archive-2019.05.21.tar.gz /opt/spack-environment/coinhsl-archive-2019.05.21.tar.gz\n\n# Install the software|" ./.devcontainer/Dockerfile

# Also trusts the build cache
sed -i "" "s|# Install the software|# Do this separate of install to cache keys...\nRUN spack mirror add develop https://binaries.spack.io/develop \&\& spack buildcache keys --install --trust\n\n# Install the software|" ./.devcontainer/Dockerfile
# Find external packages
sed -i "" "s|# Install the software|# Find external packages\nRUN cd /opt/spack-environment \&\& spack env activate . \&\& spack external find --all\n\n# Install the software|" ./.devcontainer/Dockerfile

# Also trusts the build cache and create source mirror
sed -i "" "s|# Install the software|# Do this separate of install to cache keys...\nRUN cd /opt/spack-environment \&\& spack env activate . \&\& spack mirror add develop https://binaries.spack.io/develop \&\& spack buildcache keys --install --trust \&\& spack concretize -f \&\& spack mirror create -a\n\n# Install the software|" ./.devcontainer/Dockerfile

# Install Ipopt and packages in separate stages to cache builds
sed -i "" "s|# Install the software|# Install Ipopt w/ CoinHSL (and other deps) in stages to cache builds\nRUN cd /opt/spack-environment \&\& spack env activate . \&\& spack install --fail-fast ipopt\n\n# Install the software|" ./.devcontainer/Dockerfile
sed -i "" "s|# Install the software|# Install PETSc \nRUN cd /opt/spack-environment \&\& spack env activate . \&\& spack install --fail-fast petsc\n\n# Install the software|" ./.devcontainer/Dockerfile
sed -i "" "s|# Install the software|# Install py-jupyterlab\nRUN cd /opt/spack-environment \&\& spack env activate . \&\& spack install --fail-fast py-jupyterlab\n\n# Install the software|" ./.devcontainer/Dockerfile
sed -i "" "s|# Install the software|# Install py-ipyparallel\nRUN cd /opt/spack-environment \&\& spack env activate . \&\& spack install --fail-fast py-ipyparallel\n\n# Install the software|" ./.devcontainer/Dockerfile

# Configure environment for VSCode User in devcontainer
echo "# Make sure devcontainer user gets spack packages" >> ./.devcontainer/Dockerfile
Expand All @@ -93,7 +102,7 @@ echo "# Install the Jupyter kernel" >> ./.devcontainer/Dockerfile
echo "RUN . /entrypoint.sh && \\" >> ./.devcontainer/Dockerfile
echo " python3 -m ipykernel install \\" >> ./.devcontainer/Dockerfile
echo " --name py311-exago \\" >> ./.devcontainer/Dockerfile
echo " --display-name "ExaGO" \\" >> ./.devcontainer/Dockerfile
echo " --display-name \"ExaGO\" \\" >> ./.devcontainer/Dockerfile
echo " --prefix=$(which jupyter)" >> ./.devcontainer/Dockerfile

# Install the mpi4py Jupyter kernel
Expand All @@ -102,7 +111,7 @@ echo "# Install the mpi4py Jupyter kernel" >> ./.devcontainer/Dockerfile
echo "RUN . /entrypoint.sh && \\" >> ./.devcontainer/Dockerfile
echo " python3 -m ipykernel install \\" >> ./.devcontainer/Dockerfile
echo " --name py311-mpi4py-exago \\" >> ./.devcontainer/Dockerfile
echo " --display-name "ExaGO w/ MPI" \\" >> ./.devcontainer/Dockerfile
echo " --display-name \"ExaGO w/ MPI\" \\" >> ./.devcontainer/Dockerfile
echo " --prefix=$(which jupyter)" >> ./.devcontainer/Dockerfile

# Modify mpi4py kernel to actually launch process with mpiexec
Expand All @@ -114,4 +123,3 @@ echo "RUN sed -i 's/\\\"\/opt\/views\/view\/bin\/python3\\\"/\\\"mpiexec\\\", \\
echo "" >> ./.devcontainer/Dockerfile
echo "# Configure user for container" >> ./.devcontainer/Dockerfile
echo "USER vscode" >> ./.devcontainer/Dockerfile

3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
}
},
"workspaceFolder": "/home/app/",
"postCreateCommand": "cd /home/app/viz && export CXX=$(which gcc) && npm install",
"workspaceMount": "source=${localWorkspaceFolder},target=/home/app/,type=bind,consistency=cached"
}
}
Loading

0 comments on commit 6feab41

Please sign in to comment.