Skip to content

Commit

Permalink
Updates for visualization CI (#2600)
Browse files Browse the repository at this point in the history
* Add ipython to CI

* Remove chosing pyvista backend

* Try starting xvfb prior to demo run

* Typo

* Bump pyvistaqt version

* Remove other backends

* use agg backend for matplotlib

* Revert new-line in CI
  • Loading branch information
jorgensd committed Mar 28, 2023
1 parent d99b790 commit 6e67e07
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 21 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/pyvista.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
# For pyvista/pyvistaqt
DISPLAY: ":99.0"
PYVISTA_OFF_SCREEN: true
PYVISTA_QT_VERSION: 0.9.0
PYVISTA_VERSION: 0.37.0
PYVISTA_QT_VERSION: 0.9.1
PYVISTA_VERSION: 0.38.4

PETSC_ARCH: linux-gnu-${{ matrix.petsc_arch }}-32
OMPI_ALLOW_RUN_AS_ROOT: 1
Expand All @@ -47,9 +47,9 @@ jobs:
apt-get update
apt-get install -y --no-install-recommends libgl1-mesa-dev xvfb # pyvista
apt-get install -y --no-install-recommends python3-pyqt5 libgl1-mesa-glx # pyvistaqt
pip3 install pyvista==${PYVISTA_VERSION}
pip3 install pyvistaqt==${PYVISTA_QT_VERSION}
pip3 install matplotlib
python3 -m pip install pyvista==${PYVISTA_VERSION}
python3 -m pip install pyvistaqt==${PYVISTA_QT_VERSION}
python3 -m pip install matplotlib ipython
- name: Configure C++
run: cmake -G Ninja -DCMAKE_BUILD_TYPE=Developer -B build -S cpp/
Expand All @@ -64,5 +64,5 @@ jobs:
- name: Run pyvista demos (Python, serial)
run: python3 -m pytest -v -n=2 -m serial --durations=10 python/demo/test.py

- name: Run pyivsta demos (Python, MPI (np=2))
- name: Run pyvista demos (Python, MPI (np=2))
run: python3 -m pytest -v -m mpi --num-proc=2 python/demo/test.py
14 changes: 5 additions & 9 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ARG NUMPY_VERSION=1.23.3
ARG PYBIND11_VERSION=2.10.3
ARG PETSC_VERSION=3.18.5
ARG SLEPC_VERSION=3.18.2
ARG PYVISTA_VERSION=0.38.1
ARG PYVISTA_VERSION=0.38.4

ARG MPICH_VERSION=4.1.1
ARG OPENMPI_SERIES=4.1
Expand Down Expand Up @@ -478,16 +478,12 @@ RUN apt-get -qq update && \
# available on pypi for linux/arm64.
# matplotlib improves plotting quality with better color maps and
# properly rendering colorbars.
# pythreejs and ipygany are two backends of pyvista not requiring a framebuffer,
# and are therefore preferred in notebooks
# Pinning ipywidgets due to https://github.com/pyvista/pyvista/issues/3274
# Trame is preferred backend for pyvista
RUN dpkgArch="$(dpkg --print-architecture)"; \
case "$dpkgArch" in amd64) \
pip3 install --no-cache-dir pyvista==${PYVISTA_VERSION} ipywidgets==7.7.2 && \
pip3 install --no-cache-dir matplotlib && \
pip3 install --no-cache-dir pythreejs ipygany && \
pip3 cache purge && \
jupyter nbextension enable --py --sys-prefix ipygany ;; \
python3 -m pip install --no-cache-dir pyvista[trame]==${PYVISTA_VERSION} && \
python3 -m pip install --no-cache-dir matplotlib && \
python3 -m pip cache purge ;; \
esac;

# Jupyter Notebook kernel specification for complex build DOLFINx
Expand Down
2 changes: 0 additions & 2 deletions python/demo/demo_pml/demo_pml.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ def pml_coordinates(x: ufl.indexed.Indexed, alpha: float, k0: complex, l_dom: fl
if have_pyvista:
topology, cell_types, geometry = plot.create_vtk_mesh(msh, 2)
grid = pyvista.UnstructuredGrid(topology, cell_types, geometry)
pyvista.set_jupyter_backend("pythreejs")
plotter = pyvista.Plotter()
num_local_cells = msh.topology.index_map(msh.topology.dim).size_local
grid.cell_data["Marker"] = cell_tags.values[cell_tags.indices < num_local_cells]
Expand Down Expand Up @@ -442,7 +441,6 @@ def create_eps_mu(pml: ufl.tensors.ListTensor,
Esh_values[:, :msh.topology.dim] = Esh_dg.x.array.reshape(V_x.shape[0], msh.topology.dim).real
V_grid.point_data["u"] = Esh_values

pyvista.set_jupyter_backend("pythreejs")
plotter = pyvista.Plotter()
plotter.add_text("magnitude", font_size=12, color="black")
plotter.add_mesh(V_grid.copy(), show_edges=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ def curl_2d(f: fem.Function):
if have_pyvista:
topology, cell_types, geometry = plot.create_vtk_mesh(domain, 2)
grid = pyvista.UnstructuredGrid(topology, cell_types, geometry)
pyvista.set_jupyter_backend("pythreejs")
plotter = pyvista.Plotter()
num_local_cells = domain.topology.index_map(domain.topology.dim).size_local
grid.cell_data["Marker"] = cell_tags.values[cell_tags.indices < num_local_cells]
Expand Down Expand Up @@ -440,7 +439,6 @@ def curl_2d(f: fem.Function):

V_grid.point_data["u"] = Esh_values

pyvista.set_jupyter_backend("pythreejs")
plotter = pyvista.Plotter()
plotter.add_text("magnitude", font_size=12, color="black")
plotter.add_mesh(V_grid.copy(), show_edges=True)
Expand Down
3 changes: 3 additions & 0 deletions python/demo/demo_tnt-elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# We begin this demo by importing the required modules.

# +
import matplotlib
import matplotlib.pylab as plt
import numpy as np

Expand All @@ -32,6 +33,8 @@

from mpi4py import MPI

matplotlib.use('agg')

# -

# ## Defining a degree 1 TNT element
Expand Down
2 changes: 0 additions & 2 deletions python/demo/demo_waveguide/demo_half_loaded_waveguide.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ def Omega_v(x):

V_grid.point_data["u"] = Et_values

pyvista.set_jupyter_backend("ipygany")
plotter = pyvista.Plotter()
plotter.add_mesh(V_grid.copy(), show_edges=False)
plotter.view_xy()
Expand All @@ -403,7 +402,6 @@ def Omega_v(x):
V_cells, V_types, V_x = plot.create_vtk_mesh(V_lagr)
V_grid = pyvista.UnstructuredGrid(V_cells, V_types, V_x)
V_grid.point_data["u"] = ezh.x.array.real[lagr_dofs]
pyvista.set_jupyter_backend("ipygany")
plotter = pyvista.Plotter()
plotter.add_mesh(V_grid.copy(), show_edges=False)
plotter.view_xy()
Expand Down

0 comments on commit 6e67e07

Please sign in to comment.