Skip to content

Commit

Permalink
Support progressive rendering (#1489)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Oct 15, 2024
1 parent f1722f4 commit f8dd6a5
Show file tree
Hide file tree
Showing 38 changed files with 1,993 additions and 856 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
version_spec: next

- name: Upload Distributions
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: voila-releaser-dist-${{ github.run_number }}
path: .jupyter_releaser_checkout/dist
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos]
os: [macos-12]
python_version: ['3.8', '3.9', '3.10', '3.11']

steps:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,36 @@ jobs:
sha256sum * | tee SHA256SUMS
- name: Upload distributions
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dist ${{ github.run_number }}
path: ./dist

install:
runs-on: ${{ matrix.os }}-latest
runs-on: ${{ matrix.os }}
needs: [build]
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
os: [ubuntu-latest, macos-12, windows-latest]
python: ['3.8', '3.10']
include:
- python: '3.8'
dist: 'voila*.tar.gz'
- python: '3.10'
dist: 'voila*.whl'
- os: windows
- os: windows-latest
py_cmd: python
- os: macos
- os: macos-12
py_cmd: python3
- os: ubuntu
- os: ubuntu-latest
py_cmd: python
steps:
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: dist ${{ github.run_number }}
path: ./dist
Expand Down
36 changes: 28 additions & 8 deletions .github/workflows/ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
jupyter-server-version: ["1.24.0", "2.14.2"]
jupyter-server-version: ['1.24.0', '2.14.2']
progressive_rendering: [false, true]
exclude:
- jupyter-server-version: '1.24.0'
progressive_rendering: true
fail-fast: false

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

- name: Install browser
Expand All @@ -49,30 +53,46 @@ jobs:
timeout: 360000

- name: Test
env:
PROGRESSIVE_RENDERING: ${{ matrix.progressive_rendering }}
run: jlpm run test
working-directory: ui-tests

- name: Set test report name for progressive rendering
if: always() && matrix.progressive_rendering == true
run: |
echo "TEST_REPORT_NAME=progressive-voila-test-report-${{ matrix.jupyter-server-version }}" >> $GITHUB_ENV
echo "TEST_ASSETS_NAME=progressive-voila-test-assets-${{ matrix.jupyter-server-version }}" >> $GITHUB_ENV
echo "TEST_BENCHMARK_NAME=progressive-voila-test-benchmark-${{ matrix.jupyter-server-version }}" >> $GITHUB_ENV
- name: Set test report name for non-progressive rendering
if: always() && matrix.progressive_rendering == false
run: |
echo "TEST_REPORT_NAME=voila-test-report-${{ matrix.jupyter-server-version }}" >> $GITHUB_ENV
echo "TEST_ASSETS_NAME=voila-test-assets-${{ matrix.jupyter-server-version }}" >> $GITHUB_ENV
echo "TEST_BENCHMARK_NAME=voila-test-benchmark-${{ matrix.jupyter-server-version }}" >> $GITHUB_ENV
- name: Upload Playwright Test assets
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: voila-test-assets
name: ${{ env.TEST_ASSETS_NAME }}
path: |
ui-tests/test-results
- name: Upload Playwright Benchmark report
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: voila-benchmark-report
name: ${{ env.TEST_BENCHMARK_NAME }}
path: |
ui-tests/benchmark-results
- name: Upload Playwright Test report
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: voila-test-report
name: ${{ env.TEST_REPORT_NAME }}
path: |
ui-tests/playwright-report
Expand Down
59 changes: 50 additions & 9 deletions .github/workflows/update_galata_references.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,70 @@ defaults:
jobs:
update-reference-screenshots:
name: Update Galata References
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'update galata references') }}
if: >
(
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'COLLABORATOR' ||
github.event.comment.author_association == 'MEMBER'
) && github.event.issue.pull_request && contains(github.event.comment.body, 'please update snapshots')
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
node-version: [16.x]
python-version: [3.10]
node-version: [18.x]

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

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Configure git to use https
run: git config --global hub.protocol https
- name: Get PR Info
id: pr
env:
PR_NUMBER: ${{ github.event.issue.number }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
COMMENT_AT: ${{ github.event.comment.created_at }}
run: |
pr="$(gh api /repos/${GH_REPO}/pulls/${PR_NUMBER})"
head_sha="$(echo "$pr" | jq -r .head.sha)"
pushed_at="$(echo "$pr" | jq -r .pushed_at)"
if [[ $(date -d "$pushed_at" +%s) -gt $(date -d "$COMMENT_AT" +%s) ]]; then
echo "Updating is not allowed because the PR was pushed to (at $pushed_at) after the triggering comment was issued (at $COMMENT_AT)"
exit 1
fi
echo "head_sha=$head_sha" >> $GITHUB_OUTPUT
- name: Checkout the branch from the PR that triggered the job
run: hub pr checkout ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr checkout ${{ github.event.issue.number }}

- name: Validate the fetched branch HEAD revision
env:
EXPECTED_SHA: ${{ steps.pr.outputs.head_sha }}
run: |
actual_sha="$(git rev-parse HEAD)"
if [[ "$actual_sha" != "$EXPECTED_SHA" ]]; then
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)"
exit 1
fi
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Configure git to use https
run: git config --global hub.protocol https

- name: Install dependencies
run: |
Expand Down
30 changes: 30 additions & 0 deletions docs/customize.md
Original file line number Diff line number Diff line change
Expand Up @@ -665,3 +665,33 @@ By default, Voilà will attempt to resolve a kernel spec to the best fit, based
```py
c.VoilaConfiguration.attempt_fix_notebook = False
```

## Changing dashboard rendering technique

There are two dashboard rendering techniques in Voilà:

- **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..
- **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.

To start Voilà with progressive rendering mode using CLI:

```bash
voila ... --progressive_rendering=True
```

or using `voila.json` file

```python
# voila.json
{
...
"VoilaConfiguration": {
"progressive_rendering": true,
...
}
}
```

:::{warning}
Progressive rendering mode is incompatible with the preheated kernels functionality.
:::
12 changes: 6 additions & 6 deletions packages/voila/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { PageConfig } from '@jupyterlab/coreutils';

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

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

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

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

set widgetManager(manager: KernelWidgetManager | null) {
set widgetManager(manager: VoilaWidgetManager | null) {
this._widgetManager = manager;
if (this._widgetManager) {
this._widgetManagerPromise.resolve(this._widgetManager);
}
}

get widgetManager(): KernelWidgetManager | null {
get widgetManager(): VoilaWidgetManager | null {
return this._widgetManager;
}

protected _widgetManager: KernelWidgetManager | null = null;
protected _widgetManagerPromise = new PromiseDelegate<KernelWidgetManager>();
protected _widgetManager: VoilaWidgetManager | null = null;
protected _widgetManagerPromise = new PromiseDelegate<VoilaWidgetManager>();
}

/**
Expand Down
Loading

0 comments on commit f8dd6a5

Please sign in to comment.