Skip to content

Commit

Permalink
JupyterLab 4 support (#1343)
Browse files Browse the repository at this point in the history
* Bump version

* Update dependencies

* Mock services

* Add setting handler

* Uses setting and theme handlers from jupyterlab-server

* Theme works in notebook page

* Support theme in tree page

* Bump ipywidgets deps

* extension option

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Filter federated extension with config

* Rename  to ,  to

* Move extension filtering logic to backend

* Move and rename files

* Update server extension

* Enable test debug

* Update UI tests

* Update CI

* Remove commented code

* Remove commented code

---------

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 committed Jul 6, 2023
1 parent 628a945 commit ea11d94
Show file tree
Hide file tree
Showing 50 changed files with 19,052 additions and 12,512 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

- name: Install Dependencies
run: |
python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.10
python -m pip install -U jupyterlab~=4.0 jupyter_packaging~=0.10 "notebook<7"
- name: Install the Voilà Preview JupyterLab extension
run: |
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

- name: Create the conda environment
shell: bash -l {0}
run: mamba install -q python=${{ matrix.python_version }} pip jupyterlab_pygments==0.1.0 pytest-cov pytest-rerunfailures nodejs=18 yarn=1 ipywidgets matplotlib xeus-cling "traitlets>=5.0.3,<6" ipykernel
run: mamba install -q python=${{ matrix.python_version }} pip jupyterlab_pygments==0.1.0 pytest-cov pytest-rerunfailures nodejs=18 yarn ipywidgets matplotlib xeus-cling "traitlets>=5.0.3,<6" ipykernel

- name: Install dependencies
shell: bash -l {0}
Expand All @@ -51,7 +51,9 @@ jobs:
- name: Run tests
shell: bash -l {0}
run: |
VOILA_TEST_XEUS_CLING=1 py.test tests/ --async-test-timeout=240 --reruns 2 --reruns-delay 1
VOILA_TEST_XEUS_CLING=1 py.test tests/app --async-test-timeout=240 --reruns 2 --reruns-delay 1
VOILA_TEST_XEUS_CLING=1 py.test tests/server --async-test-timeout=240 --reruns 2 --reruns-delay 1 --trace
py.test tests/execute_output_test.py
voila --help # Making sure we can run `voila --help`
# tests if voila sends a 'heartbeat' to avoid proxies from closing an apparently stale connection
# Note that wget is the only easily available software that has a read-timeout
Expand All @@ -68,7 +70,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-10.15]
os: [macos-12]
python_version: ['3.8', '3.9', '3.10']

steps:
Expand All @@ -82,28 +84,24 @@ jobs:

- name: Create the conda environment
shell: bash -l {0}
run: mamba install -q python=${{ matrix.python_version }} pip jupyterlab_pygments==0.1.0 pytest-cov pytest-rerunfailures nodejs=18 yarn=1 ipywidgets matplotlib xeus-cling "traitlets>=5.0.3,<6" ipykernel
run: mamba install -q python=${{ matrix.python_version }} pip jupyterlab_pygments==0.1.0 pytest-cov pytest-rerunfailures nodejs=18 yarn ipywidgets matplotlib xeus-cling "traitlets>=5.0.3,<6" ipykernel

- name: Install dependencies
shell: bash -l {0}
run: |
whereis python
python --version
yarn install --network-timeout 100000
python -m pip install ".[test]"
python -m pip install ".[test,dev]"
(cd tests/test_template; pip install .)
(cd tests/skip_template; pip install .)
- name: Run tests
shell: bash -l {0}
run: |
py.test tests/ --async-test-timeout=240 --reruns 2 --reruns-delay 1
voila --help # Making sure we can run `voila --help`
# tests if voila sends a 'heartbeat' to avoid proxies from closing an apparently stale connection
# Note that wget is the only easily available software that has a read-timeout
voila tests/notebooks/sleep10seconds.ipynb --port=8878 --VoilaConfiguration.http_keep_alive_timeout=2 &
sleep 2
wget --read-timeout=5 --tries=1 http://localhost:8878
py.test tests/app --async-test-timeout=240 --reruns 2 --reruns-delay 1
py.test tests/server --async-test-timeout=240 --reruns 2 --reruns-delay 1 --trace
py.test tests/execute_output_test.py
test-win:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -138,4 +136,6 @@ jobs:
- name: Run test
run: |
set VOILA_TEST_DEBUG=1
py.test tests/ --async-test-timeout=240 --reruns 2 --reruns-delay 1
py.test tests/app --async-test-timeout=240 --reruns 2 --reruns-delay 1
py.test tests/server --async-test-timeout=240 --reruns 2 --reruns-delay 1 --trace
py.test tests/execute_output_test.py
4 changes: 2 additions & 2 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- name: Install dependencies
run: |
python -m pip install setuptools jupyter_packaging~=0.10 "jupyterlab>=3,<4" build
python -m pip install setuptools jupyter_packaging~=0.10 "jupyterlab>=4,<5" build
- name: Build pypi distributions
run: |
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
path: ./dist
- name: Install the prerequisites
run: |
${{ matrix.py_cmd }} -m pip install pip wheel jupyterlab~=3.0 notebook~=6.4
${{ matrix.py_cmd }} -m pip install pip wheel "jupyterlab>=4.0.0,<5" notebook~=6.4
- name: Install the package
run: |
cd dist
Expand Down
36 changes: 3 additions & 33 deletions .github/workflows/ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install -r requirements-visual-test.txt
python -m pip install jupyterlab_miami_nights --no-deps
python -m pip install ".[test]"
jlpm
jlpm build
jupyter labextension develop . --overwrite
cd ui-tests
jlpm install --frozen-lockfile
jlpm install
- name: Launch Voila
run: |
Expand All @@ -34,7 +35,7 @@ jobs:
working-directory: ui-tests

- name: Install browser
run: jlpm playwright install chromium
run: npx playwright install chromium
working-directory: ui-tests

- name: Wait for Voila
Expand All @@ -47,37 +48,6 @@ jobs:
run: jlpm run test
working-directory: ui-tests

- uses: iterative/setup-cml@v1

- name: Publish Results
env:
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPORT: ./benchmark-results/voila-benchmark.md
shell: bash
run: |
cd ui-tests
# Publish image to cml.dev
echo "" >> ${REPORT}
cml-publish ./benchmark-results/voila-benchmark.png --md >> ${REPORT}
echo "" >> ${REPORT}
# Test if metadata have changed
export METADATA_DIFF="/tmp/metadata.diff"
diff -u <(jq --sort-keys .metadata benchmark-results/voila-benchmark.json) <(jq --sort-keys .metadata voila-benchmark-expected.json) > ${METADATA_DIFF} || true
if [[ -s ${METADATA_DIFF} ]]; then
echo "<details><summary>:exclamation: Test metadata have changed</summary>" >> ${REPORT}
echo "" >> ${REPORT}
echo "\`\`\`diff" >> ${REPORT}
cat ${METADATA_DIFF} >> ${REPORT}
echo "\`\`\`" >> ${REPORT}
echo "" >> ${REPORT}
echo "</details>" >> ${REPORT}
fi
# Save PR number for comment publication
echo "${{ github.event.number }}" > ./benchmark-results/NR
- name: Upload Playwright Test assets
if: always()
uses: actions/upload-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update_galata_references.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
jlpm build
jupyter labextension develop . --overwrite
cd ui-tests
jlpm install --frozen-lockfile
jlpm install
- uses: jupyterlab/maintainer-tools/.github/actions/update-snapshots@main
with:
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ config.rst
package-lock.json

share/jupyter/voila/templates/base/static/*voila.js
share/jupyter/voila/templates/base/static/*treepage.js
share/jupyter/voila/templates/base/static/*voila-style.js
share/jupyter/voila/templates/base/static/*.woff
share/jupyter/voila/templates/base/static/*.woff2
Expand All @@ -38,6 +39,8 @@ share/jupyter/voila/templates/base/static/*.svg
share/jupyter/voila/templates/base/static/*.ttf
share/jupyter/voila/templates/base/static/labvariables.css
share/jupyter/voila/templates/base/static/materialcolors.css
share/jupyter/voila/templates/base/static/*.LICENSE.txt


lib

Expand All @@ -48,3 +51,9 @@ ui-tests/playwright-report
ui-tests/test-results
ui-tests/benchmark-results
ui-tests/jlab_root

.yarn/

share/jupyter/voila/schemas
share/jupyter/voila/themes
share/jupyter/voila/style.js
3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enableImmutableInstalls: false

nodeLinker: node-modules
4 changes: 2 additions & 2 deletions docs/source/customize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ the following option:
voila <path-to-notebook> --theme=dark
Or by passing in the query parameter ``voila-theme``, e.g. a URL like ``http://localhost:8867/voila/render/query-strings.ipynb?voila-theme=dark``.
Or by passing in the query parameter ``theme``, e.g. a URL like ``http://localhost:8867/voila/render/query-strings.ipynb?theme=dark``.

The theme can also be set in the notebook metadata, under ``metadata/voila/theme`` by editing the notebook file manually, or using the metadata editor in for instance the classical notebook

Expand Down Expand Up @@ -73,7 +73,7 @@ For example, to use the `gridstack <https://github.com/voila-dashboards/voila-gr
voila <path-to-notebook> --template=gridstack
Or by passing in the query parameter ``voila-template``, e.g. a URL like ``http://localhost:8867/voila/render/query-strings.ipynb?voila-template=material`` (Note that this requires installing voila-material).
Or by passing in the query parameter ``template``, e.g. a URL like ``http://localhost:8867/voila/render/query-strings.ipynb?template=material`` (Note that this requires installing voila-material).

The template can also set in the notebook metadata, under ``metadata/voila/template`` by editing the notebook file manually, or using the metadata editor in for instance the classical notebook

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"clean": "lerna run clean",
"eslint": "eslint . --ext .ts,.tsx --fix",
"eslint:check": "eslint . --ext .ts,.tsx",
"install": "lerna bootstrap",
"prettier": "prettier --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"prettier:check": "prettier --list-different \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"test": "lerna run test"
Expand Down
37 changes: 19 additions & 18 deletions packages/jupyterlab-preview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,30 @@
"watch:src": "tsc -w"
},
"dependencies": {
"@jupyterlab/application": "^3.0.0",
"@jupyterlab/apputils": "^3.0.0",
"@jupyterlab/coreutils": "^5.0.0",
"@jupyterlab/docregistry": "^3.0.0",
"@jupyterlab/fileeditor": "^3.0.0",
"@jupyterlab/mainmenu": "^3.0.0",
"@jupyterlab/notebook": "^3.0.0",
"@jupyterlab/settingregistry": "^3.0.0",
"@jupyterlab/ui-components": "^3.0.0",
"@lumino/coreutils": "^1.5.3",
"@lumino/signaling": "^1.4.3",
"react": "^17.0.1",
"react-dom": "^17.0.1"
"@jupyterlab/application": "^4.0.0",
"@jupyterlab/apputils": "^4.0.0",
"@jupyterlab/coreutils": "^6.0.0",
"@jupyterlab/docregistry": "^4.0.0",
"@jupyterlab/fileeditor": "^4.0.0",
"@jupyterlab/mainmenu": "^4.0.0",
"@jupyterlab/notebook": "^4.0.0",
"@jupyterlab/settingregistry": "^4.0.0",
"@jupyterlab/ui-components": "^4.0.0",
"@lumino/coreutils": "^2.0.0",
"@lumino/signaling": "^2.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@babel/core": "^7.10.2",
"@babel/preset-env": "^7.10.2",
"@jupyterlab/builder": "^3.0.0",
"@jupyterlab/testutils": "^3.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@jupyterlab/builder": "^4.0.0",
"@jupyterlab/testutils": "^4.0.0",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"rimraf": "^2.6.1",
"typescript": "~4.1.3"
"source-map-loader": "~1.0.2",
"typescript": "~5.0.2"
},
"jupyterlab": {
"extension": true,
Expand Down
86 changes: 47 additions & 39 deletions packages/voila/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,52 @@
"main": "lib/index.js",
"browserslist": ">0.8%, not ie 11, not op_mini all, not dead",
"dependencies": {
"@jupyter-widgets/base": "^6.0.3",
"@jupyter-widgets/jupyterlab-manager": "^5.0.6",
"@jupyterlab/application": "^3.0.0",
"@jupyterlab/apputils": "^3.0.0",
"@jupyterlab/coreutils": "^5.0.0",
"@jupyterlab/docregistry": "^3.0.0",
"@jupyterlab/javascript-extension": "^3.5.0",
"@jupyterlab/json-extension": "^3.0.0",
"@jupyterlab/logconsole": "^3.0.0",
"@jupyterlab/mainmenu": "^3.0.0",
"@jupyterlab/markdownviewer-extension": "^3.5.0",
"@jupyterlab/mathjax2-extension": "^3.0.0",
"@jupyterlab/nbformat": "^3.0.0",
"@jupyterlab/notebook": "^3.0.0",
"@jupyterlab/outputarea": "^3.0.0",
"@jupyterlab/rendermime": "^3.0.0",
"@jupyterlab/rendermime-extension": "^3.0.0",
"@jupyterlab/services": "^6.1.8",
"@jupyterlab/settingregistry": "^3.0.0",
"@jupyterlab/translation": "^3.0.0",
"@jupyterlab/ui-components": "^3.0.0",
"@jupyterlab/vega5-extension": "^3.5.0",
"@lumino/algorithm": "^1.6.2",
"@lumino/commands": "^1.15.2",
"@lumino/coreutils": "^1.8.2",
"@lumino/disposable": "^1.7.2",
"@lumino/domutils": "^1.5.2",
"@lumino/dragdrop": "^1.10.2",
"@lumino/messaging": "^1.7.2",
"@lumino/properties": "^1.5.2",
"@lumino/signaling": "^1.7.2",
"@lumino/virtualdom": "^1.11.2",
"@lumino/widgets": "^1.26.2",
"react": "^17.0.1",
"react-dom": "^17.0.1"
"@jupyter-widgets/base": "^6.0.5",
"@jupyter-widgets/jupyterlab-manager": "^5.0.8",
"@jupyterlab/application": "^4.0.0",
"@jupyterlab/apputils": "^4.0.0",
"@jupyterlab/apputils-extension": "^4.0.0",
"@jupyterlab/codemirror-extension": "^4.0.0",
"@jupyterlab/coreutils": "^6.0.0",
"@jupyterlab/docregistry": "^4.0.0",
"@jupyterlab/javascript-extension": "^4.0.0",
"@jupyterlab/json-extension": "^4.0.0",
"@jupyterlab/logconsole": "^4.0.0",
"@jupyterlab/mainmenu": "^4.0.0",
"@jupyterlab/markdownviewer-extension": "^4.0.0",
"@jupyterlab/markedparser-extension": "^4.0.0",
"@jupyterlab/mathjax-extension": "^4.0.0",
"@jupyterlab/nbformat": "^4.0.0",
"@jupyterlab/notebook": "^4.0.0",
"@jupyterlab/outputarea": "^4.0.0",
"@jupyterlab/rendermime": "^4.0.0",
"@jupyterlab/rendermime-extension": "^4.0.0",
"@jupyterlab/services": "^7.0.0",
"@jupyterlab/settingregistry": "^4.0.0",
"@jupyterlab/theme-dark-extension": "^4.0.2",
"@jupyterlab/theme-light-extension": "^4.0.2",
"@jupyterlab/translation": "^4.0.0",
"@jupyterlab/ui-components": "^4.0.0",
"@jupyterlab/vega5-extension": "^4.0.0",
"@lumino/algorithm": "^2.0.0",
"@lumino/commands": "^2.0.0",
"@lumino/coreutils": "^2.0.0",
"@lumino/datagrid": "^2.1.2",
"@lumino/disposable": "^2.0.0",
"@lumino/domutils": "^2.0.0",
"@lumino/dragdrop": "^2.0.0",
"@lumino/messaging": "^2.0.0",
"@lumino/properties": "^2.0.0",
"@lumino/signaling": "^2.0.0",
"@lumino/virtualdom": "^2.0.0",
"@lumino/widgets": "^2.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.3.1",
"@jupyterlab/builder": "^3.0.0",
"@jupyterlab/builder": "^4.0.0",
"@types/node": "~18.8.3",
"babel-loader": "^8.0.5",
"css-loader": "^6.7.2",
Expand All @@ -61,7 +67,8 @@
"sass-loader": "^13.2.0",
"style-loader": "^2.0.0",
"svg-url-loader": "^7.1.1",
"typescript": "~4.1.3",
"tsc-watch": "^6.0.0",
"typescript": "~5.0.2",
"url-loader": "^4.1.1",
"watch": "^1.0.2",
"webpack": "^5.24.1",
Expand All @@ -74,10 +81,11 @@
"build": "npm run build:lib && webpack --mode=development",
"build:lib": "tsc",
"build:prod": "npm run build:lib && webpack --mode=production",
"clean": "jlpm run clean:lib && rimraf build",
"clean": "jlpm run clean:lib && jlpm run clean:asset && rimraf build",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
"clean:asset": "rimraf ../../share/jupyter/voila/schemas ../../share/jupyter/voila/themes ../../share/jupyter/voila/style.js",
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "npm-run-all -p watch:*",
"watch": "tsc-watch --onSuccess \"webpack --mode=development\"",
"watch:lib": "tsc -w",
"watch:bundle": "webpack --watch --mode=development"
}
Expand Down
3 changes: 3 additions & 0 deletions packages/voila/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ declare function __webpack_init_sharing__(arg: any);
declare var _JUPYTERLAB;
declare var __webpack_share_scopes__: any;
declare var jupyterapp: any;
declare var themeLoaded: boolean;
declare var cellLoaded: boolean;
declare function voila_finish();
Loading

0 comments on commit ea11d94

Please sign in to comment.