Repository navigation
Expand file tree
/
Copy pathscient-compute-python-kernel.yml
More file actions
458 lines (432 loc) · 22 KB
/
Copy pathscient-compute-python-kernel.yml
File metadata and controls
458 lines (432 loc) · 22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# Runs the part of the compute session's Python work that the main CI lanes
# cannot: a real Jupyter kernel, on more than one operating system and more than
# one interpreter version.
#
# The bridge's own unit tests need nothing but a standard library and so run on
# every pull request from `ci.yml`. What is here needs `jupyter_client`,
# `ipykernel`, matplotlib, pandas, and a live subprocess tree, which is why it
# is conditionally called by CI and remains manually dispatchable.
#
# Every matrix spans the four computers Scient ships for: Apple Silicon, Intel
# Mac, Windows x64 and Linux x64.
name: Scient Compute Python Kernel
on:
workflow_call:
inputs:
real_kernel:
type: boolean
default: true
managed_python:
type: boolean
default: true
# Only the Compute product case changed: run it alone, on Linux with Python 3.12.
# Every real-kernel run includes it.
python_product:
type: boolean
default: false
# `linux` when only broad inputs (dependencies, configuration, workspace
# code) changed; see compute-ci-gate.mjs. Anything else runs all four.
platforms:
type: string
default: all
workflow_dispatch:
inputs:
real_kernel:
description: Run the real-kernel OS and Python-version matrix
type: boolean
default: true
managed_python:
description: Provision and qualify managed Python toolkits
type: boolean
default: true
permissions:
contents: read
concurrency:
group: scient-compute-python-kernel-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
managed_python:
if: ${{ inputs.managed_python }}
name: Managed Python toolkits / ${{ matrix.runner }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
runner: ${{ fromJSON(inputs.platforms == 'linux' && '["ubuntu-24.04"]' || '["ubuntu-24.04", "macos-15", "macos-15-intel", "windows-2025"]') }}
defaults:
run:
shell: bash
steps:
# The runner's C: drive is slow for many small files; its D: drive, which holds the
# workspace, is several times faster. Temporary files (build stages, Python
# environments, extracted archives) go there.
- name: Use the D drive for temporary files
if: ${{ runner.os == 'Windows' }}
shell: bash
run: printf 'TEMP=%s\nTMP=%s\n' "$RUNNER_TEMP" "$RUNNER_TEMP" >> "$GITHUB_ENV"
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 0
sparse-checkout: |
/*
!/.repos/
sparse-checkout-cone-mode: false
# No package cache in this workflow: on the Macs restoring the 0.9–1.6 GB store took longer
# than installing the filtered workspace from the registry (Apple Silicon 102–174 s against
# 41–52 s), and the cache's post step packed it again after every job. Windows and Linux
# measured the same either way.
# pnpm accepts an earlier pass for the same lockfile and policy, so a cached record skips
# re-checking every package's registry metadata (13-29 s on the Intel Mac).
- name: Keep pnpm metadata beside the job
run: echo "pnpm_config_cache_dir=$RUNNER_TEMP/pnpm-metadata" >> "$GITHUB_ENV"
- name: Restore lockfile verification
id: pnpm_verified
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/pnpm-metadata/lockfile-verified.jsonl
key: pnpm-verified-v1-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'package.json') }}
- name: Setup Vite+
uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1
with:
node-version-file: package.json
cache: false
run-install: |
args:
- --filter=t3...
- name: Save lockfile verification
if: ${{ github.event_name != 'merge_group' && steps.pnpm_verified.outputs.cache-hit != 'true' }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/pnpm-metadata/lockfile-verified.jsonl
key: ${{ steps.pnpm_verified.outputs.cache-primary-key }}
# The production provisioner downloads pinned private uv/CPython and uses
# the checked-in lock. No ambient pip environment can satisfy this test.
- name: Seal candidate recipe metadata
run: node apps/server/scripts/compute-recipes.ts seal
- name: Assert native qualification target
env:
EXPECTED_TARGET: ${{ fromJSON('{"ubuntu-24.04":"linux-x64","macos-15":"darwin-arm64","macos-15-intel":"darwin-x64","windows-2025":"win32-x64"}')[matrix.runner] }}
run: node -e 'require("node:assert/strict").equal(`${process.platform}-${process.arch}`, process.env.EXPECTED_TARGET)'
# Windows qualifies recipes in managed_recipes, beside this, its longest job.
- name: Qualify recipes
if: ${{ matrix.runner != 'windows-2025' }}
working-directory: apps/server
env:
SCIENT_TEST_MANAGED_PYTHON: "1"
MPLBACKEND: Agg
run: vp test run src/scient/compute/ComputeRecipe.live.test.ts --maxWorkers=1
- name: Qualify base, every toolkit combination, and retained kernels
working-directory: apps/server
env:
SCIENT_TEST_MANAGED_PYTHON: "1"
MPLBACKEND: Agg
run: vp test bench --run src/scient/compute/ManagedPythonProduct.bench.ts --maxWorkers=1
managed_recipes:
if: ${{ inputs.managed_python && inputs.platforms != 'linux' }}
name: Managed Python recipes / windows-2025
runs-on: windows-2025
timeout-minutes: 20
defaults:
run:
shell: bash
steps:
# The runner's C: drive is slow for many small files; its D: drive, which holds the
# workspace, is several times faster. Temporary files (build stages, Python
# environments, extracted archives) go there.
- name: Use the D drive for temporary files
if: ${{ runner.os == 'Windows' }}
shell: bash
run: printf 'TEMP=%s\nTMP=%s\n' "$RUNNER_TEMP" "$RUNNER_TEMP" >> "$GITHUB_ENV"
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 0
sparse-checkout: |
/*
!/.repos/
sparse-checkout-cone-mode: false
# pnpm accepts an earlier pass for the same lockfile and policy, so a cached record skips
# re-checking every package's registry metadata (13-29 s on the Intel Mac).
- name: Keep pnpm metadata beside the job
run: echo "pnpm_config_cache_dir=$RUNNER_TEMP/pnpm-metadata" >> "$GITHUB_ENV"
- name: Restore lockfile verification
id: pnpm_verified
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/pnpm-metadata/lockfile-verified.jsonl
key: pnpm-verified-v1-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'package.json') }}
- name: Setup Vite+
uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1
with:
node-version-file: package.json
cache: false
run-install: |
args:
- --filter=t3...
- name: Save lockfile verification
if: ${{ github.event_name != 'merge_group' && steps.pnpm_verified.outputs.cache-hit != 'true' }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/pnpm-metadata/lockfile-verified.jsonl
key: ${{ steps.pnpm_verified.outputs.cache-primary-key }}
- name: Seal candidate recipe metadata
run: node apps/server/scripts/compute-recipes.ts seal
- name: Assert native qualification target
run: node -e 'require("node:assert/strict").equal(`${process.platform}-${process.arch}`, "win32-x64")'
- name: Qualify recipes
working-directory: apps/server
env:
SCIENT_TEST_MANAGED_PYTHON: "1"
MPLBACKEND: Agg
run: vp test run src/scient/compute/ComputeRecipe.live.test.ts --maxWorkers=1
real_kernel:
if: ${{ inputs.real_kernel || inputs.python_product }}
name: Real kernel / ${{ matrix.runner }}${{ matrix.python != 'both' && format(' / Python {0}', matrix.python) || '' }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
strategy:
fail-fast: false
# Macs run both versions in one job: their runner slots are the scarcest. Windows, where
# setup is cheap beside the two suites, runs each version on its own runner.
matrix:
include: ${{ fromJSON(!inputs.real_kernel && '[{"runner":"ubuntu-24.04","python":"3.12"}]' || inputs.platforms == 'linux' && '[{"runner":"ubuntu-24.04","python":"both"}]' || '[{"runner":"ubuntu-24.04","python":"both"},{"runner":"macos-15","python":"both"},{"runner":"macos-15-intel","python":"both"},{"runner":"windows-2025","python":"3.10"},{"runner":"windows-2025","python":"3.12"}]') }}
defaults:
run:
shell: bash
steps:
- name: Use the D drive for temporary files
if: ${{ runner.os == 'Windows' }}
run: printf 'TEMP=%s\nTMP=%s\n' "$RUNNER_TEMP" "$RUNNER_TEMP" >> "$GITHUB_ENV"
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
sparse-checkout: |
/*
!/.repos/
sparse-checkout-cone-mode: false
# pnpm accepts an earlier pass for the same lockfile and policy, so a cached record skips
# re-checking every package's registry metadata (13-29 s on the Intel Mac).
- name: Keep pnpm metadata beside the job
run: echo "pnpm_config_cache_dir=$RUNNER_TEMP/pnpm-metadata" >> "$GITHUB_ENV"
- name: Restore lockfile verification
id: pnpm_verified
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/pnpm-metadata/lockfile-verified.jsonl
key: pnpm-verified-v1-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'package.json') }}
- name: Setup Vite+
uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1
with:
node-version-file: package.json
cache: false
run-install: |
args:
- --filter=t3...
- name: Save lockfile verification
if: ${{ github.event_name != 'merge_group' && steps.pnpm_verified.outputs.cache-hit != 'true' }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/pnpm-metadata/lockfile-verified.jsonl
key: ${{ steps.pnpm_verified.outputs.cache-primary-key }}
# Both ends of the supported range, because the failures this suite
# catches are version-dependent asyncio and kernel-startup behaviour:
# 3.10 is the floor the runtime adapter enforces, 3.12 is what a current
# user is most likely to already have. A Mac job runs both, one after the
# other, since Mac runners are the scarcest.
- name: Setup Python 3.10
if: ${{ matrix.python == 'both' || matrix.python == '3.10' }}
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: "3.10"
# Importing the font manager builds matplotlib's font cache: over a minute on a fresh
# Windows runner, which otherwise lands inside the suite's 90-second figure step.
- name: Install kernel dependencies on Python 3.10
if: ${{ matrix.python == 'both' || matrix.python == '3.10' }}
run: |
set -euo pipefail
python -m pip install --upgrade pip
python -m pip install "jupyter_client>=8.6" "ipykernel>=6.29" matplotlib pandas
python -c "import matplotlib.font_manager"
# The absolute path rather than `python`: this value becomes the launch
# plan's executable, so resolving it once here is what makes the kernel
# under test the interpreter this step set up.
- name: Run the real-kernel integration suite on Python 3.10
if: ${{ matrix.python == 'both' || matrix.python == '3.10' }}
working-directory: apps/server
env:
# Headless runners have no display, and a figure that opened a window
# would hang the execution the test is waiting on.
MPLBACKEND: Agg
run: |
set -euo pipefail
SCIENT_TEST_PYTHON="$(python -c 'import sys; print(sys.executable)')"
export SCIENT_TEST_PYTHON
vp test run \
src/scient/compute/PythonKernel.integration.test.ts \
src/scient/compute/PythonComputeService.integration.test.ts \
src/scient/compute/FreshCompute.integration.test.ts \
src/preview/PortScannerPythonCompute.integration.test.ts
- name: Setup Python 3.12
if: ${{ matrix.python == 'both' || matrix.python == '3.12' }}
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: "3.12"
# Importing the font manager builds matplotlib's font cache: over a minute on a fresh
# Windows runner, which otherwise lands inside the suite's 90-second figure step.
- name: Install kernel dependencies on Python 3.12
if: ${{ matrix.python == 'both' || matrix.python == '3.12' }}
run: |
set -euo pipefail
python -m pip install --upgrade pip
python -m pip install "jupyter_client>=8.6" "ipykernel>=6.29" matplotlib pandas
python -c "import matplotlib.font_manager"
# The absolute path rather than `python`: this value becomes the launch
# plan's executable, so resolving it once here is what makes the kernel
# under test the interpreter this step set up.
- name: Run the real-kernel integration suite on Python 3.12
if: ${{ inputs.real_kernel && (matrix.python == 'both' || matrix.python == '3.12') }}
working-directory: apps/server
env:
# Headless runners have no display, and a figure that opened a window
# would hang the execution the test is waiting on.
MPLBACKEND: Agg
run: |
set -euo pipefail
SCIENT_TEST_PYTHON="$(python -c 'import sys; print(sys.executable)')"
export SCIENT_TEST_PYTHON
vp test run \
src/scient/compute/PythonKernel.integration.test.ts \
src/scient/compute/PythonComputeService.integration.test.ts \
src/scient/compute/FreshCompute.integration.test.ts \
src/preview/PortScannerPythonCompute.integration.test.ts
# The gateway, durable service and a real kernel together: saved, dirty and restored
# source, retained figure bytes, and a relocated workspace refused. Linux only; the
# kernel suites above cover each platform and interpreter.
- name: Run the Compute product case on Python 3.12
if: ${{ runner.os == 'Linux' && (matrix.python == 'both' || matrix.python == '3.12') }}
working-directory: apps/server
env:
MPLBACKEND: Agg
run: |
set -euo pipefail
SCIENT_TEST_PYTHON="$(python -c 'import sys; print(sys.executable)')"
export SCIENT_TEST_PYTHON
report="$RUNNER_TEMP/compute-product.json"
vp test run src/scient/compute/ComputeProduct.integration.test.ts \
--reporter=default --reporter=json --outputFile.json="$report"
# The suite skips without SCIENT_TEST_PYTHON; a skip must not pass as a run.
node -e 'const r = require(process.argv[1]); if (r.numPassedTests !== 1 || r.numTotalTests !== 1) { console.error("Expected exactly one Compute product case to run", r.numPassedTests, r.numTotalTests); process.exit(1); }' "$report"
real_languages:
if: ${{ inputs.real_kernel }}
name: Real R and Julia / ${{ matrix.runner }}${{ matrix.part != 'all' && format(' / {0}', matrix.part) || '' }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
strategy:
fail-fast: false
# The three proofs share nothing but setup. Macs run them in one job, since their runner
# slots are the scarcest; Windows and Linux run each on its own runner, set up the same way.
matrix:
include: ${{ fromJSON(inputs.platforms == 'linux' && '[{"runner":"ubuntu-24.04","part":"people"},{"runner":"ubuntu-24.04","part":"files"},{"runner":"ubuntu-24.04","part":"kernels"}]' || '[{"runner":"ubuntu-24.04","part":"people"},{"runner":"ubuntu-24.04","part":"files"},{"runner":"ubuntu-24.04","part":"kernels"},{"runner":"windows-2025","part":"people"},{"runner":"windows-2025","part":"files"},{"runner":"windows-2025","part":"kernels"},{"runner":"macos-15","part":"all"},{"runner":"macos-15-intel","part":"all"}]') }}
defaults:
run:
shell: bash
steps:
- name: Use the D drive for temporary files
if: ${{ runner.os == 'Windows' }}
run: printf 'TEMP=%s\nTMP=%s\n' "$RUNNER_TEMP" "$RUNNER_TEMP" >> "$GITHUB_ENV"
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
sparse-checkout: |
/*
!/.repos/
sparse-checkout-cone-mode: false
# pnpm accepts an earlier pass for the same lockfile and policy, so a cached record skips
# re-checking every package's registry metadata (13-29 s on the Intel Mac).
- name: Keep pnpm metadata beside the job
run: echo "pnpm_config_cache_dir=$RUNNER_TEMP/pnpm-metadata" >> "$GITHUB_ENV"
- name: Restore lockfile verification
id: pnpm_verified
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/pnpm-metadata/lockfile-verified.jsonl
key: pnpm-verified-v1-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'package.json') }}
- name: Setup Vite+
uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1
with:
node-version-file: package.json
cache: false
run-install: |
args:
- --filter=t3...
- name: Save lockfile verification
if: ${{ github.event_name != 'merge_group' && steps.pnpm_verified.outputs.cache-hit != 'true' }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/pnpm-metadata/lockfile-verified.jsonl
key: ${{ steps.pnpm_verified.outputs.cache-primary-key }}
# A system install on purpose: nothing here is Scient-managed.
- name: Setup Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: "3.12"
- name: Setup R
uses: r-lib/actions/setup-r@f9a764fea8d5c63df6ef9a5c7795bf7deb5d7e05 # v2
with:
use-public-rspm: true
- name: Setup Julia
uses: julia-actions/setup-julia@4c0cb0fce8556fdb04a90347310e5db8b1f98fb9 # v2
# Before anything is installed into this Python: it stands for a person's plain Python, on a
# computer with nothing that can host the bridge.
- name: Run on what people have
if: ${{ matrix.part == 'all' || matrix.part == 'people' }}
working-directory: apps/server
run: |
set -euo pipefail
SCIENT_TEST_BARE_PYTHON="$(python -c 'import sys; print(sys.executable)')"
export SCIENT_TEST_BARE_PYTHON
vp test run src/scient/compute/KernelLanguages.live.test.ts --maxWorkers=1
# A Windows image can ship a Visual Studio C++ library newer than its LLVM supports
# (STL1000, "expected Clang 22 or newer"), and every clang++ build then fails. Update LLVM
# only when the image's clang++ cannot build against its own library.
- name: Match LLVM to the Visual Studio C++ library
if: ${{ runner.os == 'Windows' && (matrix.part == 'all' || matrix.part == 'files') }}
run: |
set -euo pipefail
probe="$RUNNER_TEMP/stl-probe"
mkdir -p "$probe"
printf '#include <concepts>\nint main() { return 0; }\n' > "$probe/a.cpp"
clang="/c/Program Files/LLVM/bin/clang++.exe"
"$clang" --version | head -n 1
if "$clang" -std=gnu++2b "$probe/a.cpp" -o "$probe/a.exe" 2> "$probe/err.txt"; then
echo "clang++ builds against this image's C++ library."
exit 0
fi
grep -q STL1000 "$probe/err.txt" || { cat "$probe/err.txt"; exit 1; }
echo "clang++ is older than this image's C++ library; updating LLVM."
choco upgrade llvm -y --no-progress > "$probe/choco.txt" || { tail -n 40 "$probe/choco.txt"; exit 1; }
"$clang" --version | head -n 1
"$clang" -std=gnu++2b "$probe/a.cpp" -o "$probe/a.exe"
- name: Run real files and scan this computer
if: ${{ matrix.part == 'all' || matrix.part == 'files' }}
working-directory: apps/server
env:
SCIENT_TEST_RUN_TABLE: "1"
# A compiler's first run on a fresh computer, such as runghc or `dotnet run` on Windows, takes up
# to two minutes, the project's ceiling, so real programs get five.
run: vp test run src/scient/analysis/RunTableAdapter.live.test.ts --maxWorkers=1 --testTimeout=300000
- name: Install the bridge host's packages
if: ${{ matrix.part == 'all' || matrix.part == 'kernels' }}
run: python -m pip install "jupyter_client>=8.6" "ipykernel>=6.29"
- name: Run real R and Julia kernels
if: ${{ matrix.part == 'all' || matrix.part == 'kernels' }}
working-directory: apps/server
env:
SCIENT_TEST_KERNEL_DIR: ${{ runner.temp }}/scient-kernels
run: |
set -euo pipefail
SCIENT_TEST_PYTHON="$(python -c 'import sys; print(sys.executable)')"
export SCIENT_TEST_PYTHON
vp test run src/scient/compute/KernelLanguages.live.test.ts --maxWorkers=1