Skip to content

Commit db267b1

Browse files
authored
Merge pull request #8 from scientificcomputing/dokken/conda
Use conda for all actions
2 parents 6fe1c59 + fdba054 commit db267b1

File tree

8 files changed

+68
-42
lines changed

8 files changed

+68
-42
lines changed

.github/actions/install-dependencies/action.yml

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,40 @@
11
name: Install dependencies
22

3+
inputs:
4+
python-version:
5+
description: Python version to install
6+
required: true
7+
type: string
8+
default: "3.10"
39

410
runs:
511
using: composite
612
steps:
7-
- name: Install and upgrade pip
8-
shell: bash -el {0}
9-
run: |
10-
apt-get update
11-
apt-get install -y python3-pip
12-
python3 -m pip install -U pip
13+
- name: Setup conda-forge
14+
uses: conda-incubator/setup-miniconda@v2
15+
with:
16+
miniforge-variant: Mambaforge
17+
miniforge-version: latest
18+
activate-environment: mpi-tutorial
19+
python-version: ${{ inputs.python-version }}
20+
use-mamba: true
21+
environment-file: environment.yml
22+
23+
# - name: Prepare cache
24+
# shell: bash -el {0}
25+
# run: |
26+
# if [[ $CONDA != /opt/conda ]]; then
27+
# mkdir -p /opt/conda/
28+
# ln -s $CONDA/envs /opt/conda/envs
29+
# fi
30+
# echo CONDA=$CONDA
31+
# mamba env list
32+
33+
# - name: Environment cache
34+
# uses: actions/cache@v3
35+
# with:
36+
# path: /opt/conda/envs/mpi-tutorial
37+
# key: env-conda-mpi-tutorial-${{ inputs.python-version }}-${{ hashFiles('.github/actions/install-dependencies/*') }}
38+
# id: cache
1339

14-
- name: Install MPICH
15-
shell: bash -el {0}
16-
run: |
17-
apt-get install -y libmpich-dev
1840

19-
- name: Install requirements
20-
shell: bash -el {0}
21-
run: |
22-
python3 -m pip install -r requirements.txt

.github/workflows/build_docs.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ env:
1212
jobs:
1313
build-book:
1414
runs-on: ubuntu-latest
15-
container: ubuntu:22.04
1615

1716
steps:
1817

@@ -21,14 +20,9 @@ jobs:
2120
- name: Install common packages
2221
uses: ./.github/actions/install-dependencies
2322

24-
- name: Install book deps
25-
run:
26-
python3 -m pip install -r requirements.txt
27-
2823
- name: Build the book
2924
run:
30-
jupyter-book build . -W
31-
25+
conda run -n mpi-tutorial jupyter-book build . -W
3226
- uses: actions/upload-artifact@v3
3327
with:
3428
name: documentation

Dockerfile

Lines changed: 0 additions & 14 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ Welcome to this tutorial (in development)
88
2. Clone the repository (or fork) and create a new branch with `git checkout -b github-username/feature-description`
99
3. Create a compatible working environment, for instance by building the project docker-image.
1010
```bash
11-
docker build -t local_docker_file -f Dockerfile .
11+
docker build -t local_docker_file -f docker/Dockerfile .
1212
docker run -ti -v $(pwd):/root/shared -w /root/shared --name=tutorialmpi local_docker_file
1313
```
14+
You can also use conda to build your environment
15+
```bash
16+
conda env update --file environment.yml --name name-of-your-env
17+
```
1418
4. Create an `.ipynb` in the [notebooks](./notebooks/) folder, or modify the existing notebooks. If a new notebook has been created, add it to the appropriate section of [_toc.yml](_toc.yml).
1519
5. Make sure the webpage builds correctly by calling `jupyter book build -W .` from the root of the repository. You can inspect the webpage locally by opening [_build/html/index.html](_build/html/index.html) with the web-browser of your choice.
1620
6. Make a [pull-request](https://github.com/scientificcomputing/mpi-tutorial/compare) to the main branch of this repo.

_config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ logo: logo.png
88
# Force re-execution of notebooks on each build.
99
# See https://jupyterbook.org/content/execute.html
1010
execute:
11-
execute_notebooks: cache
12-
11+
execute_notebooks: force
12+
timeout: 1800
1313

1414
# Information about where the book exists on the web
1515
repository:

docker/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM condaforge/mambaforge
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
# Install ssh (missing dependency to run conda envs)
6+
RUN apt-get update && \
7+
apt-get install -y ssh build-essential
8+
9+
# Upgrade mamba
10+
RUN mamba upgrade -y mamba
11+
12+
# Copy environment and requirements files into docker env
13+
COPY environment.yml .
14+
15+
# Update environment file with new environment name
16+
RUN mamba env update --file environment.yml --name dockerenv
17+
SHELL ["mamba", "run", "-n", "dockerenv", "/bin/bash", "-c"]
18+
19+
RUN echo "source activate dockerenv" > ~/.bashrc

environment.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: mpi-tutorial
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- mpich
6+
- ipyparallel
7+
- jupyter-book
8+
- mpi4py
9+
- autopep8

requirements.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)