Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skeletons #2

Merged
merged 3 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This is a basic workflow to help you get started with Actions
name: Build and publish

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Weekly build on Mondays at 8 am
schedule:
- cron: "0 8 * * 1"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
container: dokken92/dolfinx_custom:15072022

env:
HDF5_MPI: "ON"
CC: mpicc
HDF5_DIR: "/usr/local/"
DISPLAY: ":99.0"
PYVISTA_OFF_SCREEN: true

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# - name: Test complex notebooks in parallel
# run: |
# export PKG_CONFIG_PATH=/usr/local/dolfinx-complex/lib/pkgconfig:$PKG_CONFIG_PATH
# export PETSC_ARCH=linux-gnu-complex-32
# export PYTHONPATH=/usr/local/dolfinx-complex/lib/python3.10/dist-packages:$PYTHONPATH
# export LD_LIBRARY_PATH=/usr/local/dolfinx-complex/lib:$LD_LIBRARY_PATH


- name: Install dependencies
run: pip3 install notebook nbconvert jupyter-book --upgrade
# - name: Test notebooks in parallel
# run: |
# python3 -c "from pyvista import start_xvfb; start_xvfb(0.1)"

# Runs a single command using the runners shell
- name: Build the book
run: |
PYVISTA_JUPYTER_BACKEND=static PYVISTA_OFF_SCREEN=false jupyter-book build -W .

# Push book to HTML to github pages
- name: GitHub Pages action
uses: peaceiris/actions-gh-pages@v3.5.9
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_build/html
61 changes: 61 additions & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This is a basic workflow to help you get started with Actions
name: Test tutorial against DOLFINx main branch

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [main]
pull_request:
branches:
- main

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Test every day at 9 am
schedule:
- cron: "* 9 * * 1"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
test-against-master:
# The type of runner that the job will run on
runs-on: ubuntu-latest
container: dolfinx/lab

env:
HDF5_MPI: "ON"
PYVISTA_OFF_SCREEN: true

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Install dependencies
run: |
pip3 install --upgrade pip setuptools
CC=mpicc HDF_MPI="ON" HDF5_DIR="/usr/local" pip3 install --no-cache-dir -r deps/requirements.txt
apt-get -qq update
apt-get install -y libgl1-mesa-dev xvfb nodejs
apt-get clean
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
jupyter nbextension enable --py --sys-prefix ipygany
rm -rf /usr/local/share/.cache/*
jupyter-book -h

# - name: Test complex notebooks in parallel
# run: |
# export PKG_CONFIG_PATH=/usr/local/dolfinx-complex/lib/pkgconfig:$PKG_CONFIG_PATH
# export PETSC_ARCH=linux-gnu-complex-32
# export PYTHONPATH=/usr/local/dolfinx-complex/lib/python3.10/dist-packages:$PYTHONPATH
# export LD_LIBRARY_PATH=/usr/local/dolfinx-complex/lib:$LD_LIBRARY_PATH

# - name: Test real notebooks in parallel
# run: |

- name: Test building the book
run:
PYVISTA_JUPYTER_BACKEND=static PYVISTA_OFF_SCREEN=false jupyter-book build -W .
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/

# Jupybook
_build/*
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM dokken92/dolfinx_custom:15072022

# create user with a home directory
ARG NB_USER
ARG NB_UID=1000
ENV USER ${NB_USER}
ENV HOME /home/${NB_USER}

# Copy home directory for usage in binder
WORKDIR ${HOME}
COPY . ${HOME}
USER root
RUN chown -R ${NB_UID} ${HOME}

USER ${NB_USER}
ENTRYPOINT []
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,71 @@
# fenics22-tutorial

Tutorial for the FEniCS [22 conference](https://fenicsproject.org/fenics-2022/) in San Diego


## Adding a tutorial to the book

Add a chapter to `_toc.yml`.

Inside the Jupyter notebook, go to `Property Inspector` (the two cogwheels in the top right corner of JupyterLab)
and add the following as notebook metadata:
```yml
"metadata": {
"jupytext": {
"formats": "ipynb,py:light"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
}
}
```
This will choose the default kernel in the `dolfinx/lab` docker image, and automatically convert the notebooks to a `.py` file at saving.

If you want to use complex numbers, change:
```bash
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
```
to
```bash
"kernelspec": {
"display_name": "Python 3 (DOLFINx complex)",
"language": "python",
"name": "python3-complex"
},
```


## Create slides from your notebook

You can use `nbconvert` (`pip3 install nbconvert`) to convert the `.ipynb` to a presentation.
The command to run is:
```bash
jupyter nbconvert example.ipynb --to html --template reveal
```

To change what is rendered on each slide, you can change the notebook metadata,
which is in `Property Inspector` (the two cogwheels in the top right corner of JupyterLab), and change the `Slide Type` to `Slide` to start a new slide. If you want to add the cell below to the same slide, change the type to `-`.

If a cell should be revealed with `Right Arrow`, choose `Fragment`.

If you want a sub-slide, i.e. navigating downwards with arrows when rendering the presentation, change the type to `Sub-Slide`.

If a cell should be ignored in presentation mode, set it to `Notes`.
46 changes: 46 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Book settings
# Learn more at https://jupyterbook.org/customize/config.html

title: FEniCS 22 tutorial
author: The FEniCS project
logo: logo.jpeg

# Force re-execution of notebooks on each build.
# See https://jupyterbook.org/content/execute.html
execute:
execute_notebooks: force

# Set timeout for any example to 20 minutes
timeout: 1800

# Add a bibtex file so that we can create citations
bibtex_bibfiles:
- references.bib

# Information about where the book exists on the web
repository:
url: https://github.com/jorgensd/fenics22-tutorial # Online location of your book
path_to_book: . # Optional path to your book, relative to the repository root
branch: main # Which branch of the repository should be used when creating links (optional)

parse:
myst_enable_extensions:
- "amsmath"
- "colon_fence"
- "deflist"
- "dollarmath"
- "html_admonition"
- "html_image"
- "linkify"
- "replacements"
- "smartquotes"
- "substitution"

# Add GitHub buttons to your book
# See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository
html:
use_issues_button: true
use_repository_button: true
use_edit_page_button: true

exclude_patterns: [README.md]
7 changes: 7 additions & 0 deletions _toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Table of contents
# Learn more at https://jupyterbook.org/customize/toc.html

format: jb-book
root: intro
chapters:
- file: example
33 changes: 33 additions & 0 deletions deps/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Various jupyterlab components
setuptools
jupyterhub
jupyterlab
jupyter-book

# Notebook conversion
nbconvert

# Meshio
# meshio
# --no-binary=h5py
# h5py

# Visualization with pandas
# seaborn
# pandas

# Visualization with Pyvista
# matplotlib

# Until VTK is released with wheels for python 3.10
--find-links https://wheels.pyvista.org/
pyvista

pythreejs
ipygany

# Progress bar
# tqdm

# To resolve black dependency conflict
# click
Loading