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

Update to jupyterlab 4 #110

Merged
merged 16 commits into from
Oct 1, 2024
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
project: 'tsconfig.eslint.json',
sourceType: 'module'
},
plugins: ['@typescript-eslint'],
Expand Down
36 changes: 19 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,29 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: [3.9, "3.10", "3.11"]
fail-fast: false
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
# https://github.com/jupyterlab/maintainer-tools/blob/main/.github/actions/base-setup/action.yml
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
with:
node-version: '18.x'
python_version: ${{ matrix.python-version }}
node_version: '18.x'
- name: Install dependencies
run: python -m pip install -U jupyterlab~=3.0
- name: Build the extension
run: python -m pip install -U jupyterlab~=4.0
- name: jlpm config
run: jlpm config set -H enableImmutableInstalls false
Comment on lines +22 to +23
Copy link
Contributor Author

@chrishavlin chrishavlin Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't work out why, but enableImmutableInstalls was set to true in the CI environment, which causes an error when there is no yarn.lock file on install:

YN0028: The lockfile would have been created by this install, which is explicitly forbidden.

but the yarn file should be created here. so setting it to false seems correct. just not sure what caused the change in the CI test enviornment in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to commit our yarn.lock file. I'm not sure if it's a universally-accepted practice for jupyterlab extensions ... but maybe I'm just out of the loop or woefully ignorant?!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya, i'm not sure either -- maybe we should be committing it? but I can research that separate from this PR.

- name: install ts modules
run: jlpm
- name: jlpm lint check
run: jlpm run eslint:check
- name: install python package
run: python -m pip install .
- name: check for widgyts in extensions
run: |
jlpm
jlpm run eslint:check
python -m pip install yt
python -m pip install .

jupyter server extension list 2>&1 | grep -ie "widgyts.*OK"

jupyter labextension list 2>&1 | grep -ie "@yt-project/yt-widgets.*OK"
python -m jupyterlab.browser_check
- name: run jupyterlab browser check
run: python -m jupyterlab.browser_check
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Build and Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,4 @@ dmypy.json

# yarn build related
.yarn/
.yarnrc.yml
yarn.lock
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ The following assumes you're using conda. If not, you'll need to install nodejs
in your environemnt separately.

```bash
conda create -n widgyts-dev -c conda-forge nodejs python=3.10 jupyterlab=3
conda create -n widgyts-dev -c conda-forge nodejs python=3.10 jupyterlab=4
conda activate widgyts-dev
```

Install the python. This will also build the TS package.
```bash
pip install -e "."
pip install -e .
```

When developing your extensions, you need to manually enable your extensions with the
Expand Down
73 changes: 32 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,54 +60,45 @@
},
"dependencies": {
"@data-exp-lab/yt-tools": "^0.4.1",
"@jupyter-widgets/base": "^1.1.10 || ^2 || ^3 || ^4",
"@jupyterlab/application": "^3.0.4",
"@jupyterlab/coreutils": "^5.0.2",
"@jupyterlab/mainmenu": "^3.0.3",
"@jupyterlab/services": "^6.0.3",
"@jupyter-widgets/base": "^1.1.10 || ^2 || ^3 || ^4 || ^5 || ^6",
"@jupyterlab/application": "^4.2.5",
"@types/fscreen": "^1.0.1",
"@types/node": "^10.11.6",
"@types/three": "^0.141.0",
"fscreen": "^1.2.0",
"ipycanvas": "^0.8.2",
"ipycanvas": "^0.13.3",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed to bump this to get the canvas widget to properly compile

"jupyter-threejs": "^2.3.0"
},
"devDependencies": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these deps were copy/pasted from the current cookiecutter, which is configured for jupyterlab 4. I did remove the jest and babel deps that are in the cookiecutter, because we're not using them anywhere (and don't need to as far as I can tell)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there's a possibility that I added them when wasm-bundling wasn't as straightforward as it is now.

"@jupyterlab/builder": "^3.0.0",
"@phosphor/application": "^1.6.0",
"@phosphor/widgets": "^1.6.0",
"@types/expect.js": "^0.3.29",
"@types/mocha": "^5.2.5",
"@types/node": "^10.11.6",
"@types/webpack-env": "^1.13.6",
"@typescript-eslint/eslint-plugin": "^3.6.0",
"@typescript-eslint/parser": "^3.6.0",
"acorn": "^7.2.0",
"css-loader": "^3.2.0",
"eslint": "^7.4.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"expect.js": "^0.3.1",
"fs-extra": "^7.0.0",
"karma": "^3.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-firefox-launcher": "^1.1.0",
"karma-ie-launcher": "^1.0.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-typescript": "^5.0.3",
"karma-typescript-es6-transform": "^5.0.3",
"mkdirp": "^0.5.1",
"mocha": "^5.2.0",
"npm-run-all": "^4.1.3",
"prettier": "^2.0.5",
"rimraf": "^2.6.2",
"source-map-loader": "^0.2.4",
"style-loader": "^1.0.0",
"ts-loader": "^5.2.1",
"typescript": "^4.1.3",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2"
"@jupyter-widgets/base-manager": "^1.0.7",
"@jupyterlab/builder": "^4.0.11",
"@lumino/application": "^2.3.0",
"@lumino/widgets": "^2.3.1",
"@types/webpack-env": "^1.18.4",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"acorn": "^8.11.3",
"css-loader": "^6.9.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"fs-extra": "^11.2.0",
"identity-obj-proxy": "^3.0.0",
"mkdirp": "^3.0.1",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.4",
"rimraf": "^5.0.5",
"source-map-loader": "^5.0.0",
"style-loader": "^3.3.4",
"ts-loader": "^9.5.1",
"typescript": "~5.3.3",
"webpack": "^5.90.0",
"webpack-cli": "^5.1.4"
},
"devDependenciesComments": {
"@jupyterlab/builder": "pinned to the latest JupyterLab 4.x release",
"@lumino/application": "pinned to the latest Lumino 2.x release",
"@lumino/widgets": "pinned to the latest Lumino 2.x release"
},
"sideEffects": [
"style/*.css",
Expand Down
39 changes: 23 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
[build-system]
requires = [
"hatchling",
"jupyterlab~=3.1",
"hatchling>=1.21.1",
"jupyterlab>=4.0.0,<5",
"hatch-nodejs-version>=0.3.2",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

migration script missedhatch-nodejs-version, but the cookiecutter has it, so added it.

]
build-backend = "hatchling.build"

[project]
name = "widgyts"
description = "A Custom Jupyter Widget Library for Interactive Visualization with yt"
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.9"
authors = [
{ name = "The yt Project", email = "[email protected]" },
]
keywords = [
"Jupyter",
"JupyterLab",
"JupyterLab3",
"JupyterLab4",
]
classifiers = [
"Framework :: Jupyter",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
"ipycanvas>=0.4.7",
"ipywidgets>=7.5.1",
"jupyterlab~=3.0",
"ipywidgets>=8.0.0",
"jupyterlab>=4.0",
"numpy>=1.14",
"pythreejs>=2.2.0",
"traitlets>=4.3.3",
Expand All @@ -50,9 +50,13 @@ Tracker = "https://github.com/yt-project/widgyts/issues"

[tool.hatch.build]
artifacts = [
"widgyts/labextension/*.tgz",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want this? not sure. the cookiecutter has it.

"widgyts/labextension",
]

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel.shared-data]
"widgyts/labextension/static" = "share/jupyter/labextensions/@yt-project/yt-widgets/static"
"install.json" = "share/jupyter/labextensions/@yt-project/yt-widgets/install.json"
Expand All @@ -67,7 +71,7 @@ exclude = [

[tool.hatch.build.hooks.jupyter-builder]
dependencies = [
"hatch-jupyter-builder>=0.9.1",
"hatch-jupyter-builder>=0.8.3",
]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = [
Expand All @@ -78,24 +82,27 @@ skip-if-exists = [
"widgyts/labextension/static/style.js",
]

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
path = "."
build_cmd = "build:prod"
npm = [
"jlpm",
]

[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs]
path = "."
build_dir = "widgyts/labextension"
source_dir = "src"
build_cmd = "install:extension"
npm = [
"jlpm",
]

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
build_cmd = "build:prod"
npm = [
"jlpm",
]


[tool.black]
line-length = 88
target-version = [
"py38",
"py39",
"py310",
"py311",
Expand Down
2 changes: 1 addition & 1 deletion src/fullscreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class FullscreenButtonView extends DOMWidgetView {
this.el.classList.add('jupyter-widgets');
this.el.classList.add('jupyter-button');
this.el.classList.add('widget-button');
this.delegate('click', this.el, this._handle_click);
this.delegate('click', this.el.value, this._handle_click);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got a compilation error without this complaining about assigning a string output to a HTMLButtonElement, based on some google/SO searching, seemed like this would work. and it does now compile. though just realized I didn't test the button, will go do that now ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm. ok, ya, i don't even see the fullscreen button any more, so i broke something here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it totally works yet. So let's not worry about this for this PR and fix it at a later time. If I can figure it out I'll update your PR.

this.update(); // Set defaults.
}

Expand Down
5 changes: 5 additions & 0 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "./tsconfig.json",
"include": ["src/**/*.ts", "src/**/*.tsx"],
"exclude": []
}