Skip to content

Commit 4e0c24d

Browse files
authored
Try removing xvfb for most tutorials (#278)
* Try removing xvfb for most tutorials * Remove xvfb * Update dockerfile and pyproject.toml * Try removing xvfb completely for osmesa backend instead * Publish env on dispatch * rename workflow * Try removing display * Remvoe variables from docker env * Revert docker publish
1 parent 7f2732b commit 4e0c24d

39 files changed

+43
-83
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

@@ -53,7 +52,6 @@ jobs:
5352
- name: Test chapter 1
5453
working-directory: chapter1
5554
run: |
56-
python3 -c "from pyvista import start_xvfb; start_xvfb(0.1)"
5755
mpirun -n 2 python3 fundamentals_code.py
5856
mpirun -n 2 python3 nitsche.py
5957
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 --set-formats ipynb,py:light

chapter1/complex_mode.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@
270270
"source": [
271271
"import pyvista\n",
272272
"\n",
273-
"pyvista.start_xvfb(0.1)\n",
274273
"mesh.topology.create_connectivity(mesh.topology.dim, mesh.topology.dim)\n",
275274
"p_mesh = pyvista.UnstructuredGrid(*dolfinx.plot.vtk_mesh(mesh, mesh.topology.dim))\n",
276275
"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
@@ -181,7 +181,6 @@
181181
# +
182182
import pyvista
183183

184-
pyvista.start_xvfb(0.1)
185184
mesh.topology.create_connectivity(mesh.topology.dim, mesh.topology.dim)
186185
p_mesh = pyvista.UnstructuredGrid(*dolfinx.plot.vtk_mesh(mesh, mesh.topology.dim))
187186
pyvista_cells, cell_types, geometry = dolfinx.plot.vtk_mesh(V)

chapter1/fundamentals_code.ipynb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,6 @@
473473
"We start by converting the mesh to a format that can be used with {py:mod}`pyvista`.\n",
474474
"To do this we use the function {py:func}`dolfinx.plot.vtk_mesh`.\n",
475475
"It creates the data required to create a {py:class}`pyvista.UnstructuredGrid`.\n",
476-
"On Linux (in docker) we need to start a virtual framebuffer for plotting through docker containers.\n",
477476
"You can print the current backend and change it with {py:func}`pyvista.set_jupyter_backend`."
478477
]
479478
},
@@ -486,8 +485,7 @@
486485
"source": [
487486
"import pyvista\n",
488487
"\n",
489-
"print(pyvista.global_theme.jupyter_backend)\n",
490-
"pyvista.start_xvfb(0.1)"
488+
"print(pyvista.global_theme.jupyter_backend)"
491489
]
492490
},
493491
{

chapter1/fundamentals_code.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,12 @@
309309
# We start by converting the mesh to a format that can be used with {py:mod}`pyvista`.
310310
# To do this we use the function {py:func}`dolfinx.plot.vtk_mesh`.
311311
# It creates the data required to create a {py:class}`pyvista.UnstructuredGrid`.
312-
# On Linux (in docker) we need to start a virtual framebuffer for plotting through docker containers.
313312
# You can print the current backend and change it with {py:func}`pyvista.set_jupyter_backend`.
314313

315314
# +
316315
import pyvista
317316

318317
print(pyvista.global_theme.jupyter_backend)
319-
pyvista.start_xvfb(0.1)
320318

321319
# +
322320
from dolfinx import plot

chapter1/membrane_code.ipynb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,7 @@
306306
"outputs": [],
307307
"source": [
308308
"from dolfinx.plot import vtk_mesh\n",
309-
"import pyvista\n",
310-
"\n",
311-
"pyvista.start_xvfb(0.1)"
309+
"import pyvista\n"
312310
]
313311
},
314312
{

0 commit comments

Comments
 (0)