Skip to content

Commit c21f014

Browse files
author
KevinGG
committed
[BEAM-12997] Upgraded labextension to V3
1. Upgraded JupyterLab extension apache-beam-jupyterlab-sidepanel to be compatible with JupyterLab V3.
1 parent 38305d9 commit c21f014

File tree

15 files changed

+4300
-980
lines changed

15 files changed

+4300
-980
lines changed

sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/.eslintrc.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,33 @@ module.exports = {
2525
},
2626
plugins: ['@typescript-eslint'],
2727
rules: {
28-
'@typescript-eslint/interface-name-prefix': [
28+
'@typescript-eslint/naming-convention': [
2929
'error',
30-
{ prefixWithI: 'always' }
30+
{
31+
'selector': ['variable', 'function'],
32+
'format': ['camelCase'],
33+
'leadingUnderscore': 'allow'
34+
}
35+
],
36+
'@typescript-eslint/naming-convention': [
37+
'error',
38+
{
39+
'selector': 'interface',
40+
'format': ['PascalCase'],
41+
'custom': {
42+
'regex': '^I[A-Z]',
43+
'match': true
44+
}
45+
}
46+
],
47+
"@typescript-eslint/ban-types": [
48+
"error",
49+
{
50+
"extendDefaults": true,
51+
"types": {
52+
"object": false
53+
}
54+
}
3155
],
3256
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
3357
'@typescript-eslint/no-explicit-any': 'off',
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
22
"singleQuote": true,
3-
"printWidth": 80
3+
"printWidth": 80,
4+
"trailingComma": "none",
5+
"arrowParens": "avoid"
46
}

sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/package.json

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,27 @@
2525
"url": "https://github.com/apache/beam.git"
2626
},
2727
"scripts": {
28-
"build": "tsc",
29-
"clean": "rimraf lib tsconfig.tsbuildinfo",
28+
"build": "jlpm run build:lib && jlpm run build:labextension:dev",
29+
"build:labextension": "jupyter labextension build .",
30+
"build:labextension:dev": "jupyter labextension build --development True .",
31+
"build:lib": "tsc",
32+
"build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension",
33+
"clean": "jlpm run clean:lib",
34+
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
35+
"clean:labextension": "rimraf apache-beam-jupyterlab-sidepanel/labextension",
36+
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
3037
"eslint": "eslint . --ext .ts,.tsx --fix",
3138
"eslint:check": "eslint . --ext .ts,.tsx",
39+
"install:extension": "jlpm run build",
3240
"prepare": "jlpm run clean && jlpm run build",
33-
"watch": "tsc -w"
41+
"watch": "run-p watch:src watch:labextension",
42+
"watch:labextension": "jupyter labextension watch .",
43+
"watch:src": "tsc -w"
3444
},
3545
"dependencies": {
36-
"@jupyterlab/application": "^2.0.0",
37-
"@jupyterlab/launcher": "^2.2.4",
38-
"@jupyterlab/mainmenu": "^2.2.2",
46+
"@jupyterlab/application": "^3.1.17",
47+
"@jupyterlab/launcher": "^3.1.17",
48+
"@jupyterlab/mainmenu": "^3.1.17",
3949
"@rmwc/button": "^6.1.3",
4050
"@rmwc/checkbox": "^6.1.3",
4151
"@rmwc/drawer": "^6.0.14",
@@ -46,27 +56,31 @@
4656
"material-design-icons": "^3.0.1"
4757
},
4858
"devDependencies": {
59+
"@jupyterlab/builder": "^3.1.0",
4960
"@types/jest": "^26.0.7",
5061
"@types/react-dom": "^16.9.8",
51-
"@typescript-eslint/eslint-plugin": "^2.25.0",
52-
"@typescript-eslint/parser": "^2.25.0",
53-
"eslint": "^6.8.0",
54-
"eslint-config-prettier": "^6.10.1",
55-
"eslint-plugin-prettier": "^3.1.2",
62+
"@typescript-eslint/eslint-plugin": "^4.8.1",
63+
"@typescript-eslint/parser": "^4.8.1",
64+
"eslint": "^7.14.0",
65+
"eslint-config-prettier": "^6.15.0",
66+
"eslint-plugin-prettier": "^3.1.4",
5667
"eslint-plugin-react": "^7.20.5",
5768
"identity-obj-proxy": "^3.0.0",
5869
"jest": "^26.1.0",
59-
"prettier": "^1.19.0",
60-
"react-dom": "^16.13.1",
61-
"rimraf": "^2.6.1",
70+
"npm-run-all": "^4.1.5",
71+
"prettier": "^2.1.1",
72+
"react-dom": "^17.0.1",
73+
"rimraf": "^3.0.2",
6274
"ts-jest": "^26.1.3",
63-
"typescript": "~3.7.0"
75+
"typescript": "~4.1.3"
6476
},
6577
"sideEffects": [
66-
"style/*.css"
78+
"style/*.css",
79+
"style/index.js"
6780
],
6881
"jupyterlab": {
69-
"extension": true
82+
"extension": true,
83+
"outputDir": "apache-beam-jupyterlab-sidepanel/labextension"
7084
},
7185
"test": "jest",
7286
"resolutions": {

sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/SidePanel.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ export class SidePanel extends BoxPanel {
8888
this._sessionContext.sessionManager.connectTo({
8989
model: firstModel,
9090
kernelConnectionOptions: {
91-
handleComms: true
91+
// Only one connection can handleComms. Leave it to the connection
92+
// established by the opened notebook.
93+
handleComms: false
9294
}
9395
});
9496
// Connect to the unique kernel.

sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/__tests__/common/HtmlView.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ describe('HtmlView', () => {
6565
'only executes incrementally updated Javascript ' +
6666
'as html provider updated',
6767
() => {
68-
const htmlViewRef: React.RefObject<HtmlView> = React.createRef<
69-
HtmlView
70-
>();
68+
const htmlViewRef: React.RefObject<HtmlView> =
69+
React.createRef<HtmlView>();
7170
const spiedConsole = jest.spyOn(console, 'log');
7271
const fakeHtmlProvider = {
7372
html: '<div></div>',

sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/__tests__/inspector/InspectableView.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ it('does not render options if inspecting a pipeline', () => {
5353
});
5454

5555
it('renders options if inspecting a pcollection', () => {
56-
const inspectableViewRef: React.RefObject<InspectableView> = React.createRef<
57-
InspectableView
58-
>();
56+
const inspectableViewRef: React.RefObject<InspectableView> =
57+
React.createRef<InspectableView>();
5958
const fakeModel = {
6059
html: '',
6160
script: [] as string[],

sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/__tests__/inspector/InspectableViewModel.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ import {
1818
const fakeSessionContext = {
1919
session: {
2020
kernel: {
21-
requestExecute: function(): object {
21+
requestExecute: function (): Record<string, unknown> {
2222
return {
23-
onIOPub: function(): void {
23+
onIOPub: function (): void {
2424
// do nothing
2525
}
2626
};
2727
},
28-
interrupt: function(): void {
28+
interrupt: function (): void {
2929
// do nothing
3030
}
3131
}

sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/__tests__/inspector/Inspectables.test.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { act } from 'react-dom/test-utils';
1919
import { Inspectables } from '../../inspector/Inspectables';
2020

2121
jest.mock('../../inspector/InspectableList', () => {
22-
const FakeInspectableList = function(): React.ReactNode {
22+
const FakeInspectableList = function (): React.ReactNode {
2323
return <div></div>;
2424
};
2525
FakeInspectableList.displayName = 'FakeInspectableList';
@@ -43,9 +43,8 @@ afterEach(() => {
4343
});
4444

4545
it('renders info message about no inspectable when none is available', () => {
46-
const inspectablesRef: React.RefObject<Inspectables> = React.createRef<
47-
Inspectables
48-
>();
46+
const inspectablesRef: React.RefObject<Inspectables> =
47+
React.createRef<Inspectables>();
4948
act(() => {
5049
render(<Inspectables ref={inspectablesRef} />, container);
5150
const inspectables = inspectablesRef.current;
@@ -61,9 +60,8 @@ it('renders info message about no inspectable when none is available', () => {
6160
});
6261

6362
it('renders inspectables as a list of collapsible lists', () => {
64-
const inspectablesRef: React.RefObject<Inspectables> = React.createRef<
65-
Inspectables
66-
>();
63+
const inspectablesRef: React.RefObject<Inspectables> =
64+
React.createRef<Inspectables>();
6765
const testData = {
6866
pipelineId1: {
6967
metadata: {

sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/__tests__/inspector/InteractiveInspector.test.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import { InspectableViewModel } from '../../inspector/InspectableViewModel';
2323
const fakeSessionContext = {
2424
session: {
2525
kernel: {
26-
requestExecute: function(): object {
26+
requestExecute: function (): Record<string, unknown> {
2727
return {
28-
onIOPub: function(): void {
28+
onIOPub: function (): void {
2929
// do nothing
3030
}
3131
};
@@ -118,9 +118,8 @@ it('renders the drawer open by default', () => {
118118
});
119119

120120
it('closes the drawer on flip from open state', () => {
121-
const inspectorRef: React.RefObject<InteractiveInspector> = React.createRef<
122-
InteractiveInspector
123-
>();
121+
const inspectorRef: React.RefObject<InteractiveInspector> =
122+
React.createRef<InteractiveInspector>();
124123
const inspectableViewModel = new InspectableViewModel(
125124
fakeSessionContext as any
126125
);
@@ -147,9 +146,8 @@ it('closes the drawer on flip from open state', () => {
147146
});
148147

149148
it('updates session info on change', () => {
150-
const inspectorRef: React.RefObject<InteractiveInspector> = React.createRef<
151-
InteractiveInspector
152-
>();
149+
const inspectorRef: React.RefObject<InteractiveInspector> =
150+
React.createRef<InteractiveInspector>();
153151
const inspectableViewModel = new InspectableViewModel(
154152
fakeSessionContext as any
155153
);

sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/__tests__/kernel/InterruptKernelButton.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { InterruptKernelButton } from '../../kernel/InterruptKernelButton';
2020

2121
const fakeKernelModel = {
2222
isDone: true,
23-
interruptKernel: function(): void {
23+
interruptKernel: function (): void {
2424
// do nothing.
2525
}
2626
};

0 commit comments

Comments
 (0)