Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build against JupyterLab 4 / Lumino 2 #417

Merged
merged 11 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 47 additions & 18 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,27 @@ jobs:
user: __token__
password: ${{ secrets.pypi_password }}

build:
runs-on: ubuntu-latest
steps:
- name: setup python to build package
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: install build
run: python -m pip install build
- uses: actions/checkout@v3
- name: build package
run: python -m build --sdist --wheel . -o dist
- name: Upload builds
uses: actions/upload-artifact@v3
with:
name: dist ${{ github.run_number }}
path: ./dist

visual-regression-tests-ipw7:
runs-on: ubuntu-latest
needs: [build]

steps:
- name: Checkout
Expand All @@ -119,8 +138,14 @@ jobs:
auto-activate-base: false
channels: conda-forge

- uses: actions/download-artifact@v3
with:
name: dist ${{ github.run_number }}
path: ./dist

- name: Install the package
run: pip install -vv .
run: pip install -vv ipydatagrid*.whl
working-directory: dist

- name: Install Galata
run: |
Expand All @@ -146,13 +171,14 @@ jobs:
if: always()
uses: actions/upload-artifact@v3
with:
name: ui-test-output
name: ui-test-output-ipw7
path: |
ui-tests-ipw7/playwright-report
ui-tests-ipw7/test-results

visual-regression-tests-ipw8:
runs-on: ubuntu-latest
needs: [build]

steps:
- name: Checkout
Expand All @@ -167,34 +193,37 @@ jobs:
auto-activate-base: false
channels: conda-forge

- uses: actions/download-artifact@v3
with:
name: dist ${{ github.run_number }}
path: ./dist

- name: Install the package
run: pip install -vv .
run: pip install -vv ipydatagrid*.whl
working-directory: dist

- name: Install Galata
run: |
yarn install
yarn playwright install chromium
- name: Install dependencies
shell: bash -l {0}
working-directory: ui-tests-ipw8
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: jlpm install

- name: Launch JupyterLab
run: yarn run start:detached &
- name: Install browser
shell: bash -l {0}
run: npx playwright install chromium
working-directory: ui-tests-ipw8

- name: Wait for JupyterLab
uses: ifaxity/wait-on-action@v1
with:
resource: http-get://localhost:8888/api
timeout: 20000

- name: Run UI Tests
run: yarn run test
- name: Execute integration tests
shell: bash -l {0}
working-directory: ui-tests-ipw8
run: npx playwright test

- name: Upload UI Test artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: ui-test-output
name: ui-test-output-ipw8
path: |
ui-tests-ipw8/playwright-report
ui-tests-ipw8/test-results
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ ipydatagrid/labextension/

# Packed lab extensions
ipydatagrid/labextension
ipydatagrid/nbextension/*.svg
ipydatagrid/nbextension/*.png

# Type checking
**/.pyre
Expand Down
17 changes: 9 additions & 8 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
### Tagging and creating a publishing environment

1. Create a new release branch: `git checkout -n release_1.0.x` (**replace .x with the actual version**).
2. Bump the version in `package.json` and `ipydatagrid/._version.py`.
3. Save, sign and commit your changes: `git commit -s -m "Release 1.0.x"`.
4. Open a PR with your release branch: `git push -u origin release_1.0.x`.
5. Once your PR has been merged (!), pull the new main branch `git checkout main && git pull upstream main`.
6. Add a new release tag: `git tag -a 1.0.x -m "Release 1.0.x"`.
7. Push the new tag to GitHub: `git push upstream --tags`.
8. Create a new conda environment: `conda create -n release_grid -c conda-forge python=3.8 python-build`.
9. Activate the environment: `conda activate release_grid`.
2. Install `tbump` with `pip install tbump`.
3. Bump the version with `tbump --only-patch 1.0.x`
4. Save, sign and commit your changes: `git commit -s -m "Release 1.0.x"`.
5. Open a PR with your release branch: `git push -u origin release_1.0.x`.
6. Once your PR has been merged (!), pull the new main branch `git checkout main && git pull upstream main`.
7. Add a new release tag: `git tag -a 1.0.x -m "Release 1.0.x"`.
8. Push the new tag to GitHub: `git push upstream --tags`.
9. Create a new conda environment: `conda create -n release_grid -c conda-forge python=3.8 python-build`.
10. Activate the environment: `conda activate release_grid`.

### Releasing on pypi

Expand Down
50 changes: 40 additions & 10 deletions js/datagrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,47 @@ export class DataGridModel extends DOMWidgetModel {

this.synchingWithKernel = true;

const selectionIter = sender.selections().iter();
const selections: any[] = [];
let selection = null;
while ((selection = selectionIter.next())) {
selections.push({
r1: Math.min(selection.r1, selection.r2),
r2: Math.max(selection.r1, selection.r2),
c1: Math.min(selection.c1, selection.c2),
c2: Math.max(selection.c1, selection.c2),
});

let selectionIter = sender.selections();
// @ts-ignore
if (typeof selectionIter.iter === 'function') {
// Lumino 1 (JupyterLab 3)
let selection = null;

// @ts-ignore
selectionIter = selectionIter.iter()

while ((selection = selectionIter.next())) {
selections.push({
// @ts-ignore
r1: Math.min(selection.r1, selection.r2),
// @ts-ignore
r2: Math.max(selection.r1, selection.r2),
// @ts-ignore
c1: Math.min(selection.c1, selection.c2),
// @ts-ignore
c2: Math.max(selection.c1, selection.c2),
});
}
} else {
// Lumino 2 (JupyterLab 4)
let selectionNode = null;

while (selectionNode = selectionIter.next()) {
if (selectionNode.done) {
break;
}

const selection = selectionNode.value;

selections.push({
r1: Math.min(selection.r1, selection.r2),
r2: Math.max(selection.r1, selection.r2),
c1: Math.min(selection.c1, selection.c2),
c2: Math.max(selection.c1, selection.c2),
});
}
}

this.set('selections', selections);
Expand Down Expand Up @@ -724,7 +755,6 @@ export class DataGridView extends DOMWidgetView {
default_renderer: CellRendererView;
header_renderer: CellRendererView;
grid: FeatherGrid;
// @ts-ignore needed for ipywidgetx 8.x compatibility
luminoWidget: JupyterLuminoPanelWidget;
model: DataGridModel;
backboneModel: DataGridModel;
Expand Down
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ipydatagrid",
"version": "1.1.16",
"version": "1.2.0",
"description": "Fast Datagrid widget for the Jupyter Notebook and JupyterLab",
"keywords": [
"jupyter",
Expand Down Expand Up @@ -54,19 +54,19 @@
"watch:labextension": "jupyter labextension watch ."
},
"dependencies": {
"@jupyter-widgets/base": "^2 || ^3 || ^4 || ^6.0.0",
"@jupyterlab/apputils": "^3.0.2",
"@lumino/algorithm": "^1.9.0",
"@lumino/application": "^1.27.0",
"@lumino/commands": "^1.20.0",
"@lumino/coreutils": "^1.12.0",
"@lumino/datagrid": "^0.36.0",
"@lumino/default-theme": "^0.19.0",
"@lumino/domutils": "^1.8.0",
"@lumino/messaging": "^1.9.0",
"@lumino/signaling": "^1.10",
"@lumino/virtualdom": "^1.13.0",
"@lumino/widgets": "^1.28.0",
"@jupyter-widgets/base": "^2 || ^3 || ^4 || ^6",
"@jupyterlab/apputils": "^3 || ^4",
"@lumino/algorithm": "^1 || ^2",
"@lumino/application": "^1 || ^2",
"@lumino/commands": "^1 || ^2",
"@lumino/coreutils": "^1 || ^2",
"@lumino/datagrid": "^1 || ^2",
"@lumino/default-theme": "^1 || ^2",
"@lumino/domutils": "^1 || ^2",
"@lumino/messaging": "^1 || ^2",
"@lumino/signaling": "^1 || ^2",
"@lumino/virtualdom": "^1 || ^2",
"@lumino/widgets": "^1 || ^2",
"bqplot": "^0.5",
"core-js-pure": "^3.30.2",
"d3-array": "^2.2.0",
Expand Down Expand Up @@ -96,7 +96,7 @@
"acorn": "^6.2.0",
"babel-jest": "^28.1.3",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"css-loader": "^3.0.0",
"css-loader": "^6.8.1",
"eslint": "^7.3.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
Expand All @@ -108,13 +108,13 @@
"prettier": "^2.0.5",
"rimraf": "^2.6.2",
"source-map-loader": "^0.2.4",
"style-loader": "^0.23.1",
"style-loader": "^3.3.3",
"svg-url-loader": "~3.0.3",
"ts-jest": "^28.0.8",
"ts-loader": "^6.0.4",
"typescript": "~4.2.4",
"url-loader": "^4.1.0",
"webpack": "^5",
"webpack": "^5.88.2",
"webpack-cli": "^4.4.0"
},
"jupyterlab": {
Expand Down
4 changes: 2 additions & 2 deletions test-environment-ipyw7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
dependencies:
- pip
- python
- nodejs=14
- nodejs=20
- yarn
- ipywidgets >=7.6.0,<8
- traitlets >=4.3.0
Expand All @@ -13,7 +13,7 @@ dependencies:
- pandas >=1.0.0,<2.0.0
- bqplot
- scipy
- jupyterlab < 4
- jupyterlab =3
- jupyter-packaging
- pytest
- nbval
Expand Down
4 changes: 2 additions & 2 deletions test-environment-ipyw8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
dependencies:
- pip
- python
- nodejs=14
- nodejs=20
- yarn
- ipywidgets >=8.0.0,<9
- traitlets >=4.3.0
Expand All @@ -13,7 +13,7 @@ dependencies:
- pandas >=1.0.0,<2.0.0
- bqplot
- scipy
- jupyterlab < 4
- jupyterlab =4
- jupyter-packaging
- pytest
- nbval
Expand Down
2 changes: 1 addition & 1 deletion test-environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
- pandas >=1.0.0,<2.0.0
- bqplot
- scipy
- jupyterlab < 4
- jupyterlab
- jupyter-packaging
- pytest
- nbval
Expand Down
2 changes: 1 addition & 1 deletion tests/js/filterMenu.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InteractiveFilterDialog } from '../..//js/core/filterMenu';
import { InteractiveFilterDialog } from '../../js/core/filterMenu';
import { ViewBasedJSONModel } from '../../js/core/viewbasedjsonmodel';
import { DataGenerator } from '../js/testUtils';
import { Transform } from '../../js/core/transform';
Expand Down
5 changes: 5 additions & 0 deletions tests/js/setupFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ HTMLCanvasElement.prototype.getContext = () => {
stroke: () => { },
};
};

// Polyfill DragEvent
Object.defineProperty(window, 'DragEvent', {
value: class DragEvent {}
});
5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"compilerOptions": {
"declaration": true,
"esModuleInterop": true,
"lib": ["es2015", "dom"],
"module": "commonjs",
"module": "CommonJS",
"moduleResolution": "node",
"noEmitOnError": true,
"noUnusedLocals": true,
Expand All @@ -15,7 +14,7 @@
"strict": true,
// This allows us to initialize members in the "initialize" method
"strictPropertyInitialization": false,
"target": "es2015"
"target": "es2017"
},
"include": ["js/*.ts", "js/*.tsx", "js/core/*.ts", "js/core/*.tsx"]
}
4 changes: 4 additions & 0 deletions ui-tests-ipw7/tests/ipydatagrid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ const testPlotUpdates = async (page: IJupyterLabPageFixture, tmpPath: string, th

test.describe('ipydatagrid Visual Regression', () => {
test.beforeEach(async ({ page, tmpPath }) => {
page.on("console", (message) => {
console.log('CONSOLE MSG ---', message.text());
});

await page.contents.uploadDirectory(
path.resolve(__dirname, './notebooks'),
tmpPath
Expand Down
11 changes: 2 additions & 9 deletions ui-tests-ipw8/jupyter_server_config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
from tempfile import mkdtemp
from jupyterlab.galata import configure_jupyter_server

c.ServerApp.port = 8888 # noqa: F821
c.ServerApp.token = "" # noqa: F821
c.ServerApp.password = "" # noqa: F821
c.ServerApp.disable_check_xsrf = True # noqa: F821
c.ServerApp.open_browser = False # noqa: F821
c.ServerApp.root_dir = mkdtemp(prefix="galata-test-") # noqa: F821

c.LabApp.expose_app_in_browser = True # noqa: F821
configure_jupyter_server(c) # noqa: F821
4 changes: 2 additions & 2 deletions ui-tests-ipw8/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"author": "ipydatagrid",
"license": "Apache-2.0",
"dependencies": {
"@jupyterlab/galata": "~4.5.0",
"@jupyterlab/galata": "^5.0.0",
"klaw-sync": "^6.0.0",
"rimraf": "^3.0.2"
},
"devDependencies": {
"@playwright/test": "^1.16.2"
"@playwright/test": "^1.32.0"
}
}
Loading