-
Notifications
You must be signed in to change notification settings - Fork 8
Fix CI abort: skip PyVista Plotter test on headless runners #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -49,6 +49,15 @@ def check_module_available(module_name: str) -> bool: | |||||
| HAS_GDAL = check_module_available("osgeo.gdal") | ||||||
| HAS_GEOPANDAS = check_module_available("geopandas") | ||||||
| HAS_PYVISTA = check_module_available("pyvista") | ||||||
|
|
||||||
| # Check if a display server is available for rendering. | ||||||
| # On headless CI (no DISPLAY, no WAYLAND), pyvista.Plotter() calls | ||||||
| # VTK's OpenGL probe which aborts the entire process — not catchable | ||||||
| # with try/except. We must skip rendering tests before they run. | ||||||
| import os | ||||||
| HAS_DISPLAY = bool(os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY") | ||||||
| or os.environ.get("PYVISTA_OFF_SCREEN")) | ||||||
| HAS_PYVISTA_RENDERING = HAS_PYVISTA and HAS_DISPLAY | ||||||
| HAS_TRAME = check_module_available("trame") | ||||||
|
|
||||||
| # Composite feature flags | ||||||
|
|
@@ -98,6 +107,11 @@ def check_petsc_has_pragmatic() -> bool: | |||||
| reason="Requires pyvista. Install with: pixi install -e runtime" | ||||||
| ) | ||||||
|
|
||||||
| requires_pyvista_rendering = pytest.mark.skipif( | ||||||
| not HAS_PYVISTA_RENDERING, | ||||||
| reason="Requires pyvista and a display server (DISPLAY or PYVISTA_OFF_SCREEN)" | ||||||
|
||||||
| reason="Requires pyvista and a display server (DISPLAY or PYVISTA_OFF_SCREEN)" | |
| reason="Requires pyvista and a display server (DISPLAY, WAYLAND_DISPLAY, or PYVISTA_OFF_SCREEN)" |
Copilot
AI
Feb 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting pv.OFF_SCREEN = True as a global module-level attribute mutation inside a test method has a side effect: it permanently modifies the PyVista global state for the entire test session. Any subsequent tests that create a pv.Plotter() without off_screen=True will inherit this global flag. Since this test already passes off_screen=True directly to pv.Plotter(), the global pv.OFF_SCREEN = True assignment is redundant and should be removed to avoid unintended side effects on other tests.
| pv.OFF_SCREEN = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
import osstatement is placed mid-file at line 57, after module-level dependency flags have already been set. The existing imports at the top of the file (lines 22-25) are whereosshould be imported along withpytestandsys. Placing imports mid-module deviates from PEP 8 conventions and from the import pattern used throughout this file. Moveimport osto the top-level imports block near line 22-24, alongsideimport pytestandimport sys. Note thatosis also re-imported insidecheck_petsc_has_pragmatic()at line 70, which would then be unnecessary.