Skip to content

Commit a09e760

Browse files
committed
Add first couple of files to tutorial
1 parent 1cb1869 commit a09e760

File tree

12 files changed

+306
-0
lines changed

12 files changed

+306
-0
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.github
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Install dependencies
2+
3+
4+
runs:
5+
using: composite
6+
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+
14+
- name: Install MPICH
15+
shell: bask -el {0}
16+
run: |
17+
apt-get install -y libmpich-dev
18+
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: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build book
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
pull_request:
7+
branches: ["main"]
8+
9+
env:
10+
DEB_PYTHON_INSTALL_LAYOUT: deb_system
11+
12+
jobs:
13+
build-book:
14+
runs-on: ubuntu-latest
15+
16+
env:
17+
PYVISTA_TRAME_SERVER_PROXY_PREFIX: '/proxy/'
18+
PYVISTA_TRAME_SERVER_PROXY_ENABLED: "True"
19+
PYVISTA_OFF_SCREEN: false
20+
PYVISTA_JUPYTER_BACKEND: "panel"
21+
22+
steps:
23+
24+
- uses: actions/checkout@v3
25+
26+
- name: Install common packages
27+
uses: ./.github/actions/install-dependencies
28+
29+
- name: Install book deps
30+
run:
31+
python3 -m pip install -r requirements.txt
32+
33+
- name: Build the book
34+
run:
35+
jupyter-book build . -W
36+
37+
- uses: actions/upload-artifact@v3
38+
with:
39+
name: documentation
40+
path: ./_build/html
41+
retention-days: 2
42+
if-no-files-found: error

.github/workflows/deploy.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Publish book
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
workflow_dispatch:
8+
9+
# Weekly build on Mondays at 8 am
10+
schedule:
11+
- cron: "0 8 * * 1"
12+
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
concurrency:
19+
group: "pages"
20+
cancel-in-progress: true
21+
22+
env:
23+
DEB_PYTHON_INSTALL_LAYOUT: deb_system
24+
25+
jobs:
26+
27+
build-book:
28+
uses: ./.github/workflows/build_docs.yml
29+
30+
deploy:
31+
runs-on: ubuntu-22.04
32+
needs: [build-book]
33+
environment:
34+
name: github-pages
35+
url: ${{ steps.deployment.outputs.page_url }}
36+
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v3
40+
41+
- name: Setup Pages
42+
uses: actions/configure-pages@v2
43+
44+
- name: Download docs artifact
45+
uses: actions/download-artifact@v3
46+
with:
47+
name: documentation
48+
path: "./public"
49+
50+
- name: Upload page artifact
51+
uses: actions/upload-pages-artifact@v1
52+
with:
53+
path: "./public"
54+
55+
- name: Deploy webpage
56+
id: deployment
57+
uses: actions/deploy-pages@v1

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,7 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
132+
# jupyter-book
133+
_build/

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM ubuntu:22.04
2+
3+
4+
ADD requirements.txt .
5+
6+
RUN apt-get update && \
7+
apt-get install -y \
8+
python3-pip \
9+
libmpich-dev \
10+
git
11+
12+
RUN python3 -m pip install -U pip
13+
14+
RUN python3 -m pip install -r requirements.txt

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Tutorial for MPI
2+
3+
Welcome to this tutorial (in development)
4+
5+
6+
A local env with minimal dependencies can be built with
7+
```bash
8+
docker build -t local_docker_file -f Dockerfile
9+
docker run -ti -v $(pwd):/root/shared -w /root/shared --name=tutorialmpi local_docker_file
10+
```

_config.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Book settings
2+
# Learn more at https://jupyterbook.org/customize/config.html
3+
4+
title: MPI tutorial
5+
author: Jørgen S. Dokken
6+
logo: logo.png
7+
8+
# Force re-execution of notebooks on each build.
9+
# See https://jupyterbook.org/content/execute.html
10+
execute:
11+
execute_notebooks: cache
12+
13+
14+
# Information about where the book exists on the web
15+
repository:
16+
url: https://github.com/scientificcomputing/mpi-tutorial # Online location of your book
17+
path_to_book: . # Optional path to your book, relative to the repository root
18+
branch: main # Which branch of the repository should be used when creating links (optional)
19+
20+
launch_buttons:
21+
notebook_interface: "jupyterlab"
22+
binderhub_url: "https://mybinder.org"
23+
24+
html:
25+
use_issues_button: true
26+
use_repository_button: true
27+
28+
extra_footer: |
29+
<div>
30+
This webpage is distributed under the terms of the <a href=https://choosealicense.com/licenses/mit/>MIT License</a>.
31+
If you use this work, please cite it appropriately.
32+
</div
33+
34+
parse:
35+
myst_enable_extensions:
36+
- "amsmath"
37+
- "colon_fence"
38+
- "deflist"
39+
- "dollarmath"
40+
- "html_admonition"
41+
- "html_image"
42+
- "linkify"
43+
- "replacements"
44+
- "smartquotes"
45+
- "substitution"
46+
47+
sphinx:
48+
config:
49+
html_last_updated_fmt: "%b %d, %Y"
50+
suppress_warnings: ["mystnb.unknown_mime_type"]

_toc.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
format: jb-book
2+
root: README
3+
parts:
4+
- caption: Introduction
5+
chapters:
6+
- file: notebooks/introduction

logo.png

14.9 KB
Loading

notebooks/introduction.ipynb

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"cells": [
3+
{
4+
"attachments": {},
5+
"cell_type": "markdown",
6+
"id": "f8ed5686",
7+
"metadata": {},
8+
"source": [
9+
"# First notebook"
10+
]
11+
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": 1,
15+
"id": "6b50a74a-5b21-4109-b629-b8bb7860810b",
16+
"metadata": {},
17+
"outputs": [
18+
{
19+
"name": "stdout",
20+
"output_type": "stream",
21+
"text": [
22+
"Starting 2 engines with <class 'ipyparallel.cluster.launcher.MPIEngineSetLauncher'>\n",
23+
"100%|██████████| 2/2 [00:05<00:00, 2.75s/engine]\n"
24+
]
25+
}
26+
],
27+
"source": [
28+
"import ipyparallel as ipp\n",
29+
"cluster = ipp.Cluster(engines=\"mpi\", n=2)\n",
30+
"rc = cluster.start_and_connect_sync()\n"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": 2,
36+
"id": "6034b913",
37+
"metadata": {},
38+
"outputs": [
39+
{
40+
"data": {
41+
"text/plain": [
42+
"[stdout:0] MPI.COMM_WORLD.rank=0 MPI.COMM_WORLD.size=2\n"
43+
]
44+
},
45+
"metadata": {},
46+
"output_type": "display_data"
47+
},
48+
{
49+
"data": {
50+
"text/plain": [
51+
"[stdout:1] MPI.COMM_WORLD.rank=1 MPI.COMM_WORLD.size=2\n"
52+
]
53+
},
54+
"metadata": {},
55+
"output_type": "display_data"
56+
}
57+
],
58+
"source": [
59+
"%%px\n",
60+
"from mpi4py import MPI\n",
61+
"\n",
62+
"\n",
63+
"print(f\"{MPI.COMM_WORLD.rank=} {MPI.COMM_WORLD.size=}\")\n"
64+
]
65+
},
66+
{
67+
"cell_type": "code",
68+
"execution_count": null,
69+
"id": "4f760892",
70+
"metadata": {},
71+
"outputs": [],
72+
"source": []
73+
}
74+
],
75+
"metadata": {
76+
"kernelspec": {
77+
"display_name": "Python 3 (ipykernel)",
78+
"language": "python",
79+
"name": "python3"
80+
},
81+
"language_info": {
82+
"codemirror_mode": {
83+
"name": "ipython",
84+
"version": 3
85+
},
86+
"file_extension": ".py",
87+
"mimetype": "text/x-python",
88+
"name": "python",
89+
"nbconvert_exporter": "python",
90+
"pygments_lexer": "ipython3",
91+
"version": "3.10.6"
92+
}
93+
},
94+
"nbformat": 4,
95+
"nbformat_minor": 5
96+
}

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ipyparallel
2+
mpi4py
3+
jupyter-book
4+
autopep8

0 commit comments

Comments
 (0)