Skip to content

Commit d40ba1b

Browse files
feat: Remote rendering 5.2a - ParaView backend support (#223)
Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
1 parent ae276e8 commit d40ba1b

38 files changed

Lines changed: 2345 additions & 36 deletions

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ celerybeat.pid
155155
.env
156156
.venv
157157
.venvdash
158+
.pvenv/
158159
env/
159160
venv/
160161
ENV/

‎doc/changelog.d/223.added.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remote rendering 5.2a - ParaView backend support

‎doc/source/getting_started/index.rst‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ Getting started
5858

5959
Override default VISOR settings using a project-level YAML file.
6060

61+
.. grid-item-card:: :material-outlined:`dns;2em`
62+
:link-type: doc
63+
:link: /getting_started/paraview_mode
64+
65+
.. raw:: html
66+
67+
<span style="font-size: 1.5em; color:#5a2a82;">PARAVIEW mode setup</span>
68+
69+
Set up the environments and the pvserver that PARAVIEW rendering mode uses.
70+
71+
.. note::
72+
73+
PARAVIEW mode is a beta feature and is still in development.
74+
6175

6276
.. toctree::
6377
:hidden:
@@ -68,6 +82,7 @@ Getting started
6882
quick_start
6983
known_limitations
7084
configure_visor
85+
paraview_mode
7186

7287

7388

Lines changed: 324 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,324 @@
1+
.. _paraview-mode:
2+
3+
PARAVIEW mode setup
4+
###################
5+
6+
.. note::
7+
8+
PARAVIEW mode is a beta feature and is still in development.
9+
10+
In PARAVIEW rendering mode, VISOR renders through a ParaView ``pvserver``.
11+
VISOR drives the server from a ``pvpython`` process that runs in its own
12+
virtual environment, the ``.pvenv``. This page shows how to build that
13+
environment beside the ``.venv`` that VISOR is installed in (see
14+
:ref:`installation-index`) and how to launch ``pvserver``.
15+
16+
Each VISOR instance in PARAVIEW mode needs its own ``pvserver`` process, which
17+
you start by hand before you start the instance. For details, see
18+
:ref:`paraview-mode-launch-pvserver`.
19+
20+
Instructions are given for Windows and Linux. Run all commands from the
21+
directory that holds the ``.venv``: in PowerShell on Windows, or in a Bash
22+
shell on Linux. The
23+
paths assume ParaView 6.2.0, installed at ``C:\Program Files\ParaView 6.2.0``
24+
on Windows or extracted to ``/opt/ParaView-6.2.0`` on Linux. Adjust them to
25+
match your installation.
26+
27+
Pin pydantic in the ``.venv``
28+
=============================
29+
30+
Pydantic models pass between the API process and the ``pvpython`` process, so
31+
both environments must hold identical pydantic, pydantic-core and
32+
pydantic-settings versions. Pin the ``.venv`` to these versions:
33+
34+
.. tab-set::
35+
:sync-group: os
36+
37+
.. tab-item:: Windows
38+
:sync: windows
39+
40+
.. code-block:: powershell
41+
42+
.venv\Scripts\python.exe -m pip install "pydantic==2.14.1" "pydantic-core==2.50.1" "pydantic-settings==2.6.0"
43+
44+
.. tab-item:: Linux
45+
:sync: linux
46+
47+
.. code-block:: bash
48+
49+
.venv/bin/python -m pip install "pydantic==2.14.1" "pydantic-core==2.50.1" "pydantic-settings==2.6.0"
50+
51+
If these pins ever change, change them in both environments together.
52+
53+
Create the ``.pvenv``
54+
=====================
55+
56+
1. Check the Python version that ``pvpython`` embeds:
57+
58+
.. tab-set::
59+
:sync-group: os
60+
61+
.. tab-item:: Windows
62+
:sync: windows
63+
64+
.. code-block:: powershell
65+
66+
& "C:\Program Files\ParaView 6.2.0\bin\pvpython.exe" -c "import sys; print(sys.version)"
67+
68+
.. tab-item:: Linux
69+
:sync: linux
70+
71+
.. code-block:: bash
72+
73+
/opt/ParaView-6.2.0/bin/pvpython -c "import sys; print(sys.version)"
74+
75+
It must print ``3.12.x``.
76+
77+
2. Create the environment with a CPython of the same minor version:
78+
79+
.. tab-set::
80+
:sync-group: os
81+
82+
.. tab-item:: Windows
83+
:sync: windows
84+
85+
.. code-block:: powershell
86+
87+
py -3.12 -m venv .pvenv
88+
89+
.. tab-item:: Linux
90+
:sync: linux
91+
92+
.. code-block:: bash
93+
94+
python3.12 -m venv .pvenv
95+
96+
3. Install the dependencies. Do not install ``vtk``: ParaView supplies it.
97+
``numpy`` is pinned below 2 so that it matches the numpy 1.26 that
98+
ParaView's own extensions are built against.
99+
100+
.. tab-set::
101+
:sync-group: os
102+
103+
.. tab-item:: Windows
104+
:sync: windows
105+
106+
.. code-block:: powershell
107+
108+
.pvenv\Scripts\python.exe -m pip install "trame==3.12.0" "trame-server>=3.6.0" "wslink>=2.6.0" "trame-rca==2.11.8" "pydantic==2.14.1" "pydantic-core==2.50.1" "pydantic-settings==2.6.0" pyyaml "pillow>=12.3.0" "numpy<2"
109+
110+
.. tab-item:: Linux
111+
:sync: linux
112+
113+
.. code-block:: bash
114+
115+
.pvenv/bin/python -m pip install "trame==3.12.0" "trame-server>=3.6.0" "wslink>=2.6.0" "trame-rca==2.11.8" "pydantic==2.14.1" "pydantic-core==2.50.1" "pydantic-settings==2.6.0" pyyaml "pillow>=12.3.0" "numpy<2"
116+
117+
4. Install ``trame-vtklocal`` without its dependencies, which would pull in
118+
``vtk``:
119+
120+
.. tab-set::
121+
:sync-group: os
122+
123+
.. tab-item:: Windows
124+
:sync: windows
125+
126+
.. code-block:: powershell
127+
128+
.pvenv\Scripts\python.exe -m pip install --no-deps "trame-vtklocal==1.6.2"
129+
130+
.. tab-item:: Linux
131+
:sync: linux
132+
133+
.. code-block:: bash
134+
135+
.pvenv/bin/python -m pip install --no-deps "trame-vtklocal==1.6.2"
136+
137+
5. Install VISOR itself, without dependencies. The ``.pvenv`` must hold the
138+
same VISOR version as the ``.venv``, so read the version from the
139+
``.venv`` and install that version:
140+
141+
.. tab-set::
142+
:sync-group: os
143+
144+
.. tab-item:: Windows
145+
:sync: windows
146+
147+
.. code-block:: powershell
148+
149+
$v = .venv\Scripts\python.exe -c "from importlib.metadata import version; print(version('ansys-visor-viewer'))"
150+
.pvenv\Scripts\python.exe -m pip install --no-deps "ansys-visor-viewer==$v"
151+
152+
.. tab-item:: Linux
153+
:sync: linux
154+
155+
.. code-block:: bash
156+
157+
v=$(.venv/bin/python -c "from importlib.metadata import version; print(version('ansys-visor-viewer'))")
158+
.pvenv/bin/python -m pip install --no-deps "ansys-visor-viewer==$v"
159+
160+
If you work from a clone of the VISOR repository (see the developer
161+
installation in :ref:`installation-index`), install your checkout in
162+
editable mode instead, from the repository root:
163+
164+
.. tab-set::
165+
:sync-group: os
166+
167+
.. tab-item:: Windows
168+
:sync: windows
169+
170+
.. code-block:: powershell
171+
172+
.pvenv\Scripts\python.exe -m pip install --no-deps -e .
173+
174+
.. tab-item:: Linux
175+
:sync: linux
176+
177+
.. code-block:: bash
178+
179+
.pvenv/bin/python -m pip install --no-deps -e .
180+
181+
Verify the ``.pvenv``
182+
=====================
183+
184+
1. numpy and VTK come from the right places:
185+
186+
.. tab-set::
187+
:sync-group: os
188+
189+
.. tab-item:: Windows
190+
:sync: windows
191+
192+
.. code-block:: powershell
193+
194+
& "C:\Program Files\ParaView 6.2.0\bin\pvpython.exe" --venv ".pvenv" -c "import numpy, vtkmodules; print(numpy.__version__, vtkmodules.__path__)"
195+
196+
.. tab-item:: Linux
197+
:sync: linux
198+
199+
.. code-block:: bash
200+
201+
/opt/ParaView-6.2.0/bin/pvpython --venv ".pvenv" -c "import numpy, vtkmodules; print(numpy.__version__, vtkmodules.__path__)"
202+
203+
The output must show numpy ``1.26.x`` and a ``vtkmodules`` path inside the
204+
ParaView installation directory. A path under ``.pvenv`` means a pip copy
205+
of VTK was installed: remove it.
206+
207+
2. The pydantic versions match. Run both commands and compare the
208+
``pydantic`` lines; all three must be identical:
209+
210+
.. tab-set::
211+
:sync-group: os
212+
213+
.. tab-item:: Windows
214+
:sync: windows
215+
216+
.. code-block:: powershell
217+
218+
.venv\Scripts\python.exe -m pip list
219+
.pvenv\Scripts\python.exe -m pip list
220+
221+
.. tab-item:: Linux
222+
:sync: linux
223+
224+
.. code-block:: bash
225+
226+
.venv/bin/python -m pip list
227+
.pvenv/bin/python -m pip list
228+
229+
Configure VISOR
230+
===============
231+
232+
Add these keys to the ``.visor`` file in the directory the API is started
233+
from (see :ref:`configure-visor` for the file format):
234+
235+
.. tab-set::
236+
:sync-group: os
237+
238+
.. tab-item:: Windows
239+
:sync: windows
240+
241+
.. code-block:: yaml
242+
243+
paraview_pvpython: C:/Program Files/ParaView 6.2.0/bin/pvpython.exe
244+
paraview_venv: C:/path/to/visor/.pvenv
245+
pvserver_host: localhost
246+
pvserver_port: 11111
247+
248+
.. tab-item:: Linux
249+
:sync: linux
250+
251+
.. code-block:: yaml
252+
253+
paraview_pvpython: /opt/ParaView-6.2.0/bin/pvpython
254+
paraview_venv: /path/to/visor/.pvenv
255+
pvserver_host: localhost
256+
pvserver_port: 11111
257+
258+
``pvserver_host`` and ``pvserver_port`` are the defaults used when a session
259+
does not name a server.
260+
261+
.. _paraview-mode-launch-pvserver:
262+
263+
Launch ``pvserver``
264+
===================
265+
266+
VISOR does not start ``pvserver``. You must start one ``pvserver`` process
267+
manually for every VISOR instance in PARAVIEW mode, before you start that
268+
instance:
269+
270+
- A ``pvserver`` serves one VISOR instance only. Started without
271+
``--multi-clients``, it accepts a single connection and exits when that
272+
instance ends.
273+
- To run several PARAVIEW instances at the same time, start one ``pvserver``
274+
per instance, each on its own port, and give each instance its port. For
275+
example, with the VISOR CLI:
276+
277+
.. code-block:: console
278+
279+
visor-cli server init --rendering-mode PARAVIEW --pvserver-port 11112 --start
280+
281+
Instances that do not name a port use ``pvserver_port`` from the ``.visor``
282+
file.
283+
- After an instance ends, start a new ``pvserver`` before you start the next
284+
instance on that port.
285+
286+
Start ``pvserver`` without ``--multi-clients``:
287+
288+
.. tab-set::
289+
:sync-group: os
290+
291+
.. tab-item:: Windows
292+
:sync: windows
293+
294+
.. code-block:: powershell
295+
296+
& "C:\Program Files\ParaView 6.2.0\bin\pvserver.exe" --server-port=11111 --force-offscreen-rendering
297+
298+
.. tab-item:: Linux
299+
:sync: linux
300+
301+
.. code-block:: bash
302+
303+
/opt/ParaView-6.2.0/bin/pvserver --server-port=11111 --force-offscreen-rendering
304+
305+
Before starting ``pvserver``, stop any ``pvserver`` or ``pvpython`` processes
306+
left from an earlier run: a stale process causes version handshake errors.
307+
308+
``pvserver`` must be able to read the files VISOR opens, at the same path
309+
the API is given.
310+
311+
If ``pvserver`` is not running, VISOR fails to connect after about ten
312+
seconds and reports an error that names the ``host:port`` it tried.
313+
314+
Offscreen rendering on Linux
315+
----------------------------
316+
317+
On a Linux machine without a display, both ``pvserver`` and the ``pvpython``
318+
process that the API starts need an OpenGL context. Use one of these options:
319+
320+
- A ParaView build with EGL or OSMesa support, which renders offscreen
321+
without an X server.
322+
- A virtual X display: run ``pvserver`` and the VISOR API under ``xvfb-run``.
323+
VISOR does not wrap the ``pvpython`` process itself, so it inherits the
324+
display of the API process.

0 commit comments

Comments
 (0)