Skip to content

Commit f8dd6a5

Browse files
trungleducpre-commit-ci[bot]martinRenou
authored
Support progressive rendering (#1489)
* wip * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Bump actions/upload-artifact * Create render plugin * Bump action * Refactor plugins * Add progressive rendering flag * Disable kernel message * Simplify template * Update for reveal template * Update typing * Update macos runner * Add unit tests * Add UI tests * Update snapshots * Update snapshots p2 * Using the same snapshots for both render mode * Update doc * Clean up * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Raise error if jupyter_server 1 with progressive rendering * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Exclude invalid combination from CI * Bump galata * Fix CI --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: martinRenou <[email protected]>
1 parent f1722f4 commit f8dd6a5

38 files changed

+1993
-856
lines changed

.github/workflows/check-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
version_spec: next
3232

3333
- name: Upload Distributions
34-
uses: actions/upload-artifact@v3
34+
uses: actions/upload-artifact@v4
3535
with:
3636
name: voila-releaser-dist-${{ github.run_number }}
3737
path: .jupyter_releaser_checkout/dist

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
strategy:
7575
fail-fast: false
7676
matrix:
77-
os: [macos]
77+
os: [macos-12]
7878
python_version: ['3.8', '3.9', '3.10', '3.11']
7979

8080
steps:

.github/workflows/packaging.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,36 +50,36 @@ jobs:
5050
sha256sum * | tee SHA256SUMS
5151
5252
- name: Upload distributions
53-
uses: actions/upload-artifact@v3
53+
uses: actions/upload-artifact@v4
5454
with:
5555
name: dist ${{ github.run_number }}
5656
path: ./dist
5757

5858
install:
59-
runs-on: ${{ matrix.os }}-latest
59+
runs-on: ${{ matrix.os }}
6060
needs: [build]
6161
strategy:
6262
fail-fast: false
6363
matrix:
64-
os: [ubuntu, macos, windows]
64+
os: [ubuntu-latest, macos-12, windows-latest]
6565
python: ['3.8', '3.10']
6666
include:
6767
- python: '3.8'
6868
dist: 'voila*.tar.gz'
6969
- python: '3.10'
7070
dist: 'voila*.whl'
71-
- os: windows
71+
- os: windows-latest
7272
py_cmd: python
73-
- os: macos
73+
- os: macos-12
7474
py_cmd: python3
75-
- os: ubuntu
75+
- os: ubuntu-latest
7676
py_cmd: python
7777
steps:
7878
- name: Install Python
7979
uses: actions/setup-python@v5
8080
with:
8181
python-version: ${{ matrix.python }}
82-
- uses: actions/download-artifact@v3
82+
- uses: actions/download-artifact@v4
8383
with:
8484
name: dist ${{ github.run_number }}
8585
path: ./dist

.github/workflows/ui-tests.yml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
jupyter-server-version: ["1.24.0", "2.14.2"]
15+
jupyter-server-version: ['1.24.0', '2.14.2']
16+
progressive_rendering: [false, true]
17+
exclude:
18+
- jupyter-server-version: '1.24.0'
19+
progressive_rendering: true
1620
fail-fast: false
1721

1822
steps:
@@ -35,7 +39,7 @@ jobs:
3539
- name: Launch Voila
3640
run: |
3741
# Mount a volume to overwrite the server configuration
38-
jlpm start 2>&1 > /tmp/voila_server.log &
42+
jlpm start --progressive_rendering=${{ matrix.progressive_rendering }} 2>&1 > /tmp/voila_server.log &
3943
working-directory: ui-tests
4044

4145
- name: Install browser
@@ -49,30 +53,46 @@ jobs:
4953
timeout: 360000
5054

5155
- name: Test
56+
env:
57+
PROGRESSIVE_RENDERING: ${{ matrix.progressive_rendering }}
5258
run: jlpm run test
5359
working-directory: ui-tests
5460

61+
- name: Set test report name for progressive rendering
62+
if: always() && matrix.progressive_rendering == true
63+
run: |
64+
echo "TEST_REPORT_NAME=progressive-voila-test-report-${{ matrix.jupyter-server-version }}" >> $GITHUB_ENV
65+
echo "TEST_ASSETS_NAME=progressive-voila-test-assets-${{ matrix.jupyter-server-version }}" >> $GITHUB_ENV
66+
echo "TEST_BENCHMARK_NAME=progressive-voila-test-benchmark-${{ matrix.jupyter-server-version }}" >> $GITHUB_ENV
67+
68+
- name: Set test report name for non-progressive rendering
69+
if: always() && matrix.progressive_rendering == false
70+
run: |
71+
echo "TEST_REPORT_NAME=voila-test-report-${{ matrix.jupyter-server-version }}" >> $GITHUB_ENV
72+
echo "TEST_ASSETS_NAME=voila-test-assets-${{ matrix.jupyter-server-version }}" >> $GITHUB_ENV
73+
echo "TEST_BENCHMARK_NAME=voila-test-benchmark-${{ matrix.jupyter-server-version }}" >> $GITHUB_ENV
74+
5575
- name: Upload Playwright Test assets
5676
if: always()
57-
uses: actions/upload-artifact@v3
77+
uses: actions/upload-artifact@v4
5878
with:
59-
name: voila-test-assets
79+
name: ${{ env.TEST_ASSETS_NAME }}
6080
path: |
6181
ui-tests/test-results
6282
6383
- name: Upload Playwright Benchmark report
6484
if: always()
65-
uses: actions/upload-artifact@v3
85+
uses: actions/upload-artifact@v4
6686
with:
67-
name: voila-benchmark-report
87+
name: ${{ env.TEST_BENCHMARK_NAME }}
6888
path: |
6989
ui-tests/benchmark-results
7090
7191
- name: Upload Playwright Test report
7292
if: always()
73-
uses: actions/upload-artifact@v3
93+
uses: actions/upload-artifact@v4
7494
with:
75-
name: voila-test-report
95+
name: ${{ env.TEST_REPORT_NAME }}
7696
path: |
7797
ui-tests/playwright-report
7898

.github/workflows/update_galata_references.yaml

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,70 @@ defaults:
1515
jobs:
1616
update-reference-screenshots:
1717
name: Update Galata References
18-
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'update galata references') }}
18+
if: >
19+
(
20+
github.event.comment.author_association == 'OWNER' ||
21+
github.event.comment.author_association == 'COLLABORATOR' ||
22+
github.event.comment.author_association == 'MEMBER'
23+
) && github.event.issue.pull_request && contains(github.event.comment.body, 'please update snapshots')
1924
runs-on: ubuntu-latest
2025
strategy:
2126
matrix:
22-
python-version: [3.8]
23-
node-version: [16.x]
27+
python-version: [3.10]
28+
node-version: [18.x]
2429

2530
steps:
26-
- name: Base Setup
27-
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
31+
- name: React to the triggering comment
32+
run: |
33+
gh api repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions --raw-field 'content=+1'
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2836

2937
- name: Checkout
30-
uses: actions/checkout@v2
38+
uses: actions/checkout@v4
3139
with:
3240
token: ${{ secrets.GITHUB_TOKEN }}
3341

34-
- name: Configure git to use https
35-
run: git config --global hub.protocol https
42+
- name: Get PR Info
43+
id: pr
44+
env:
45+
PR_NUMBER: ${{ github.event.issue.number }}
46+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
GH_REPO: ${{ github.repository }}
48+
COMMENT_AT: ${{ github.event.comment.created_at }}
49+
run: |
50+
pr="$(gh api /repos/${GH_REPO}/pulls/${PR_NUMBER})"
51+
head_sha="$(echo "$pr" | jq -r .head.sha)"
52+
pushed_at="$(echo "$pr" | jq -r .pushed_at)"
53+
54+
if [[ $(date -d "$pushed_at" +%s) -gt $(date -d "$COMMENT_AT" +%s) ]]; then
55+
echo "Updating is not allowed because the PR was pushed to (at $pushed_at) after the triggering comment was issued (at $COMMENT_AT)"
56+
exit 1
57+
fi
58+
59+
echo "head_sha=$head_sha" >> $GITHUB_OUTPUT
3660
3761
- name: Checkout the branch from the PR that triggered the job
38-
run: hub pr checkout ${{ github.event.issue.number }}
3962
env:
4063
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
run: gh pr checkout ${{ github.event.issue.number }}
65+
66+
- name: Validate the fetched branch HEAD revision
67+
env:
68+
EXPECTED_SHA: ${{ steps.pr.outputs.head_sha }}
69+
run: |
70+
actual_sha="$(git rev-parse HEAD)"
71+
72+
if [[ "$actual_sha" != "$EXPECTED_SHA" ]]; then
73+
echo "The HEAD of the checked out branch ($actual_sha) differs from the HEAD commit available at the time when trigger comment was submitted ($EXPECTED_SHA)"
74+
exit 1
75+
fi
76+
77+
- name: Base Setup
78+
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
79+
80+
- name: Configure git to use https
81+
run: git config --global hub.protocol https
4182

4283
- name: Install dependencies
4384
run: |

docs/customize.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,3 +665,33 @@ By default, Voilà will attempt to resolve a kernel spec to the best fit, based
665665
```py
666666
c.VoilaConfiguration.attempt_fix_notebook = False
667667
```
668+
669+
## Changing dashboard rendering technique
670+
671+
There are two dashboard rendering techniques in Voilà:
672+
673+
- **Blocking rendering** (default): In this method, Voilà completes the execution of the entire notebook before displaying the dashboard. It is ideal for lightweight notebooks, as a loading spinner is shown until execution finishes..
674+
- **Progressive rendering** (introduced in Voilà 0.6): With this method, the dashboard appears immediately, with placeholders filling the cell outputs. These outputs are updated as each cell is executed by the kernel.
675+
676+
To start Voilà with progressive rendering mode using CLI:
677+
678+
```bash
679+
voila ... --progressive_rendering=True
680+
```
681+
682+
or using `voila.json` file
683+
684+
```python
685+
# voila.json
686+
{
687+
...
688+
"VoilaConfiguration": {
689+
"progressive_rendering": true,
690+
...
691+
}
692+
}
693+
```
694+
695+
:::{warning}
696+
Progressive rendering mode is incompatible with the preheated kernels functionality.
697+
:::

packages/voila/src/app.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { PageConfig } from '@jupyterlab/coreutils';
1010

1111
import { IRenderMime } from '@jupyterlab/rendermime';
1212

13-
import { KernelWidgetManager } from '@jupyter-widgets/jupyterlab-manager';
13+
import { VoilaWidgetManager } from './plugins/widget';
1414

1515
import { IShell, VoilaShell } from './shell';
1616

@@ -121,23 +121,23 @@ export class VoilaApp extends JupyterFrontEnd<IShell> {
121121
/**
122122
* A promise that resolves when the Voila Widget Manager is created
123123
*/
124-
get widgetManagerPromise(): PromiseDelegate<KernelWidgetManager> {
124+
get widgetManagerPromise(): PromiseDelegate<VoilaWidgetManager> {
125125
return this._widgetManagerPromise;
126126
}
127127

128-
set widgetManager(manager: KernelWidgetManager | null) {
128+
set widgetManager(manager: VoilaWidgetManager | null) {
129129
this._widgetManager = manager;
130130
if (this._widgetManager) {
131131
this._widgetManagerPromise.resolve(this._widgetManager);
132132
}
133133
}
134134

135-
get widgetManager(): KernelWidgetManager | null {
135+
get widgetManager(): VoilaWidgetManager | null {
136136
return this._widgetManager;
137137
}
138138

139-
protected _widgetManager: KernelWidgetManager | null = null;
140-
protected _widgetManagerPromise = new PromiseDelegate<KernelWidgetManager>();
139+
protected _widgetManager: VoilaWidgetManager | null = null;
140+
protected _widgetManagerPromise = new PromiseDelegate<VoilaWidgetManager>();
141141
}
142142

143143
/**

0 commit comments

Comments
 (0)