From 07a427988d78dd778d3054999dd97e322edd4905 Mon Sep 17 00:00:00 2001 From: chenzo Date: Tue, 1 Apr 2025 21:48:01 +0800 Subject: [PATCH 01/13] Upgrade package from JupyterLab 3.x to 4.x --- .../package.json | 61 ++++++++++--------- .../src/SidePanel.ts | 9 +-- .../src/clusters/Clusters.tsx | 12 ++-- .../src/common/HtmlView.tsx | 2 +- .../src/inspector/InspectableList.tsx | 2 +- .../src/inspector/InspectableListItem.tsx | 2 +- .../src/inspector/InspectableView.tsx | 10 +-- .../src/inspector/Inspectables.tsx | 6 +- .../src/inspector/InteractiveInspector.tsx | 2 +- .../src/kernel/InterruptKernelButton.tsx | 2 +- 10 files changed, 56 insertions(+), 52 deletions(-) diff --git a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/package.json b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/package.json index a3d204a25f5f..8466e1f1c75d 100644 --- a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/package.json +++ b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/package.json @@ -43,38 +43,41 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.1.17", - "@jupyterlab/launcher": "^3.1.17", - "@jupyterlab/mainmenu": "^3.1.17", - "@rmwc/button": "^6.1.3", - "@rmwc/fab": "^6.1.4", - "@rmwc/data-table": "^6.0.14", - "@rmwc/dialog": "^7.0.2", - "@rmwc/drawer": "^6.0.14", - "@rmwc/list": "^6.1.3", - "@rmwc/textfield": "^6.1.4", - "@rmwc/tooltip": "^6.1.4", - "@rmwc/top-app-bar": "^6.1.3", - "material-design-icons": "^3.0.1" + "@jupyterlab/application": "^4.3.6", + "@jupyterlab/launcher": "^4.3.6", + "@jupyterlab/mainmenu": "^4.3.6", + "@lumino/widgets": "^2.2.1", + "@rmwc/button": "^8.0.6", + "@rmwc/data-table": "^8.0.6", + "@rmwc/dialog": "^8.0.6", + "@rmwc/drawer": "^8.0.6", + "@rmwc/fab": "^8.0.6", + "@rmwc/list": "^8.0.6", + "@rmwc/textfield": "^8.0.6", + "@rmwc/tooltip": "^8.0.6", + "@rmwc/top-app-bar": "^8.0.6", + "material-design-icons": "^3.0.1", + "react": "^18.2.0", + "react-dom": "^18.2.0" }, "devDependencies": { - "@jupyterlab/builder": "^3.1.0", - "@types/jest": "^26.0.7", - "@types/react-dom": "^16.9.8", - "@typescript-eslint/eslint-plugin": "^4.8.1", - "@typescript-eslint/parser": "^4.8.1", - "eslint": "^7.14.0", - "eslint-config-prettier": "^6.15.0", - "eslint-plugin-prettier": "^3.1.4", - "eslint-plugin-react": "^7.20.5", + "@jupyterlab/builder": "^4.3.6", + "@types/jest": "^29.5.14", + "@types/react": "^18.2.0", + "@types/react-dom": "^18.2.0", + "@typescript-eslint/eslint-plugin": "^7.3.1", + "@typescript-eslint/parser": "^7.3.1", + "eslint": "^8.56.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.1.3", + "eslint-plugin-react": "^7.33.2", "identity-obj-proxy": "^3.0.0", - "jest": "^26.1.0", + "jest": "^29.7.0", "npm-run-all": "^4.1.5", - "prettier": "^2.1.1", - "react-dom": "^17.0.1", - "rimraf": "^3.0.2", - "ts-jest": "^26.1.3", - "typescript": "~4.1.3" + "prettier": "^3.2.4", + "rimraf": "^5.0.5", + "ts-jest": "^29.1.2", + "typescript": "~5.3.3" }, "sideEffects": [ "style/*.css", @@ -86,6 +89,6 @@ }, "test": "jest", "resolutions": { - "@types/react": "~16.9.16" + "@types/react": "^18.2.0" } } diff --git a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/SidePanel.ts b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/SidePanel.ts index 596f4d3673c4..fb86b0a53fdf 100644 --- a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/SidePanel.ts +++ b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/SidePanel.ts @@ -14,7 +14,7 @@ import { ReactWidget, SessionContext, ISessionContext, - sessionContextDialogs + SessionContextDialogs } from '@jupyterlab/apputils'; import { IRenderMimeRegistry } from '@jupyterlab/rendermime'; import { ServiceManager } from '@jupyterlab/services'; @@ -64,7 +64,7 @@ export class SidePanel extends BoxPanel { } else { let sessionModel = sessionModelItr.next(); while (sessionModel !== undefined) { - if (sessionModel.kernel.id !== firstModel.kernel.id) { + if (sessionModel.value.kernel.id !== firstModel.value.kernel.id) { // There is more than one unique running kernel. onlyOneUniqueKernelExists = false; break; @@ -78,7 +78,7 @@ export class SidePanel extends BoxPanel { // kernel. if (onlyOneUniqueKernelExists) { this._sessionContext.sessionManager.connectTo({ - model: firstModel, + model: firstModel.value, kernelConnectionOptions: { // Only one connection can handleComms. Leave it to the connection // established by the opened notebook. @@ -86,10 +86,11 @@ export class SidePanel extends BoxPanel { } }); // Connect to the unique kernel. - this._sessionContext.changeKernel(firstModel.kernel); + this._sessionContext.changeKernel(firstModel.value.kernel); } else { // Let the user choose among sessions and kernels when there is no // or more than 1 running kernels. + const sessionContextDialogs = new SessionContextDialogs(); await sessionContextDialogs.selectKernel(this._sessionContext); } } catch (err) { diff --git a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/clusters/Clusters.tsx b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/clusters/Clusters.tsx index 51542563d238..1391010d4aa0 100644 --- a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/clusters/Clusters.tsx +++ b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/clusters/Clusters.tsx @@ -209,7 +209,7 @@ export class Clusters extends React.Component { style={{ backgroundColor: 'var(--mdc-theme-error)' }} theme={['onError']} mini - onClick={e => { + onClick={() => { this.displayDialog(true, key, value['cluster_name']); }} /> @@ -234,7 +234,7 @@ export class Clusters extends React.Component { label="Default cluster" enhanced options={clusterNames} - onChange={e => this.setDefaultCluster(e.currentTarget.value)} + onChange={(e: React.ChangeEvent) => this.setDefaultCluster(e.currentTarget.value)} value={this.state.defaultClusterId} /> { { + onClick={() => { this.deleteCluster(this.state.selectedId); }} > @@ -286,7 +286,7 @@ export class Clusters extends React.Component { private _inspectKernelCode: string; private _model: KernelModel; - private _queryKernelTimerId: number; - private _updateRenderTimerId: number; - private _updateSessionInfoTimerId: number; + private _queryKernelTimerId: ReturnType; + private _updateRenderTimerId: ReturnType; + private _updateSessionInfoTimerId: ReturnType; } diff --git a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/common/HtmlView.tsx b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/common/HtmlView.tsx index 1cd35b423cf5..2189d6eb2146 100644 --- a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/common/HtmlView.tsx +++ b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/common/HtmlView.tsx @@ -88,7 +88,7 @@ export class HtmlView extends React.Component { ); } - private _updateRenderTimerId: number; + private _updateRenderTimerId: ReturnType; } /** diff --git a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InspectableList.tsx b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InspectableList.tsx index 90e262ced0a4..cde34653208d 100644 --- a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InspectableList.tsx +++ b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InspectableList.tsx @@ -123,5 +123,5 @@ export class InspectableList extends React.Component< }); } - private _updateRenderTimerId: number; + private _updateRenderTimerId: ReturnType; } diff --git a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InspectableListItem.tsx b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InspectableListItem.tsx index 9fa2075965a7..4abd846635de 100644 --- a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InspectableListItem.tsx +++ b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InspectableListItem.tsx @@ -98,5 +98,5 @@ export class InspectableListItem extends React.Component< ); } - private _updateRenderTimerId: number; + private _updateRenderTimerId: ReturnType; } diff --git a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InspectableView.tsx b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InspectableView.tsx index c04c45722a11..3c949e3126e9 100644 --- a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InspectableView.tsx +++ b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InspectableView.tsx @@ -131,7 +131,7 @@ export class InspectableView extends React.Component< { + onChange={(e: React.ChangeEvent): void => { showOptions.includeWindowInfo = !!e.currentTarget.checked; this.setState({ options: showOptions }); }} @@ -146,7 +146,7 @@ export class InspectableView extends React.Component< { + onChange={(e: React.ChangeEvent): void => { showOptions.visualizeInFacets = !!e.currentTarget.checked; this.setState({ options: showOptions }); }} @@ -169,7 +169,7 @@ export class InspectableView extends React.Component< label="Duration" floatLabel placeholder={showOptions.duration} - onChange={(e): void => { + onChange={(e: React.ChangeEvent): void => { showOptions.duration = e.currentTarget.value; }} /> @@ -190,7 +190,7 @@ export class InspectableView extends React.Component< label="Element Number" floatLabel placeholder={showOptions.n} - onChange={(e): void => { + onChange={(e: React.ChangeEvent): void => { showOptions.n = e.currentTarget.value; }} /> @@ -220,5 +220,5 @@ export class InspectableView extends React.Component< } as IShowOptions; } - private _updateRenderTimerId: number; + private _updateRenderTimerId: ReturnType; } diff --git a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/Inspectables.tsx b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/Inspectables.tsx index a38b3b994b01..08fff2077835 100644 --- a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/Inspectables.tsx +++ b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/Inspectables.tsx @@ -72,7 +72,7 @@ export class Inspectables extends React.Component< if ( Object.keys(inspectablesToUpdate).length && JSON.stringify(this.state.inspectables) !== - JSON.stringify(inspectablesToUpdate) + JSON.stringify(inspectablesToUpdate) ) { this.setState({ inspectables: inspectablesToUpdate }); } @@ -99,6 +99,6 @@ export class Inspectables extends React.Component< private _inspectKernelCode: string; private _model: KernelModel; - private _queryKernelTimerId: number; - private _updateRenderTimerId: number; + private _queryKernelTimerId: ReturnType; + private _updateRenderTimerId: ReturnType; } diff --git a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InteractiveInspector.tsx b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InteractiveInspector.tsx index 854acb2ebd19..9eaffd1588d9 100644 --- a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InteractiveInspector.tsx +++ b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InteractiveInspector.tsx @@ -129,5 +129,5 @@ export class InteractiveInspector extends React.Component< ); } - private _updateSessionInfoTimerId: number; + private _updateSessionInfoTimerId: ReturnType; } diff --git a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/kernel/InterruptKernelButton.tsx b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/kernel/InterruptKernelButton.tsx index 0ab9be7f516a..9bbe7b3e2e33 100644 --- a/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/kernel/InterruptKernelButton.tsx +++ b/sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/kernel/InterruptKernelButton.tsx @@ -78,5 +78,5 @@ export class InterruptKernelButton extends React.Component< return