Skip to content

Commit ee38006

Browse files
committed
Fix JB2 in CI
1 parent d7c3c5f commit ee38006

File tree

2 files changed

+139
-30
lines changed

2 files changed

+139
-30
lines changed

.github/workflows/deploy.yml

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,92 @@ jobs:
1919
environment:
2020
name: github-pages
2121
url: ${{ steps.deployment.outputs.page_url }}
22+
defaults:
23+
run:
24+
shell: bash -leo pipefail {0}
2225
runs-on: ubuntu-latest
2326
steps:
2427
- uses: actions/checkout@v5
2528

2629
- name: Set up Pages
2730
uses: actions/configure-pages@v5
2831

29-
- name: Set up Python
32+
- name: Set up conda env
3033
uses: mamba-org/setup-micromamba@v2
3134
with:
3235
environment-file: environment.yml
3336
cache-environment: true
37+
create-args: >-
38+
libegl
39+
libgles
40+
# mesalib
41+
# ipywidgets
42+
# trame
43+
# trame-vtk
44+
# trame-vuetify
45+
46+
- name: Install JB2
47+
run: python -m pip install -U --pre "jupyter-book==2.*" --no-deps -v
48+
49+
# - name: Set up PyVista
50+
# # libglx-mesa0, libgl1, xvfb already present in ubuntu-24.04
51+
# run: |
52+
# sudo apt-get update
53+
# sudo apt-get install -y libglx-mesa0 libgl1 xvfb libosmesa6
54+
55+
# - name: Start xvfb
56+
# run: python -c "import pyvista as pv; pv.start_xvfb()"
57+
58+
- name: PyVista test
59+
# xvfb-run -s "-screen 0 1024x768x24" python -c '
60+
run: |
61+
python -c '
62+
import os
63+
import vtk
64+
import pyvista as pv
65+
66+
# pv.BUILDING_GALLERY = True
67+
68+
print("=== Environment variables ===")
69+
print("VTK_DEFAULT_OPENGL_WINDOW =", os.environ.get("VTK_DEFAULT_OPENGL_WINDOW"))
70+
print("PYVISTA_OFF_SCREEN =", os.environ.get("PYVISTA_OFF_SCREEN"))
71+
72+
print("\n=== VTK backend check ===")
73+
rw = vtk.vtkRenderWindow()
74+
print("RenderWindow backend:", rw.GetClassName())
75+
76+
print("\n=== PyVista backend check ===")
77+
# print("PyVista rendering_backend:", pv.global_theme.rendering_backend)
78+
79+
# Force PyVista to off-screen if not already
80+
# pv.global_theme.off_screen = True
81+
print("PyVista OFF_SCREEN before:", pv.OFF_SCREEN)
82+
pv.OFF_SCREEN = True
83+
84+
print("\n=== Rendering test ===")
85+
sphere = pv.Sphere()
86+
plotter = pv.Plotter(off_screen=True)
87+
plotter.add_mesh(sphere, color="tomato")
88+
plotter.show(screenshot="backend_test.png")
89+
print("Rendered sphere saved as backend_test.png")
90+
'
91+
env:
92+
PYVISTA_OFF_SCREEN: true
93+
# VTK_DEFAULT_OPENGL_WINDOW: vtkOSOpenGLRenderWindow
94+
# VTK_DEFAULT_OPENGL_WINDOW: vtkXOpenGLRenderWindow
95+
96+
# JB2 has --execute, but this way we can see how long it takes
97+
- name: Execute the notebook
98+
run: jupyter nbconvert --to notebook --execute --inplace 03-viz.ipynb
99+
env:
100+
PYVISTA_OFF_SCREEN: true
101+
# VTK_DEFAULT_BACKEND: X
102+
# VTK_USE_OSMESA: "1"
103+
# VTK_DEFAULT_OPENGL_WINDOW: vtkOSOpenGLRenderWindow
104+
# VTK_DEFAULT_OPENGL_WINDOW: vtkXOpenGLRenderWindow
34105

35106
- name: Build HTML
36-
run: jupyter-book build --html --execute --strict --ci
37-
shell: micromamba-shell {0}
107+
run: jupyter book build --html --strict --ci
38108

39109
- name: Upload artifact
40110
uses: actions/upload-pages-artifact@v4

03-viz.ipynb

Lines changed: 66 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"title: Viz\n",
1616
"subtitle: Visualizing native-grid output in Python\n",
1717
"label: page:viz\n",
18+
"kernelspec:\n",
19+
" name: python3\n",
1820
"---"
1921
]
2022
},
@@ -53,6 +55,40 @@
5355
"cell_type": "code",
5456
"execution_count": null,
5557
"id": "2",
58+
"metadata": {},
59+
"outputs": [],
60+
"source": [
61+
"import sys\n",
62+
"\n",
63+
"print(f\"Python: {sys.version}\")\n",
64+
"\n",
65+
"try:\n",
66+
" import pyvista as pv\n",
67+
"\n",
68+
" print(f\"PyVista version: {pv.__version__}\")\n",
69+
" print(f\"Off screen: {pv.OFF_SCREEN}\")\n",
70+
"\n",
71+
" # pv.start_xvfb()\n",
72+
" pv.set_jupyter_backend(\"static\")\n",
73+
" pv.global_theme.notebook = False\n",
74+
"\n",
75+
" # Try a simple plot\n",
76+
" sphere = pv.Sphere()\n",
77+
" plotter = pv.Plotter(off_screen=True)\n",
78+
" plotter.add_mesh(sphere)\n",
79+
" plotter.show(screenshot=\"test.png\")\n",
80+
" print(\"SUCCESS: PyVista works!\")\n",
81+
"except Exception as e:\n",
82+
" print(f\"ERROR: {e}\")\n",
83+
" import traceback\n",
84+
"\n",
85+
" traceback.print_exc()"
86+
]
87+
},
88+
{
89+
"cell_type": "code",
90+
"execution_count": null,
91+
"id": "3",
5692
"metadata": {
5793
"editable": true,
5894
"slideshow": {
@@ -76,14 +112,17 @@
76112
"import xarray as xr\n",
77113
"\n",
78114
"# https://docs.pyvista.org/user-guide/jupyter/index.html\n",
115+
"# if os.environ.get(\"CI\", \"true\") == \"true\":\n",
116+
"# pv.start_xvfb()\n",
79117
"pv.set_jupyter_backend(\"static\")\n",
118+
"# pv.set_jupyter_backend(\"html\")\n",
80119
"\n",
81120
"_ = xr.set_options(display_expand_data=False)"
82121
]
83122
},
84123
{
85124
"cell_type": "markdown",
86-
"id": "3",
125+
"id": "4",
87126
"metadata": {
88127
"editable": true,
89128
"slideshow": {
@@ -100,7 +139,7 @@
100139
{
101140
"cell_type": "code",
102141
"execution_count": null,
103-
"id": "4",
142+
"id": "5",
104143
"metadata": {
105144
"editable": true,
106145
"slideshow": {
@@ -141,7 +180,7 @@
141180
{
142181
"cell_type": "code",
143182
"execution_count": null,
144-
"id": "5",
183+
"id": "6",
145184
"metadata": {
146185
"editable": true,
147186
"slideshow": {
@@ -167,7 +206,7 @@
167206
},
168207
{
169208
"cell_type": "markdown",
170-
"id": "6",
209+
"id": "7",
171210
"metadata": {
172211
"editable": true,
173212
"slideshow": {
@@ -184,7 +223,7 @@
184223
{
185224
"cell_type": "code",
186225
"execution_count": null,
187-
"id": "7",
226+
"id": "8",
188227
"metadata": {},
189228
"outputs": [],
190229
"source": [
@@ -211,7 +250,7 @@
211250
{
212251
"cell_type": "code",
213252
"execution_count": null,
214-
"id": "8",
253+
"id": "9",
215254
"metadata": {},
216255
"outputs": [],
217256
"source": [
@@ -238,7 +277,7 @@
238277
{
239278
"cell_type": "code",
240279
"execution_count": null,
241-
"id": "9",
280+
"id": "10",
242281
"metadata": {},
243282
"outputs": [],
244283
"source": [
@@ -260,7 +299,7 @@
260299
{
261300
"cell_type": "code",
262301
"execution_count": null,
263-
"id": "10",
302+
"id": "11",
264303
"metadata": {},
265304
"outputs": [],
266305
"source": [
@@ -289,7 +328,7 @@
289328
{
290329
"cell_type": "code",
291330
"execution_count": null,
292-
"id": "11",
331+
"id": "12",
293332
"metadata": {},
294333
"outputs": [],
295334
"source": [
@@ -312,7 +351,7 @@
312351
},
313352
{
314353
"cell_type": "markdown",
315-
"id": "12",
354+
"id": "13",
316355
"metadata": {
317356
"editable": true,
318357
"slideshow": {
@@ -331,7 +370,7 @@
331370
{
332371
"cell_type": "code",
333372
"execution_count": null,
334-
"id": "13",
373+
"id": "14",
335374
"metadata": {
336375
"editable": true,
337376
"slideshow": {
@@ -347,7 +386,7 @@
347386
},
348387
{
349388
"cell_type": "markdown",
350-
"id": "14",
389+
"id": "15",
351390
"metadata": {
352391
"editable": true,
353392
"slideshow": {
@@ -364,7 +403,7 @@
364403
{
365404
"cell_type": "code",
366405
"execution_count": null,
367-
"id": "15",
406+
"id": "16",
368407
"metadata": {
369408
"editable": true,
370409
"slideshow": {
@@ -380,7 +419,7 @@
380419
{
381420
"cell_type": "code",
382421
"execution_count": null,
383-
"id": "16",
422+
"id": "17",
384423
"metadata": {
385424
"editable": true,
386425
"slideshow": {
@@ -397,7 +436,7 @@
397436
{
398437
"cell_type": "code",
399438
"execution_count": null,
400-
"id": "17",
439+
"id": "18",
401440
"metadata": {
402441
"editable": true,
403442
"slideshow": {
@@ -413,7 +452,7 @@
413452
{
414453
"cell_type": "code",
415454
"execution_count": null,
416-
"id": "18",
455+
"id": "19",
417456
"metadata": {
418457
"editable": true,
419458
"slideshow": {
@@ -460,7 +499,7 @@
460499
},
461500
{
462501
"cell_type": "markdown",
463-
"id": "19",
502+
"id": "20",
464503
"metadata": {
465504
"editable": true,
466505
"slideshow": {
@@ -477,7 +516,7 @@
477516
{
478517
"cell_type": "code",
479518
"execution_count": null,
480-
"id": "20",
519+
"id": "21",
481520
"metadata": {
482521
"editable": true,
483522
"slideshow": {
@@ -502,7 +541,7 @@
502541
{
503542
"cell_type": "code",
504543
"execution_count": null,
505-
"id": "21",
544+
"id": "22",
506545
"metadata": {},
507546
"outputs": [],
508547
"source": [
@@ -532,7 +571,7 @@
532571
{
533572
"cell_type": "code",
534573
"execution_count": null,
535-
"id": "22",
574+
"id": "23",
536575
"metadata": {
537576
"editable": true,
538577
"slideshow": {
@@ -567,7 +606,7 @@
567606
},
568607
{
569608
"cell_type": "markdown",
570-
"id": "23",
609+
"id": "24",
571610
"metadata": {
572611
"editable": true,
573612
"slideshow": {
@@ -586,7 +625,7 @@
586625
{
587626
"cell_type": "code",
588627
"execution_count": null,
589-
"id": "24",
628+
"id": "25",
590629
"metadata": {
591630
"editable": true,
592631
"slideshow": {
@@ -629,7 +668,7 @@
629668
},
630669
{
631670
"cell_type": "markdown",
632-
"id": "25",
671+
"id": "26",
633672
"metadata": {},
634673
"source": [
635674
"(sec:geovista)=\n",
@@ -644,7 +683,7 @@
644683
{
645684
"cell_type": "code",
646685
"execution_count": null,
647-
"id": "26",
686+
"id": "27",
648687
"metadata": {},
649688
"outputs": [],
650689
"source": [
@@ -679,7 +718,7 @@
679718
{
680719
"cell_type": "code",
681720
"execution_count": null,
682-
"id": "27",
721+
"id": "28",
683722
"metadata": {},
684723
"outputs": [],
685724
"source": [
@@ -705,7 +744,7 @@
705744
},
706745
{
707746
"cell_type": "markdown",
708-
"id": "28",
747+
"id": "29",
709748
"metadata": {
710749
"editable": true,
711750
"slideshow": {
@@ -732,7 +771,7 @@
732771
{
733772
"cell_type": "code",
734773
"execution_count": null,
735-
"id": "29",
774+
"id": "30",
736775
"metadata": {
737776
"editable": true,
738777
"slideshow": {

0 commit comments

Comments
 (0)