Skip to content

Commit c04e742

Browse files
committed
Try removing xvfb for most tutorials (#278)
* Try removing xvfb for most tutorials
1 parent 3c87f94 commit c04e742

37 files changed

+324
-313
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ runs:
66
- name: Install apt dependencies and upgrade pip
77
shell: bash -el {0}
88
run: |
9-
apt-get update && apt-get install -y libxrender1 xvfb
9+
apt-get update && apt-get install -y libxrender1

.github/workflows/book_stable.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010
env:
1111
HDF5_MPI: "ON"
1212
HDF5_DIR: "/usr/local/"
13-
DISPLAY: ":99.0"
1413
DEB_PYTHON_INSTALL_LAYOUT: deb_system
1514
LIBGL_ALWAYS_SOFTWARE: 1
1615

@@ -20,8 +19,6 @@ jobs:
2019
container: ghcr.io/fenics/dolfinx/lab:stable
2120

2221
env:
23-
PYVISTA_TRAME_SERVER_PROXY_PREFIX: "/proxy/"
24-
PYVISTA_TRAME_SERVER_PROXY_ENABLED: "True"
2522
PYVISTA_OFF_SCREEN: false
2623
PYVISTA_JUPYTER_BACKEND: "html"
2724

.github/workflows/test_nightly.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test release branch against DOLFINx nightly build
1+
name: Test against DOLFINx nightly build
22

33
# Controls when the action will run.
44
on:
@@ -22,7 +22,6 @@ jobs:
2222
env:
2323
HDF5_MPI: "ON"
2424
PYVISTA_OFF_SCREEN: true
25-
DISPLAY: ":99.0"
2625
PYVISTA_JUPYTER_BACKEND: html
2726
LIBGL_ALWAYS_SOFTWARE: 1
2827

@@ -56,7 +55,6 @@ jobs:
5655
- name: Test chapter 1
5756
working-directory: chapter1
5857
run: |
59-
python3 -c "from pyvista import start_xvfb; start_xvfb(0.1)"
6058
mpirun -n 2 python3 fundamentals_code.py
6159
mpirun -n 2 python3 nitsche.py
6260
mpirun -n 2 python3 membrane_code.py

.github/workflows/test_stable.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ jobs:
4545
- name: Test chapter 1
4646
working-directory: chapter1
4747
run: |
48-
python3 -c "from pyvista import start_xvfb; start_xvfb(0.1)"
4948
mpirun -n 2 python3 fundamentals_code.py
5049
mpirun -n 2 python3 nitsche.py
5150
mpirun -n 2 python3 membrane_code.py

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,36 @@ If you have any comments, corrections or questions, please submit an issue in th
1010

1111
## Contributing
1212

13-
If you want to contribute to this tutorial, please make a fork of the repository, make your changes, and test that the CI passes. You can do this locally by downloading [act](https://github.com/nektos/act) and call
13+
If you want to contribute to this tutorial, please make a fork of the repository, make your changes, and test that the CI passes.
1414

15+
Alternatively, if you want to add a separate chapter, a Jupyter notebook can be added to a pull request, without integrating it into the tutorial. If so, the notebook will be reviewed and modified to be included in the tutorial.
16+
17+
Any code added to the tutorial should work in parallel. If any changes are made to `ipynb` files, please ensure that these changes are reflected in the corresponding `py` files by using [`jupytext`](https://jupytext.readthedocs.io/en/latest/faq.html#can-i-use-jupytext-with-jupyterhub-binder-nteract-colab-saturn-or-azure):
18+
19+
20+
## Building the book and running code
21+
The book is built using [jupyterbook](https://jupyterbook.org/). The following environment variables should be set if you want to build the book
1522
```bash
16-
act -j test-nightly
23+
PYVISTA_OFF_SCREEN=false
24+
PYVISTA_JUPYTER_BACKEND="html"
25+
JUPYTER_EXTENSION_ENABLED=true
26+
LIBGL_ALWAYS_SOFTWARE=1
1727
```
1828

19-
Alternatively, if you want to add a separate chapter, a Jupyter notebook can be added to a pull request, without integrating it into the tutorial. If so, the notebook will be reviewed and modified to be included in the tutorial.
29+
If you run the tutorial using `jupyter-lab`, for instance through `conda`, one should set the following environment variables
30+
```bash
31+
PYVISTA_OFF_SCREEN=false
32+
PYVISTA_JUPYTER_BACKEND="trame"
33+
JUPYTER_EXTENSION_ENABLED=true
34+
LIBGL_ALWAYS_SOFTWARE=1
35+
```
36+
If you use docker to run your code, you should set the following variables:
37+
```bash
38+
docker run -ti -e DISPLAY=$DISPLAY -e LIBGL_ALWAYS_SOFTWARE=1 -e PYVISTA_OFF_SCREEN=false -e PYVISTA_JUPYTER_BACKEND="trame" -e JUPYTER_EXTENSION_ENABLED=true --network=host -v $(pwd):/root/shared -w /root/shared ....
39+
```
40+
41+
To run python scripts, either choose `PYVISTA_OFF_SCREEN=True` to get screenshots, or render interactive plots with `PYVISTA_OFF_SCREEN=False`
2042

21-
Any code added to the tutorial should work in parallel. If any changes are made to `ipynb` files, please ensure that these changes are reflected in the corresponding `py` files by using [`jupytext`](https://jupytext.readthedocs.io/en/latest/faq.html#can-i-use-jupytext-with-jupyterhub-binder-nteract-colab-saturn-or-azure):
2243

2344
```bash
2445
python3 -m jupytext --sync */*.ipynb

chapter1/complex_mode.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
"outputs": [],
220220
"source": [
221221
"import pyvista\n",
222-
"pyvista.start_xvfb()\n",
222+
"\n",
223223
"mesh.topology.create_connectivity(mesh.topology.dim, mesh.topology.dim)\n",
224224
"p_mesh = pyvista.UnstructuredGrid(*dolfinx.plot.vtk_mesh(mesh, mesh.topology.dim))\n",
225225
"pyvista_cells, cell_types, geometry = dolfinx.plot.vtk_mesh(V)\n",

chapter1/complex_mode.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@
125125
#
126126

127127
import pyvista
128-
pyvista.start_xvfb()
129128
mesh.topology.create_connectivity(mesh.topology.dim, mesh.topology.dim)
130129
p_mesh = pyvista.UnstructuredGrid(*dolfinx.plot.vtk_mesh(mesh, mesh.topology.dim))
131130
pyvista_cells, cell_types, geometry = dolfinx.plot.vtk_mesh(V)

chapter1/fundamentals_code.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,10 @@
407407
"source": [
408408
"## Plotting the mesh using pyvista\n",
409409
"We will visualizing the mesh using [pyvista](https://docs.pyvista.org/), an interface to the VTK toolkit.\n",
410-
"We start by converting the mesh to a format that can be used with `pyvista`.\n",
411-
"To do this we use the function `dolfinx.plot.vtk_mesh`. The first step is to create an unstructured grid that can be used by `pyvista`.\n",
412-
"We need to start a virtual framebuffer for plotting through docker containers. You can print the current backend and change it with `pyvista.set_jupyter_backend(backend)`"
410+
"We start by converting the mesh to a format that can be used with {py:mod}`pyvista`.\n",
411+
"To do this we use the function {py:func}`dolfinx.plot.vtk_mesh`.\n",
412+
"It creates the data required to create a {py:class}`pyvista.UnstructuredGrid`.\n",
413+
"You can print the current backend and change it with {py:func}`pyvista.set_jupyter_backend`."
413414
]
414415
},
415416
{
@@ -420,6 +421,7 @@
420421
"outputs": [],
421422
"source": [
422423
"import pyvista\n",
424+
"\n",
423425
"print(pyvista.global_theme.jupyter_backend)"
424426
]
425427
},

chapter1/fundamentals_code.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,10 @@
222222

223223
# ## Plotting the mesh using pyvista
224224
# We will visualizing the mesh using [pyvista](https://docs.pyvista.org/), an interface to the VTK toolkit.
225-
# We start by converting the mesh to a format that can be used with `pyvista`.
226-
# To do this we use the function `dolfinx.plot.vtk_mesh`. The first step is to create an unstructured grid that can be used by `pyvista`.
227-
# We need to start a virtual framebuffer for plotting through docker containers. You can print the current backend and change it with `pyvista.set_jupyter_backend(backend)`
225+
# We start by converting the mesh to a format that can be used with {py:mod}`pyvista`.
226+
# To do this we use the function {py:func}`dolfinx.plot.vtk_mesh`.
227+
# It creates the data required to create a {py:class}`pyvista.UnstructuredGrid`.
228+
# You can print the current backend and change it with {py:func}`pyvista.set_jupyter_backend`.
228229

229230
import pyvista
230231
print(pyvista.global_theme.jupyter_backend)

chapter1/membrane_code.ipynb

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,24 @@
244244
"outputs": [],
245245
"source": [
246246
"from dolfinx.plot import vtk_mesh\n",
247-
"import pyvista\n",
248-
"pyvista.start_xvfb()\n",
249-
"\n",
250-
"# Extract topology from mesh and create pyvista mesh\n",
247+
"import pyvista\n"
248+
]
249+
},
250+
{
251+
"cell_type": "markdown",
252+
"id": "25",
253+
"metadata": {},
254+
"source": [
255+
"Extract topology from mesh and create pyvista mesh"
256+
]
257+
},
258+
{
259+
"cell_type": "code",
260+
"execution_count": null,
261+
"id": "26",
262+
"metadata": {},
263+
"outputs": [],
264+
"source": [
251265
"topology, cell_types, x = vtk_mesh(V)\n",
252266
"grid = pyvista.UnstructuredGrid(topology, cell_types, x)\n",
253267
"\n",

0 commit comments

Comments
 (0)