Skip to content

jorgensd/checkpointing-presentation

Repository files navigation

FEniCSx checkpointing presentation

This repository contains the source code and presentation for FEniCS 23'

Installation

Running

docker pull ghcr.io/fenics/dolfinx/lab:nightly
docker build -t checkpointing_image .

to build a compatible image, and then

docker run -ti -v ${PWD}:/root/shared -w /root/shared --entrypoint=/bin/bash --name=checkpoint_container -p 8080:8888 checkpointing_image
jupyter lab --ip 0.0.0.0 --no-browser --allow-root

Developer notes

Rendering the HTML presentation files directly on Github

Use githack and add the link to the relevant presentation.

Adding a tutorial to the book

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:

 {
  "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:

 "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },

to

  "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:

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.

Hiding cells/output

See https://jupyterbook.org/en/stable/interactive/hiding.htm for more details. The setting is also in advanced tools on the RHS of the Jupyterlab interface

Automatically generate slides

By adding the following file to the (jupyter_server_config.py) .jupyter folder on your system. You might need to rename it to jupyter_notebook_config.py. To check the config paths, call:

jupyter server --show-config
jupyter notebook --show-config

If you run the code with dolfinx/lab:nightly using for instance:

docker run -ti -p 8888:8888 --rm -v $(pwd):/root/shared --entrypoint=/bin/bash -w /root/shared dolfinx/lab:nightly
jupyter lab --ip 0.0.0.0 --no-browser --allow-root

no copying is required.

To run jupyter in the backgroud call ctrl+z and then bg in the terminal

Releases

No releases published

Packages

No packages published