Skip to content

Commit

Permalink
Upgrade example for JupyterLab 4
Browse files Browse the repository at this point in the history
Co-authored-by: Florence Haudin <[email protected]>
Co-authored-by: Nicolas Brichet <[email protected]>
  • Loading branch information
3 people committed Apr 17, 2023
1 parent 4ef3dd5 commit e316912
Show file tree
Hide file tree
Showing 682 changed files with 9,869 additions and 7,423 deletions.
76 changes: 39 additions & 37 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
build_extensions:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -67,8 +67,7 @@ jobs:
diff ../hello-world/.eslintignore .eslintignore
diff ../hello-world/.eslintrc.js .eslintrc.js
diff ../hello-world/.gitignore .gitignore
diff ../hello-world/ui-tests/playwright.config.ts ./ui-tests/playwright.config.ts
diff ../hello-world/ui-tests/README.md ./ui-tests/README.md
diff ../hello-world/ui-tests/playwright.config.js ./ui-tests/playwright.config.js
shell: bash
- name: Install node
if: steps.filter.outputs.extension == 'true'
Expand Down Expand Up @@ -98,7 +97,7 @@ jobs:
- name: Install the Python dependencies
if: steps.filter.outputs.extension == 'true'
run: |
python -m pip install --upgrade pip jupyter_packaging~=0.10 jupyterlab~=3.1
python -m pip install --upgrade pip "jupyterlab>=4.0.0.b0"
- name: Install the NPM dependencies
if: steps.filter.outputs.extension == 'true'
run: jlpm
Expand All @@ -112,29 +111,33 @@ jobs:
jupyter labextension list 2>&1 | tee labextension.list
cat labextension.list | grep -ie "@jupyterlab-examples/*.*OK"
python -m jupyterlab.browser_check
pip uninstall -y $(python setup.py --name)
shell: bash

- name: Install galata
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux')
working-directory: ${{ matrix.example }}/ui-tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: jlpm install
- name: Install kernel-output dependencies
if: steps.filter.outputs.extension == 'true' && ${{ matrix.example }} == 'kernel-output'
run: pip install numpy pandas
- name: Integration tests
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux')
run: |
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env down || true
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env pull -q || true
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env build
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env run --rm e2e
working-directory: ${{ matrix.example }}/ui-tests
run: jlpm playwright test
- name: Upload UI Test artifacts
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux') && always()
uses: actions/upload-artifact@v3
with:
name: ui-test-output
path: |
${{ matrix.example }}/ui-tests/test-results
- name: Stop containers
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux') && always()
- name: Uninstall extension
if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') )
run: |
# Print jupyterlab logs before removing the containers using the container name set in docker-compose file
docker logs jupyterlab
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env down
export NAME=`python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['name'])"`
pip uninstall -y ${NAME}
build_serverextension:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -173,8 +176,7 @@ jobs:
diff hello-world/tsconfig.json server-extension/tsconfig.json
diff hello-world/.eslintignore server-extension/.eslintignore
diff hello-world/.eslintrc.js server-extension/.eslintrc.js
diff hello-world/ui-tests/playwright.config.ts server-extension/ui-tests/playwright.config.ts
diff hello-world/ui-tests/README.md server-extension/ui-tests/README.md
diff hello-world/ui-tests/playwright.config.js server-extension/ui-tests/playwright.config.js
shell: bash
- name: Install Python
if: steps.filter.outputs.extension == 'true'
Expand All @@ -199,7 +201,7 @@ jobs:
- name: Install the Python dependencies
if: steps.filter.outputs.extension == 'true'
run: |
python -m pip install --upgrade pip jupyter_packaging~=0.10 jupyterlab~=3.1
python -m pip install --upgrade pip jupyterlab~=4.0.0b0 build twine hatch
- name: Install the NPM dependencies
if: steps.filter.outputs.extension == 'true'
run: |
Expand All @@ -215,20 +217,20 @@ jobs:
# Force the usage of the source distribution (good practice)
run: |
cd server-extension
python setup.py sdist
pip install ./dist/jlab_ext_example* --pre --find-links=dist --no-cache-dir
python -m build --sdist
pip install ./dist/jupyterlab_examples_server* --pre --find-links=dist --no-cache-dir
python -m jupyterlab.browser_check
- name: Check extension as dev
if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') )
run: |
jupyter server extension list 2>&1 | tee serverextension.list
cat serverextension.list | grep -ie "jlab_ext_example.*OK"
cat serverextension.list | grep -ie "jupyterlab_examples_server.*OK"
jupyter labextension list 2>&1 | tee labextension.list
cat labextension.list | grep -ie "@jupyterlab-examples/server-extension.*OK"
- name: Clean extension installation
if: steps.filter.outputs.extension == 'true'
run: |
pip uninstall -y jlab_ext_example
pip uninstall -y jupyterlab_examples_server
jupyter lab clean
jupyter server extension list
jupyter labextension list
Expand All @@ -241,33 +243,33 @@ jobs:
if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') )
run: |
jupyter server extension list 2>&1 | tee serverextension.list
cat serverextension.list | grep -ie "jlab_ext_example.*OK"
cat serverextension.list | grep -ie "jupyterlab_examples_server.*OK"
jupyter labextension list 2>&1 | tee labextension.list
cat labextension.list | grep -ie "@jupyterlab-examples/server-extension.*OK"
python -m jupyterlab.browser_check
- name: Install galata
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux')
working-directory: server-extension/ui-tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: jlpm install
- name: Integration tests
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux')
run: |
cd server-extension
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env down || true
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env pull -q || true
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env build
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env run --rm e2e
working-directory: server-extension/ui-tests
run: jlpm playwright test
- name: Upload UI Test artifacts
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux') && always()
uses: actions/upload-artifact@v3
with:
name: ui-test-output
path: |
server-extension/ui-tests/test-results
- name: Stop containers
if: steps.filter.outputs.extension == 'true' && startsWith(runner.os, 'Linux') && always()
- name: Uninstall extension
if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') )
run: |
cd server-extension
# Print jupyterlab logs before removing the containers using the container name set in docker-compose file
docker logs jupyterlab
docker-compose -f ../end-to-end-tests/docker-compose.yml --env-file ./ui-tests/.env down
export NAME=`python -c "import tomllib; print(tomllib.load(open('server-extension/pyproject.toml', 'rb'))['project']['name'])"`
pip uninstall -y ${NAME}
build_all:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -309,7 +311,7 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
- name: Install the Python dependencies
run: python -m pip install jupyter_packaging~=0.10 jupyterlab~=3.1 pytest pytest-check-links
run: python -m pip install jupyterlab~=4.0.0b0 pytest pytest-check-links
- name: Bootstrap the jlpm deps
run: jlpm
- name: Build all the extensions
Expand All @@ -318,4 +320,4 @@ jobs:
jlpm lint:check
jlpm install-ext
# Check links as last step as new tutorial may set links not yet valid (like file not yet in master)
pytest --check-links
jlpm run lerna exec --concurrency 4 -- "pytest --check-links"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ node_modules/
*.tsbuildinfo
*.lock
__pycache__
.yarn/

# Ensure embedme does not run ont node_modules README.md files.
**/node_modules/**/README.md
Expand Down
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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2020, Project Jupyter Contributors.
Copyright (c) 2020-2023, Project Jupyter Contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
32 changes: 9 additions & 23 deletions command-palette/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ module.exports = {
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:jsdoc/recommended',
'plugin:prettier/recommended',
'plugin:react/recommended',
'plugin:prettier/recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
sourceType: 'module'
},
plugins: ['@typescript-eslint', 'jsdoc'],
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/naming-convention': [
'error',
Expand All @@ -21,9 +19,9 @@ module.exports = {
format: ['PascalCase'],
custom: {
regex: '^I[A-Z]',
match: true,
},
},
match: true
}
}
],
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
'@typescript-eslint/no-explicit-any': 'off',
Expand All @@ -32,22 +30,10 @@ module.exports = {
'@typescript-eslint/quotes': [
'error',
'single',
{ avoidEscape: true, allowTemplateLiterals: false },
{ avoidEscape: true, allowTemplateLiterals: false }
],
curly: ['error', 'all'],
eqeqeq: 'error',
'jsdoc/require-param-type': 'off',
'jsdoc/require-property-type': 'off',
'jsdoc/require-returns-type': 'off',
'jsdoc/no-types': 'warn',
'prefer-arrow-callback': 'error',
},
settings: {
jsdoc: {
mode: 'typescript',
},
react: {
version: 'detect',
},
},
'prefer-arrow-callback': 'error'
}
};
7 changes: 7 additions & 0 deletions command-palette/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ node_modules/
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo

# Integration tests
ui-tests/test-results/
ui-tests/playwright-report/

# Yarn cache
.yarn/
6 changes: 6 additions & 0 deletions command-palette/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
**/node_modules
**/lib
**/package.json
!/package.json
jupyterlab_examples_command_palette
6 changes: 6 additions & 0 deletions command-palette/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid",
"endOfLine": "auto"
}
12 changes: 12 additions & 0 deletions command-palette/.stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": [
"stylelint-config-recommended",
"stylelint-config-standard",
"stylelint-prettier/recommended"
],
"rules": {
"property-no-vendor-prefix": null,
"selector-no-vendor-prefix": null,
"value-no-vendor-prefix": null
}
}
3 changes: 3 additions & 0 deletions command-palette/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enableImmutableInstalls: false

nodeLinker: node-modules
5 changes: 5 additions & 0 deletions command-palette/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

<!-- <START NEW CHANGELOG ENTRY> -->

<!-- <END NEW CHANGELOG ENTRY> -->
29 changes: 29 additions & 0 deletions command-palette/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2023, Project Jupyter Contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 changes: 0 additions & 22 deletions command-palette/MANIFEST.in

This file was deleted.

4 changes: 2 additions & 2 deletions command-palette/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ const extension: JupyterFrontEndPlugin<void> = {
console.log(
`jlab-examples:command-palette has been called ${args['origin']}.`
);
},
}
});

// Add the command to the command palette
const category = 'Extension Examples';
palette.addItem({ command, category, args: { origin: 'from palette' } });
},
}
```
The `ICommandPalette`
Expand Down
Loading

0 comments on commit e316912

Please sign in to comment.