Skip to content

Commit d423ede

Browse files
Upgrade to JupyterLab 4 (#402)
* remove unused dependency * upgrade dependencies to JL4 * fix type errors * add dev-install script * update yarn.lock * bump JL version in build and workflows * pre-commit * fix lint * fix yarn.lock checksums * bump ts-jest to v29 * upgrade to jest 29, typescript 4.3.0 * pull in required JupyterLab 4 test configuration * upgrade to React 18 to be compatible w/ JL4 * fix Build/test-isolated job * bump @jupyterlab/galata to latest, regenerate yarn.lock * try not deleting node * hardcode labextension name to fix Build/test_isolated job * call playwright directly via node to fix Build/integration-tests * use new JL4 galata config * fix and simplify E2E tests * remove outdated snapshots * add test:update script * add workflow_dispatch trigger to choose workflow branch * use jlpm when updating E2E snapshots * Update Playwright Snapshots --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 73ee948 commit d423ede

30 files changed

+16513
-13568
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
2323

2424
- name: Install dependencies
25-
run: python -m pip install -U jupyterlab~=3.1
25+
run: python -m pip install -U jupyterlab~=4.0
2626

2727
- name: Lint the extension
2828
run: |
@@ -81,19 +81,12 @@ jobs:
8181
- name: Install and Test
8282
run: |
8383
set -eux
84-
# Remove NodeJS, twice to take care of system and locally installed node versions.
85-
sudo rm -rf $(which node)
86-
sudo rm -rf $(which node)
87-
88-
pip install "jupyterlab~=3.1" jupyter_scheduler*.whl
89-
90-
84+
pip install "jupyterlab~=4.0" jupyter_scheduler*.whl
9185
jupyter server extension list
9286
jupyter server extension list 2>&1 | grep -ie "jupyter_scheduler.*OK"
93-
9487
jupyter labextension list
9588
jupyter labextension list 2>&1 | grep -ie "@jupyterlab/scheduler.*OK"
96-
python -m jupyterlab.browser_check --no-chrome-test
89+
python -m jupyterlab.browser_check
9790
9891
integration-tests:
9992
name: Integration tests
@@ -118,7 +111,7 @@ jobs:
118111
- name: Install the extension
119112
run: |
120113
set -eux
121-
python -m pip install "jupyterlab~=3.1" jupyter_scheduler*.whl
114+
python -m pip install "jupyterlab~=4.0" jupyter_scheduler*.whl
122115
123116
- name: Install dependencies
124117
working-directory: ui-tests
@@ -134,13 +127,12 @@ jobs:
134127
key: ${{ runner.os }}-${{ hashFiles('ui-tests/yarn.lock') }}
135128

136129
- name: Install browser
137-
run: jlpm playwright install chromium
138130
working-directory: ui-tests
131+
run: jlpm install-chromium
139132

140133
- name: Execute integration tests
141134
working-directory: ui-tests
142-
run: |
143-
jlpm playwright test
135+
run: jlpm test
144136

145137
- name: Upload Playwright Test report
146138
if: always()

.github/workflows/update-integration-tests.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: Update Playwright Snapshots
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
number:
7+
description: 'PR number'
8+
required: true
59
issue_comment:
610
types: [created, edited]
711

@@ -10,10 +14,8 @@ permissions:
1014
pull-requests: write
1115

1216
jobs:
13-
14-
1517
update-snapshots:
16-
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'please update playwright snapshots') }}
18+
if: ${{ github.event.inputs || (github.event.issue.pull_request && contains(github.event.comment.body, 'please update playwright snapshots')) }}
1719
runs-on: ubuntu-latest
1820

1921
steps:
@@ -26,7 +28,7 @@ jobs:
2628
run: git config --global hub.protocol https
2729

2830
- name: Checkout the branch from the PR that triggered the job
29-
run: hub pr checkout ${{ github.event.issue.number }}
31+
run: hub pr checkout ${{ github.event.inputs.number || github.event.issue.number }}
3032
env:
3133
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3234

@@ -36,7 +38,7 @@ jobs:
3638
python_version: '3.11'
3739

3840
- name: Install dependencies
39-
run: python -m pip install -U jupyterlab~=3.1 jupyter-archive
41+
run: python -m pip install -U jupyterlab~=4.0
4042

4143
- name: Install extension
4244
run: |
@@ -50,3 +52,5 @@ jobs:
5052
# Playwright knows how to start JupyterLab server
5153
start_server_script: 'null'
5254
test_folder: ui-tests
55+
# use jlpm (not default yet)
56+
npm_client: jlpm

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,10 @@ dev/jobs
125125

126126
# jupyter releaser local checkout
127127
.jupyter_releaser_checkout
128+
129+
# Yarn 3 cache
130+
.yarn
131+
132+
# Jest coverage reports and a side effect
133+
coverage
134+
junit.xml

.yarnrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# these configuration fields are only read by yarn 3 (JL4+)
2+
nodeLinker: 'node-modules'
3+
enableImmutableInstalls: false

jest.config.js

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,28 @@
11
const jestJupyterLab = require('@jupyterlab/testutils/lib/jest-config');
22

33
const esModules = [
4+
'@codemirror',
5+
'@jupyter/ydoc',
46
'@jupyterlab/',
57
'lib0',
6-
'y\\-protocols',
7-
'y\\-websocket',
8+
'nanoid',
9+
'vscode-ws-jsonrpc',
10+
'y-protocols',
11+
'y-websocket',
812
'yjs'
913
].join('|');
1014

11-
const jlabConfig = jestJupyterLab(__dirname);
12-
13-
const {
14-
moduleFileExtensions,
15-
moduleNameMapper,
16-
preset,
17-
setupFilesAfterEnv,
18-
setupFiles,
19-
testPathIgnorePatterns,
20-
transform
21-
} = jlabConfig;
15+
const baseConfig = jestJupyterLab(__dirname);
2216

2317
module.exports = {
24-
moduleFileExtensions,
25-
moduleNameMapper,
26-
preset,
27-
setupFilesAfterEnv,
28-
setupFiles,
29-
testPathIgnorePatterns,
30-
transform,
18+
...baseConfig,
3119
automock: false,
32-
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/**/*.d.ts'],
33-
coverageDirectory: 'coverage',
20+
collectCoverageFrom: [
21+
'src/**/*.{ts,tsx}',
22+
'!src/**/*.d.ts',
23+
'!src/**/.ipynb_checkpoints/*'
24+
],
3425
coverageReporters: ['lcov', 'text'],
35-
globals: {
36-
'ts-jest': {
37-
tsconfig: 'tsconfig.json'
38-
}
39-
},
4026
testRegex: 'src/.*/.*.spec.ts[x]?$',
4127
transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`]
4228
};

jupyter_scheduler/__init__.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
"""Scheduling API for JupyterLab"""
2-
import json
3-
from pathlib import Path
4-
52
from ._version import __version__
63
from .extension import SchedulerApp
74

8-
HERE = Path(__file__).parent.resolve()
9-
10-
11-
with (HERE / "labextension" / "package.json").open() as fid:
12-
data = json.load(fid)
13-
145

156
def _jupyter_labextension_paths():
16-
return [{"src": "labextension", "dest": data["name"]}]
7+
return [{"src": "labextension", "dest": "@jupyterlab/scheduler"}]
178

189

1910
def _jupyter_server_extension_points():

package.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
3939
"clean:labextension": "rimraf jupyter_scheduler/labextension",
4040
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
41+
"dev-install": "pip install -e . && jupyter labextension develop . --overwrite && jupyter server extension enable jupyter_scheduler",
4142
"eslint": "jlpm eslint:check --fix",
4243
"eslint:check": "eslint . --cache --ext .ts,.tsx",
4344
"install:extension": "jlpm build",
@@ -56,40 +57,39 @@
5657
"dependencies": {
5758
"@emotion/react": "^11.10.4",
5859
"@emotion/styled": "^11.10.4",
59-
"@jupyterlab/application": "^3.4.1",
60-
"@jupyterlab/apputils": "^3.4.1",
61-
"@jupyterlab/coreutils": "^5.4.2",
62-
"@jupyterlab/docmanager-extension": "^3.4.2",
63-
"@jupyterlab/filebrowser": "^3.4.1",
64-
"@jupyterlab/launcher": "^3.4.4",
65-
"@jupyterlab/services": "^6.4.2",
66-
"@jupyterlab/translation": "^3.4.1",
67-
"@jupyterlab/ui-components": "^3.4.2",
68-
"@lumino/polling": "^1.9.0",
69-
"@lumino/signaling": "^1.10.0",
70-
"@lumino/coreutils": "^1.12.0",
71-
"@lumino/widgets": "^1.32.0",
60+
"@jupyterlab/application": "^4",
61+
"@jupyterlab/apputils": "^4",
62+
"@jupyterlab/coreutils": "^6",
63+
"@jupyterlab/filebrowser": "^4",
64+
"@jupyterlab/launcher": "^4",
65+
"@jupyterlab/services": "^7",
66+
"@jupyterlab/translation": "^4",
67+
"@jupyterlab/ui-components": "^4",
68+
"@lumino/coreutils": "^2",
69+
"@lumino/polling": "^2",
70+
"@lumino/signaling": "^2",
71+
"@lumino/widgets": "^2",
7272
"@mui/icons-material": "^5.10.9",
7373
"@mui/material": "^5.10.6",
7474
"@mui/system": "^5.10.6",
7575
"@types/react-dom": "^18.0.5",
7676
"cronstrue": "^2.12.0",
77-
"react": "^17.0.1",
78-
"react-dom": "^17.0.1",
77+
"react": "^18.2.0",
78+
"react-dom": "^18.2.0",
7979
"tzdata": "^1.0.33"
8080
},
8181
"devDependencies": {
8282
"@babel/core": "^7.0.0",
8383
"@babel/preset-env": "^7.0.0",
84-
"@jupyterlab/builder": "^3.4.7",
85-
"@jupyterlab/testutils": "^3.0.0",
86-
"@types/jest": "^26.0.0",
84+
"@jupyterlab/builder": "^4",
85+
"@jupyterlab/testutils": "^4",
86+
"@types/jest": "^29",
8787
"@typescript-eslint/eslint-plugin": "^4.8.1",
8888
"@typescript-eslint/parser": "^4.8.1",
8989
"eslint": "^7.14.0",
9090
"eslint-config-prettier": "^6.15.0",
9191
"eslint-plugin-prettier": "^3.1.4",
92-
"jest": "^26.0.0",
92+
"jest": "^29",
9393
"mkdirp": "^1.0.3",
9494
"npm-run-all": "^4.1.5",
9595
"prettier": "^2.1.1",
@@ -99,8 +99,8 @@
9999
"stylelint-config-recommended": "^6.0.0",
100100
"stylelint-config-standard": "~24.0.0",
101101
"stylelint-prettier": "^2.0.0",
102-
"ts-jest": "^26.0.0",
103-
"typescript": "~4.1.3"
102+
"ts-jest": "^29",
103+
"typescript": "~4.3.0"
104104
},
105105
"resolutions": {
106106
"@types/react": "^17.0.1",
@@ -132,7 +132,7 @@
132132
"jupyter-releaser": {
133133
"hooks": {
134134
"before-build-npm": [
135-
"python -m pip install jupyterlab~=3.1",
135+
"python -m pip install jupyterlab~=4.0",
136136
"jlpm",
137137
"jlpm build:prod"
138138
],

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["hatchling>=1.3.1", "jupyterlab~=3.1"]
2+
requires = ["hatchling>=1.3.1", "jupyterlab~=4.0"]
33
build-backend = "hatchling.build"
44

55
[project]

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function getSelectedItem(widget: FileBrowser | null): Contents.IModel | null {
7373
}
7474

7575
// Get the first selected item.
76-
const firstItem = widget.selectedItems().next();
76+
const firstItem = widget.selectedItems().next()?.value;
7777
if (firstItem === null || firstItem === undefined) {
7878
return null;
7979
}

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"noUnusedLocals": true,
1414
"preserveWatchOutput": true,
1515
"resolveJsonModule": true,
16+
"skipLibCheck": true,
1617
"outDir": "lib",
1718
"rootDir": "src",
1819
"strict": true,

0 commit comments

Comments
 (0)