Skip to content

Commit

Permalink
Upgrade to JupyterLab 4 (jupyter-server#402)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
dlqqq and github-actions[bot] authored Jul 26, 2023
1 parent 73ee948 commit d423ede
Show file tree
Hide file tree
Showing 30 changed files with 16,513 additions and 13,568 deletions.
20 changes: 6 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

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

- name: Lint the extension
run: |
Expand Down Expand Up @@ -81,19 +81,12 @@ jobs:
- name: Install and Test
run: |
set -eux
# Remove NodeJS, twice to take care of system and locally installed node versions.
sudo rm -rf $(which node)
sudo rm -rf $(which node)
pip install "jupyterlab~=3.1" jupyter_scheduler*.whl
pip install "jupyterlab~=4.0" jupyter_scheduler*.whl
jupyter server extension list
jupyter server extension list 2>&1 | grep -ie "jupyter_scheduler.*OK"
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "@jupyterlab/scheduler.*OK"
python -m jupyterlab.browser_check --no-chrome-test
python -m jupyterlab.browser_check
integration-tests:
name: Integration tests
Expand All @@ -118,7 +111,7 @@ jobs:
- name: Install the extension
run: |
set -eux
python -m pip install "jupyterlab~=3.1" jupyter_scheduler*.whl
python -m pip install "jupyterlab~=4.0" jupyter_scheduler*.whl
- name: Install dependencies
working-directory: ui-tests
Expand All @@ -134,13 +127,12 @@ jobs:
key: ${{ runner.os }}-${{ hashFiles('ui-tests/yarn.lock') }}

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

- name: Execute integration tests
working-directory: ui-tests
run: |
jlpm playwright test
run: jlpm test

- name: Upload Playwright Test report
if: always()
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/update-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Update Playwright Snapshots

on:
workflow_dispatch:
inputs:
number:
description: 'PR number'
required: true
issue_comment:
types: [created, edited]

Expand All @@ -10,10 +14,8 @@ permissions:
pull-requests: write

jobs:


update-snapshots:
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'please update playwright snapshots') }}
if: ${{ github.event.inputs || (github.event.issue.pull_request && contains(github.event.comment.body, 'please update playwright snapshots')) }}
runs-on: ubuntu-latest

steps:
Expand All @@ -26,7 +28,7 @@ jobs:
run: git config --global hub.protocol https

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

Expand All @@ -36,7 +38,7 @@ jobs:
python_version: '3.11'

- name: Install dependencies
run: python -m pip install -U jupyterlab~=3.1 jupyter-archive
run: python -m pip install -U jupyterlab~=4.0

- name: Install extension
run: |
Expand All @@ -50,3 +52,5 @@ jobs:
# Playwright knows how to start JupyterLab server
start_server_script: 'null'
test_folder: ui-tests
# use jlpm (not default yet)
npm_client: jlpm
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,10 @@ dev/jobs

# jupyter releaser local checkout
.jupyter_releaser_checkout

# Yarn 3 cache
.yarn

# Jest coverage reports and a side effect
coverage
junit.xml
3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# these configuration fields are only read by yarn 3 (JL4+)
nodeLinker: 'node-modules'
enableImmutableInstalls: false
40 changes: 13 additions & 27 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,28 @@
const jestJupyterLab = require('@jupyterlab/testutils/lib/jest-config');

const esModules = [
'@codemirror',
'@jupyter/ydoc',
'@jupyterlab/',
'lib0',
'y\\-protocols',
'y\\-websocket',
'nanoid',
'vscode-ws-jsonrpc',
'y-protocols',
'y-websocket',
'yjs'
].join('|');

const jlabConfig = jestJupyterLab(__dirname);

const {
moduleFileExtensions,
moduleNameMapper,
preset,
setupFilesAfterEnv,
setupFiles,
testPathIgnorePatterns,
transform
} = jlabConfig;
const baseConfig = jestJupyterLab(__dirname);

module.exports = {
moduleFileExtensions,
moduleNameMapper,
preset,
setupFilesAfterEnv,
setupFiles,
testPathIgnorePatterns,
transform,
...baseConfig,
automock: false,
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/**/*.d.ts'],
coverageDirectory: 'coverage',
collectCoverageFrom: [
'src/**/*.{ts,tsx}',
'!src/**/*.d.ts',
'!src/**/.ipynb_checkpoints/*'
],
coverageReporters: ['lcov', 'text'],
globals: {
'ts-jest': {
tsconfig: 'tsconfig.json'
}
},
testRegex: 'src/.*/.*.spec.ts[x]?$',
transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`]
};
11 changes: 1 addition & 10 deletions jupyter_scheduler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
"""Scheduling API for JupyterLab"""
import json
from pathlib import Path

from ._version import __version__
from .extension import SchedulerApp

HERE = Path(__file__).parent.resolve()


with (HERE / "labextension" / "package.json").open() as fid:
data = json.load(fid)


def _jupyter_labextension_paths():
return [{"src": "labextension", "dest": data["name"]}]
return [{"src": "labextension", "dest": "@jupyterlab/scheduler"}]


def _jupyter_server_extension_points():
Expand Down
44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf jupyter_scheduler/labextension",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"dev-install": "pip install -e . && jupyter labextension develop . --overwrite && jupyter server extension enable jupyter_scheduler",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand All @@ -56,40 +57,39 @@
"dependencies": {
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"@jupyterlab/application": "^3.4.1",
"@jupyterlab/apputils": "^3.4.1",
"@jupyterlab/coreutils": "^5.4.2",
"@jupyterlab/docmanager-extension": "^3.4.2",
"@jupyterlab/filebrowser": "^3.4.1",
"@jupyterlab/launcher": "^3.4.4",
"@jupyterlab/services": "^6.4.2",
"@jupyterlab/translation": "^3.4.1",
"@jupyterlab/ui-components": "^3.4.2",
"@lumino/polling": "^1.9.0",
"@lumino/signaling": "^1.10.0",
"@lumino/coreutils": "^1.12.0",
"@lumino/widgets": "^1.32.0",
"@jupyterlab/application": "^4",
"@jupyterlab/apputils": "^4",
"@jupyterlab/coreutils": "^6",
"@jupyterlab/filebrowser": "^4",
"@jupyterlab/launcher": "^4",
"@jupyterlab/services": "^7",
"@jupyterlab/translation": "^4",
"@jupyterlab/ui-components": "^4",
"@lumino/coreutils": "^2",
"@lumino/polling": "^2",
"@lumino/signaling": "^2",
"@lumino/widgets": "^2",
"@mui/icons-material": "^5.10.9",
"@mui/material": "^5.10.6",
"@mui/system": "^5.10.6",
"@types/react-dom": "^18.0.5",
"cronstrue": "^2.12.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tzdata": "^1.0.33"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@jupyterlab/builder": "^3.4.7",
"@jupyterlab/testutils": "^3.0.0",
"@types/jest": "^26.0.0",
"@jupyterlab/builder": "^4",
"@jupyterlab/testutils": "^4",
"@types/jest": "^29",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
"eslint": "^7.14.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-prettier": "^3.1.4",
"jest": "^26.0.0",
"jest": "^29",
"mkdirp": "^1.0.3",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.1",
Expand All @@ -99,8 +99,8 @@
"stylelint-config-recommended": "^6.0.0",
"stylelint-config-standard": "~24.0.0",
"stylelint-prettier": "^2.0.0",
"ts-jest": "^26.0.0",
"typescript": "~4.1.3"
"ts-jest": "^29",
"typescript": "~4.3.0"
},
"resolutions": {
"@types/react": "^17.0.1",
Expand Down Expand Up @@ -132,7 +132,7 @@
"jupyter-releaser": {
"hooks": {
"before-build-npm": [
"python -m pip install jupyterlab~=3.1",
"python -m pip install jupyterlab~=4.0",
"jlpm",
"jlpm build:prod"
],
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["hatchling>=1.3.1", "jupyterlab~=3.1"]
requires = ["hatchling>=1.3.1", "jupyterlab~=4.0"]
build-backend = "hatchling.build"

[project]
Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function getSelectedItem(widget: FileBrowser | null): Contents.IModel | null {
}

// Get the first selected item.
const firstItem = widget.selectedItems().next();
const firstItem = widget.selectedItems().next()?.value;
if (firstItem === null || firstItem === undefined) {
return null;
}
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"noUnusedLocals": true,
"preserveWatchOutput": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"outDir": "lib",
"rootDir": "src",
"strict": true,
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./tsconfig"
}
3 changes: 3 additions & 0 deletions ui-tests/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# these configuration fields are only read by yarn 3 (JL4+)
nodeLinker: 'node-modules'
enableImmutableInstalls: false
Loading

0 comments on commit d423ede

Please sign in to comment.