Skip to content

Commit 97d5a2d

Browse files
fcollonvalkrassowskiHaudinFlorencebrichet
authored
Update master to JupyterLab 4 examples (#232)
* Upgrade example for JupyterLab 4 Switch to extension template (#229) Add notifications example (#230) Add an example package for the use of metadata-form (#208) Add codemirror extension example (#231) Co-authored-by: Frédéric Collonval <[email protected]> Co-authored-by: Florence Haudin <[email protected]> Co-authored-by: Nicolas Brichet <[email protected]> * Bump to final package version * Upgrade documents example * Update documents README * Update template * Make ICollaborativeDrive optional * Fix tests * Install browser for integration tests * Fix tests * Improve robustness for metadata form ui test Break documents test at browser_check * Fix documents packaging * Remove _version.py file * Yet another attempt to fix integration tests * Improve test robustness and some fixes * Update codemirror snapshot * Finally nail the culprit in metadata form test --------- Co-authored-by: Michał Krassowski <[email protected]> Co-authored-by: Florence Haudin <[email protected]> Co-authored-by: Nicolas Brichet <[email protected]>
1 parent 0ebd794 commit 97d5a2d

File tree

701 files changed

+16415
-9647
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

701 files changed

+16415
-9647
lines changed

.github/workflows/main.yml

+102-66
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,39 @@ on:
44
push:
55
branches: master
66
pull_request:
7-
branches: "*"
7+
branches: '*'
88

99
jobs:
1010
build_extensions:
1111
runs-on: ${{ matrix.os }}
12-
12+
1313
strategy:
1414
fail-fast: false
1515
matrix:
1616
example:
17-
- kernel-messaging
18-
- kernel-output
19-
- datagrid
20-
- documents
21-
- hello-world
22-
- signals
17+
- codemirror-extension
2318
- command-palette
2419
- commands
20+
- completer
21+
- contentheader
2522
- context-menu
26-
- launcher
2723
- custom-log-console
24+
- datagrid
25+
- documents
26+
- hello-world
27+
- launcher
28+
- kernel-messaging
29+
- kernel-output
2830
- log-messages
2931
- main-menu
32+
- metadata-form
33+
- notifications
3034
- react-widget
3135
- settings
36+
- signals
3237
- state
3338
- toolbar-button
3439
- widgets
35-
- completer
36-
- contentheader
3740
os: [ubuntu-latest, macos-latest, windows-latest]
3841

3942
defaults:
@@ -63,24 +66,23 @@ jobs:
6366
- name: Check config files
6467
if: steps.filter.outputs.extension == 'true'
6568
run: |
69+
diff ../hello-world/setup.py setup.py
6670
diff ../hello-world/tsconfig.json tsconfig.json
67-
diff ../hello-world/.eslintignore .eslintignore
68-
diff ../hello-world/.eslintrc.js .eslintrc.js
69-
diff ../hello-world/.gitignore .gitignore
70-
diff ../hello-world/ui-tests/playwright.config.ts ./ui-tests/playwright.config.ts
71-
diff ../hello-world/ui-tests/README.md ./ui-tests/README.md
71+
diff ../hello-world/.yarnrc.yml .yarnrc.yml
72+
diff ../hello-world/ui-tests/jupyter_server_test_config.py ./ui-tests/jupyter_server_test_config.py
73+
diff ../hello-world/ui-tests/playwright.config.js ./ui-tests/playwright.config.js
7274
shell: bash
7375
- name: Install node
7476
if: steps.filter.outputs.extension == 'true'
7577
uses: actions/setup-node@v3
7678
with:
77-
node-version: "18.x"
79+
node-version: '18.x'
7880
- name: Install Python
7981
if: steps.filter.outputs.extension == 'true'
8082
uses: actions/setup-python@v4
8183
with:
82-
python-version: "3.11"
83-
architecture: "x64"
84+
python-version: '3.11'
85+
architecture: 'x64'
8486
- name: Get pip cache dir
8587
if: steps.filter.outputs.extension == 'true'
8688
id: pip-cache
@@ -92,13 +94,18 @@ jobs:
9294
uses: actions/cache@v3
9395
with:
9496
path: ${{ steps.pip-cache.outputs.dir }}
95-
key: ${{ runner.os }}-pip-${{ hashFiles('**/environment.yml') }}
97+
key: ${{ runner.os }}-pip-${{ hashFiles('environment.yml') }}
9698
restore-keys: |
9799
${{ runner.os }}-pip-
98100
- name: Install the Python dependencies
99101
if: steps.filter.outputs.extension == 'true'
100102
run: |
101-
python -m pip install --upgrade pip jupyter_packaging~=0.10 jupyterlab~=3.1
103+
python -m pip install --upgrade pip "jupyterlab>=4.0.0"
104+
# This is challenging to test in collaboration;
105+
# got trouble with the file ID service and the uncontrolled auto-save
106+
# - if: steps.filter.outputs.extension == 'true' && matrix.example == 'documents'
107+
# run: |
108+
# python -m pip install jupyter-collaboration
102109
- name: Install the NPM dependencies
103110
if: steps.filter.outputs.extension == 'true'
104111
run: jlpm
@@ -111,30 +118,47 @@ jobs:
111118
pip install . -v
112119
jupyter labextension list 2>&1 | tee labextension.list
113120
cat labextension.list | grep -ie "@jupyterlab-examples/*.*OK"
121+
# There is a JavaScript warning as jupyter-collaboration is not
122+
# installed. And therefore @jupyter/docprovider is not available.
114123
python -m jupyterlab.browser_check
115-
pip uninstall -y $(python setup.py --name)
116124
shell: bash
117125

126+
- name: Install galata
127+
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux')
128+
working-directory: ${{ matrix.example }}/ui-tests
129+
env:
130+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
131+
run: jlpm install
132+
- name: Set up browser cache
133+
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux')
134+
uses: actions/cache@v3
135+
with:
136+
path: |
137+
${{ github.workspace }}/pw-browsers
138+
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
139+
- name: Install browser
140+
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux')
141+
run: jlpm playwright install chromium
142+
working-directory: ${{ matrix.example }}/ui-tests
143+
- name: Install kernel-output dependencies
144+
if: steps.filter.outputs.extension == 'true' && matrix.example == 'kernel-output'
145+
run: pip install numpy pandas
118146
- name: Integration tests
119147
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux')
120-
run: |
121-
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env down || true
122-
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env pull -q || true
123-
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env build
124-
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env run --rm e2e
148+
working-directory: ${{ matrix.example }}/ui-tests
149+
run: jlpm playwright test
125150
- name: Upload UI Test artifacts
126151
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux') && always()
127152
uses: actions/upload-artifact@v3
128153
with:
129154
name: ui-test-output
130155
path: |
131156
${{ matrix.example }}/ui-tests/test-results
132-
- name: Stop containers
133-
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux') && always()
157+
- name: Uninstall extension
158+
if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') )
134159
run: |
135-
# Print jupyterlab logs before removing the containers using the container name set in docker-compose file
136-
docker logs jupyterlab
137-
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env down
160+
export NAME=`python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['name'])"`
161+
pip uninstall -y ${NAME}
138162
139163
build_serverextension:
140164
runs-on: ${{ matrix.os }}
@@ -166,22 +190,22 @@ jobs:
166190
if: steps.filter.outputs.extension == 'true'
167191
uses: actions/setup-node@v3
168192
with:
169-
node-version: "18.x"
193+
node-version: '18.x'
170194
- name: Check config files
171195
if: steps.filter.outputs.extension == 'true'
172196
run: |
197+
diff hello-world/setup.py server-extension/setup.py
173198
diff hello-world/tsconfig.json server-extension/tsconfig.json
174-
diff hello-world/.eslintignore server-extension/.eslintignore
175-
diff hello-world/.eslintrc.js server-extension/.eslintrc.js
176-
diff hello-world/ui-tests/playwright.config.ts server-extension/ui-tests/playwright.config.ts
177-
diff hello-world/ui-tests/README.md server-extension/ui-tests/README.md
199+
diff hello-world/.yarnrc.yml server-extension/.yarnrc.yml
200+
diff hello-world/ui-tests/jupyter_server_test_config.py server-extension/ui-tests/jupyter_server_test_config.py
201+
diff hello-world/ui-tests/playwright.config.js server-extension/ui-tests/playwright.config.js
178202
shell: bash
179203
- name: Install Python
180204
if: steps.filter.outputs.extension == 'true'
181205
uses: actions/setup-python@v4
182206
with:
183-
python-version: "3.11"
184-
architecture: "x64"
207+
python-version: '3.11'
208+
architecture: 'x64'
185209
- name: Get pip cache dir
186210
if: steps.filter.outputs.extension == 'true'
187211
id: pip-cache
@@ -193,13 +217,13 @@ jobs:
193217
uses: actions/cache@v3
194218
with:
195219
path: ${{ steps.pip-cache.outputs.dir }}
196-
key: ${{ runner.os }}-pip-${{ hashFiles('**/environment.yml') }}
220+
key: ${{ runner.os }}-pip-${{ hashFiles('environment.yml') }}
197221
restore-keys: |
198222
${{ runner.os }}-pip-
199223
- name: Install the Python dependencies
200224
if: steps.filter.outputs.extension == 'true'
201225
run: |
202-
python -m pip install --upgrade pip jupyter_packaging~=0.10 jupyterlab~=3.1
226+
python -m pip install --upgrade pip jupyterlab~=4.0.0 build twine hatch
203227
- name: Install the NPM dependencies
204228
if: steps.filter.outputs.extension == 'true'
205229
run: |
@@ -215,20 +239,20 @@ jobs:
215239
# Force the usage of the source distribution (good practice)
216240
run: |
217241
cd server-extension
218-
python setup.py sdist
219-
pip install ./dist/jlab_ext_example* --pre --find-links=dist --no-cache-dir
242+
python -m build --sdist
243+
pip install ./dist/jupyterlab_examples_server* --pre --find-links=dist --no-cache-dir
220244
python -m jupyterlab.browser_check
221245
- name: Check extension as dev
222246
if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') )
223247
run: |
224248
jupyter server extension list 2>&1 | tee serverextension.list
225-
cat serverextension.list | grep -ie "jlab_ext_example.*OK"
249+
cat serverextension.list | grep -ie "jupyterlab_examples_server.*OK"
226250
jupyter labextension list 2>&1 | tee labextension.list
227251
cat labextension.list | grep -ie "@jupyterlab-examples/server-extension.*OK"
228252
- name: Clean extension installation
229253
if: steps.filter.outputs.extension == 'true'
230254
run: |
231-
pip uninstall -y jlab_ext_example
255+
pip uninstall -y jupyterlab_examples_server
232256
jupyter lab clean
233257
jupyter server extension list
234258
jupyter labextension list
@@ -241,33 +265,44 @@ jobs:
241265
if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') )
242266
run: |
243267
jupyter server extension list 2>&1 | tee serverextension.list
244-
cat serverextension.list | grep -ie "jlab_ext_example.*OK"
268+
cat serverextension.list | grep -ie "jupyterlab_examples_server.*OK"
245269
jupyter labextension list 2>&1 | tee labextension.list
246270
cat labextension.list | grep -ie "@jupyterlab-examples/server-extension.*OK"
247271
python -m jupyterlab.browser_check
248272
273+
- name: Install galata
274+
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux')
275+
working-directory: server-extension/ui-tests
276+
env:
277+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
278+
run: jlpm install
279+
- name: Set up browser cache
280+
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux')
281+
uses: actions/cache@v3
282+
with:
283+
path: |
284+
${{ github.workspace }}/pw-browsers
285+
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
286+
- name: Install browser
287+
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux')
288+
run: jlpm playwright install chromium
289+
working-directory: server-extension/ui-tests
249290
- name: Integration tests
250291
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux')
251-
run: |
252-
cd server-extension
253-
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env down || true
254-
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env pull -q || true
255-
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env build
256-
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env run --rm e2e
292+
working-directory: server-extension/ui-tests
293+
run: jlpm playwright test
257294
- name: Upload UI Test artifacts
258295
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux') && always()
259296
uses: actions/upload-artifact@v3
260297
with:
261298
name: ui-test-output
262299
path: |
263300
server-extension/ui-tests/test-results
264-
- name: Stop containers
265-
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux') && always()
301+
- name: Uninstall extension
302+
if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') )
266303
run: |
267-
cd server-extension
268-
# Print jupyterlab logs before removing the containers using the container name set in docker-compose file
269-
docker logs jupyterlab
270-
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env down
304+
export NAME=`python -c "import tomllib; print(tomllib.load(open('server-extension/pyproject.toml', 'rb'))['project']['name'])"`
305+
pip uninstall -y ${NAME}
271306
272307
build_all:
273308
runs-on: ${{ matrix.os }}
@@ -290,12 +325,12 @@ jobs:
290325
- name: Install node
291326
uses: actions/setup-node@v3
292327
with:
293-
node-version: "18.x"
328+
node-version: '18.x'
294329
- name: Install Python
295330
uses: actions/setup-python@v4
296331
with:
297-
python-version: "3.11"
298-
architecture: "x64"
332+
python-version: '3.11'
333+
architecture: 'x64'
299334
- name: Get pip cache dir
300335
id: pip-cache
301336
run: |
@@ -305,17 +340,18 @@ jobs:
305340
uses: actions/cache@v3
306341
with:
307342
path: ${{ steps.pip-cache.outputs.dir }}
308-
key: ${{ runner.os }}-pip-${{ hashFiles('**/environment.yml') }}
343+
key: ${{ runner.os }}-pip-${{ hashFiles('environment.yml') }}
309344
restore-keys: |
310345
${{ runner.os }}-pip-
311346
- name: Install the Python dependencies
312-
run: python -m pip install jupyter_packaging~=0.10 jupyterlab~=3.1 pytest pytest-check-links
347+
run: python -m pip install jupyterlab~=4.0.0 pytest pytest-check-links "pytest-jupyter[server]>=0.6.0"
313348
- name: Bootstrap the jlpm deps
314349
run: jlpm
315350
- name: Build all the extensions
316351
run: |
317352
jlpm lint:check
318-
jlpm build-ext
319-
jlpm install-ext
353+
lerna exec --concurrency 4 -- "touch yarn.lock"
354+
# Needed to generate the _version.py files
355+
jlpm run lerna exec --concurrency 4 -- "pip install -e ."
320356
# Check links as last step as new tutorial may set links not yet valid (like file not yet in master)
321-
pytest --check-links
357+
jlpm run lerna exec --concurrency 4 -- "pytest --check-links"

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ node_modules/
77
*.tsbuildinfo
88
*.lock
99
__pycache__
10+
.yarn/
1011

1112
# Ensure embedme does not run ont node_modules README.md files.
1213
**/node_modules/**/README.md
1314

1415
static
1516
labextension
1617
**/test-results/
18+
_version.py
1719

20+
.jupyter_ystore.db

.prettierrc

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"singleQuote": true
2+
"singleQuote": true,
3+
"trailingComma": "none",
4+
"arrowParens": "avoid",
5+
"endOfLine": "auto"
36
}

.yarnrc.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
enableImmutableInstalls: false
2+
3+
nodeLinker: node-modules

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2020, Project Jupyter Contributors.
3+
Copyright (c) 2020-2023, Project Jupyter Contributors.
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

0 commit comments

Comments
 (0)