Skip to content

Commit

Permalink
Update to jupyterlab 4
Browse files Browse the repository at this point in the history
  • Loading branch information
peytondmurray committed Mar 20, 2023
1 parent ce61432 commit f861d6d
Show file tree
Hide file tree
Showing 8 changed files with 6,628 additions and 6,616 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
python-version: '3.7'
architecture: 'x64'
- name: Install dependencies
run: python -m pip install jupyterlab
run: python -m pip install jupyterlab==4.0.0a37
- name: Build the extension
run: |
jlpm
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,9 @@ dmypy.json

# OSX files
.DS_Store

# Berry
.pnp.cjs
.pnp.loader.mjs
.yarn/
.yarnrc.yml
46 changes: 23 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,40 +57,40 @@
"watch:src": "tsc -w"
},
"dependencies": {
"@jupyterlab/application": "^3.0.0",
"@jupyterlab/cells": "^3.0.0",
"@jupyterlab/docregistry": "^3.0.0",
"@jupyterlab/notebook": "^3.0.0",
"@jupyterlab/settingregistry": "^3.0.0",
"@lumino/coreutils": "^1.5.3",
"@lumino/widgets": "^1.16.1",
"date-fns": "^2.24.0"
"@jupyterlab/application": "^4.0.0-alpha.22",
"@jupyterlab/cells": "^4.0.0-alpha.22",
"@jupyterlab/docregistry": "^4.0.0-alpha.22",
"@jupyterlab/notebook": "^4.0.0-alpha.22",
"@jupyterlab/settingregistry": "^4.0.0-alpha.22",
"@lumino/coreutils": "^2.0.0-rc.1",
"@lumino/widgets": "^2.0.0-rc.1",
"date-fns": "^2.29.3"
},
"husky": {
"hooks": {
"pre-commit": "npm run lint && npm run test"
}
},
"devDependencies": {
"@jupyterlab/builder": "^3.1.12",
"@types/chai": "^4.2.22",
"@types/mocha": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^4.32.0",
"@typescript-eslint/parser": "^4.32.0",
"chai": "^4.3.4",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^4.2.3",
"mocha": "^9.1.2",
"@jupyterlab/builder": "^4.0.0-alpha.22",
"@types/chai": "^4.3.4",
"@types/mocha": "^10.0.1",
"@typescript-eslint/eslint-plugin": "^5.54.1",
"@typescript-eslint/parser": "^5.54.1",
"chai": "^4.3.7",
"eslint": "^8.35.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.3",
"mocha": "^10.2.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.4.1",
"rimraf": "^3.0.2",
"ts-mocha": "^8.0.0",
"prettier": "^2.8.4",
"rimraf": "^4.4.0",
"ts-mocha": "^10.0.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.3.0",
"typescript": "~4.1.3"
"typescript": "5.0.1-rc"
},
"styleModule": "style/index.js"
}
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 = ["jupyter_packaging~=0.9,<2", "jupyterlab~=3.0"]
requires = ["jupyter_packaging~=0.10,<2", "jupyterlab==4.0.0a37"]
build-backend = "jupyter_packaging.build_api"

[tool.jupyter-packaging.builder]
Expand Down
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,21 @@
long_description=long_description,
long_description_content_type="text/markdown",
packages=setuptools.find_packages(),
install_requires=["jupyter_server>=1.6,<3"],
install_requires=["jupyter_server>=2.0.1,<3"],
zip_safe=False,
include_package_data=True,
python_requires=">=3.6",
python_requires=">=3.7",
platforms="Linux, Mac OS X, Windows",
keywords=["Jupyter", "JupyterLab", "JupyterLab3"],
keywords=["Jupyter", "JupyterLab", "JupyterLab4"],
classifiers=[
"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",
"Framework :: Jupyter",
],
)
Expand Down
19 changes: 6 additions & 13 deletions src/ExecuteTimeWidget.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Widget } from '@lumino/widgets';
import { JSONExt, JSONObject } from '@lumino/coreutils';
import { NotebookPanel, INotebookTracker } from '@jupyterlab/notebook';
import { NotebookPanel, INotebookTracker, type CellList } from '@jupyterlab/notebook';
import { ISettingRegistry } from '@jupyterlab/settingregistry';
import {
IObservableJSON,
IObservableList,
IObservableUndoableList,
} from '@jupyterlab/observables';
import { Cell, CodeCell, ICellModel } from '@jupyterlab/cells';
import { getTimeDiff, getTimeString } from './formatters';
Expand Down Expand Up @@ -73,7 +71,7 @@ export default class ExecuteTimeWidget extends Widget {
}

updateConnectedCell(
cells: IObservableUndoableList<ICellModel>,
sender: CellList,
changed: IObservableList.IChangedArgs<ICellModel>
) {
// While we could look at changed.type, it's easier to just remove all
Expand All @@ -86,7 +84,7 @@ export default class ExecuteTimeWidget extends Widget {
if (!(cellModel.id in this._cellSlotMap)) {
const fn = () => this._cellMetadataChanged(cellModel);
this._cellSlotMap[cellModel.id] = fn;
cellModel.metadata.changed.connect(fn);
cellModel.metadataChanged.connect(fn);
}
// Always re-render cells.
// In case there was already metadata: do not highlight on first load.
Expand All @@ -96,7 +94,7 @@ export default class ExecuteTimeWidget extends Widget {
_deregisterMetadataChanges(cellModel: ICellModel) {
const fn = this._cellSlotMap[cellModel.id];
if (fn) {
cellModel.metadata.changed.disconnect(fn);
cellModel.metadataChanged.disconnect(fn);
const codeCell = this._getCodeCell(cellModel);
if (codeCell) {
this._removeExecuteNode(codeCell);
Expand Down Expand Up @@ -151,9 +149,7 @@ export default class ExecuteTimeWidget extends Widget {
* @private
*/
_updateCodeCell(cell: CodeCell, disableHighlight: boolean) {
const executionMetadata = cell.model.metadata.get(
'execution'
) as JSONObject;
const executionMetadata = cell.model.getMetadata('execution') as JSONObject;
if (executionMetadata && JSONExt.isObject(executionMetadata)) {
let executionTimeNode: HTMLDivElement = cell.node.querySelector(
`.${EXECUTE_TIME_CLASS}`
Expand Down Expand Up @@ -359,10 +355,7 @@ export default class ExecuteTimeWidget extends Widget {
}

private _cellSlotMap: {
[id: string]: (
sender: IObservableJSON,
args: IObservableJSON.IChangedArgs
) => void;
[id: string]: () => void;
} = {};
private _tracker: INotebookTracker;
private _panel: NotebookPanel;
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"rootDir": "src",
"strict": true,
"strictNullChecks": false,
"target": "es2017",
"target": "es2018",
"types": []
},
"include": ["src/*"]
Expand Down
Loading

0 comments on commit f861d6d

Please sign in to comment.