@datalayer/jupyter-react 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/cell/Cell.js +20 -22
- package/lib/components/cell/Cell.js.map +1 -1
- package/lib/components/cell/CellAdapter.d.ts +3 -0
- package/lib/components/cell/CellAdapter.js +100 -5
- package/lib/components/cell/CellAdapter.js.map +1 -1
- package/lib/components/cell/CellCommands.d.ts +2 -2
- package/lib/components/cell/CellCommands.js +2 -2
- package/lib/components/cell/CellCommands.js.map +1 -1
- package/lib/components/cell/CellState.d.ts +17 -8
- package/lib/components/cell/CellState.js +57 -6
- package/lib/components/cell/CellState.js.map +1 -1
- package/lib/components/codemirror/CodeMirrorEditor.js +7 -13
- package/lib/components/codemirror/CodeMirrorEditor.js.map +1 -1
- package/lib/components/kernel/Kernelndicator.d.ts +7 -5
- package/lib/components/kernel/Kernelndicator.js +8 -8
- package/lib/components/kernel/Kernelndicator.js.map +1 -1
- package/lib/components/kernel/inspector/widget.js +3 -3
- package/lib/components/kernel/inspector/widget.js.map +1 -1
- package/lib/components/notebook/NotebookAdapter.js +1 -1
- package/lib/components/notebook/cell/metadata/CellMetadataEditor.js +23 -8
- package/lib/components/notebook/cell/metadata/CellMetadataEditor.js.map +1 -1
- package/lib/components/notebook/cell/metadata/NbGraderCells.js +4 -4
- package/lib/components/notebook/cell/metadata/NbGraderCells.js.map +1 -1
- package/lib/components/output/Output.d.ts +5 -4
- package/lib/components/output/Output.js +52 -39
- package/lib/components/output/Output.js.map +1 -1
- package/lib/components/output/OutputAdapter.d.ts +3 -2
- package/lib/components/output/OutputAdapter.js +9 -6
- package/lib/components/output/OutputAdapter.js.map +1 -1
- package/lib/components/output/OutputExecutor.d.ts +8 -0
- package/lib/components/output/OutputExecutor.js +28 -0
- package/lib/components/output/OutputExecutor.js.map +1 -0
- package/lib/components/output/OutputState.d.ts +23 -41
- package/lib/components/output/OutputState.js +53 -45
- package/lib/components/output/OutputState.js.map +1 -1
- package/lib/examples/All.js +5 -6
- package/lib/examples/All.js.map +1 -1
- package/lib/examples/Cell.js +16 -11
- package/lib/examples/Cell.js.map +1 -1
- package/lib/examples/CellExecuteControl.d.ts +1 -0
- package/lib/examples/CellExecuteControl.js +38 -0
- package/lib/examples/CellExecuteControl.js.map +1 -0
- package/lib/examples/Cells.js +1 -1
- package/lib/examples/Cells.js.map +1 -1
- package/lib/examples/KernelExecute.d.ts +1 -0
- package/lib/examples/{KernelExecResult.js → KernelExecute.js} +5 -5
- package/lib/examples/KernelExecute.js.map +1 -0
- package/lib/examples/KernelExecutor.js +3 -3
- package/lib/examples/KernelExecutor.js.map +1 -1
- package/lib/examples/NotebookInit.js +0 -1
- package/lib/examples/NotebookInit.js.map +1 -1
- package/lib/examples/NotebookKernelChange.js +0 -1
- package/lib/examples/NotebookKernelChange.js.map +1 -1
- package/lib/examples/NotebookUnmount.js +0 -1
- package/lib/examples/NotebookUnmount.js.map +1 -1
- package/lib/examples/Output.js +52 -13
- package/lib/examples/Output.js.map +1 -1
- package/lib/jupyter/kernel/Kernel.d.ts +8 -3
- package/lib/jupyter/kernel/Kernel.js +10 -9
- package/lib/jupyter/kernel/Kernel.js.map +1 -1
- package/lib/jupyter/kernel/KernelExecutor.d.ts +17 -10
- package/lib/jupyter/kernel/KernelExecutor.js +82 -63
- package/lib/jupyter/kernel/KernelExecutor.js.map +1 -1
- package/lib/jupyter/kernel/KernelState.d.ts +25 -0
- package/lib/jupyter/kernel/KernelState.js +56 -0
- package/lib/jupyter/kernel/KernelState.js.map +1 -0
- package/lib/state/State.d.ts +10 -10
- package/lib/state/State.js +10 -12
- package/lib/state/State.js.map +1 -1
- package/lib/utils/Utils.d.ts +1 -0
- package/lib/utils/Utils.js +4 -0
- package/lib/utils/Utils.js.map +1 -1
- package/package.json +2 -1
- package/lib/examples/KernelExecResult.d.ts +0 -1
- package/lib/examples/KernelExecResult.js.map +0 -1
package/lib/examples/Output.js
CHANGED
|
@@ -4,13 +4,18 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
4
4
|
*
|
|
5
5
|
* MIT License
|
|
6
6
|
*/
|
|
7
|
+
import { useEffect, useState } from 'react';
|
|
7
8
|
import { createRoot } from 'react-dom/client';
|
|
8
|
-
import { Text } from '@primer/react';
|
|
9
|
-
import {
|
|
9
|
+
import { Box, Text } from '@primer/react';
|
|
10
|
+
import { useOutputsStore } from './../components/output/OutputState';
|
|
10
11
|
import { useJupyter } from '../jupyter/JupyterContext';
|
|
11
|
-
import Jupyter from '../jupyter/Jupyter';
|
|
12
|
-
import
|
|
13
|
-
|
|
12
|
+
import { Jupyter } from '../jupyter/Jupyter';
|
|
13
|
+
import { Kernel } from '../jupyter/kernel/Kernel';
|
|
14
|
+
import { useKernelsStore } from '../jupyter/kernel/KernelState';
|
|
15
|
+
import { KernelIndicator } from '../components/kernel/Kernelndicator';
|
|
16
|
+
import { newUuid } from '../utils/Utils';
|
|
17
|
+
import { Output } from '../components/output/Output';
|
|
18
|
+
const SOURCE_ID_1 = 'output-id-1';
|
|
14
19
|
const OUTPUTS_1 = [
|
|
15
20
|
{
|
|
16
21
|
data: {
|
|
@@ -21,7 +26,7 @@ const OUTPUTS_1 = [
|
|
|
21
26
|
output_type: 'execute_result',
|
|
22
27
|
},
|
|
23
28
|
];
|
|
24
|
-
const SOURCE_ID_2 = '2';
|
|
29
|
+
const SOURCE_ID_2 = 'output-id-2';
|
|
25
30
|
const SOURCE_2 = '2+2';
|
|
26
31
|
const OUTPUTS_2 = [
|
|
27
32
|
{
|
|
@@ -33,19 +38,53 @@ const OUTPUTS_2 = [
|
|
|
33
38
|
output_type: 'execute_result',
|
|
34
39
|
},
|
|
35
40
|
];
|
|
41
|
+
const SOURCE_ID_3 = 'output-id-3';
|
|
42
|
+
const SOURCE_3 = 'x=2';
|
|
43
|
+
const OUTPUTS_3 = [
|
|
44
|
+
{
|
|
45
|
+
data: {
|
|
46
|
+
'text/plain': ['2'],
|
|
47
|
+
},
|
|
48
|
+
execution_count: 1,
|
|
49
|
+
metadata: {},
|
|
50
|
+
output_type: 'execute_result',
|
|
51
|
+
},
|
|
52
|
+
];
|
|
36
53
|
const OutputWithoutEditor = () => {
|
|
37
|
-
const outputStore =
|
|
38
|
-
console.log('Outputs 1', outputStore.
|
|
39
|
-
return (_jsxs(_Fragment, { children: [_jsx(Text, { as: "h1", children: "Output without Code Editor" }), _jsx(Output, {
|
|
54
|
+
const outputStore = useOutputsStore();
|
|
55
|
+
console.log('Outputs 1', outputStore.getModel(SOURCE_ID_1)?.toJSON(), outputStore.getInput(SOURCE_ID_1));
|
|
56
|
+
return (_jsxs(_Fragment, { children: [_jsx(Text, { as: "h1", children: "Output without Code Editor" }), _jsx(Output, { autoRun: false, id: SOURCE_ID_1, outputs: OUTPUTS_1, showEditor: false })] }));
|
|
40
57
|
};
|
|
41
58
|
const OutputWithEditor = () => {
|
|
42
59
|
const { defaultKernel } = useJupyter();
|
|
43
|
-
const outputStore =
|
|
44
|
-
console.log('Outputs 2', outputStore.
|
|
45
|
-
return (_jsxs(_Fragment, { children: [_jsx(Text, { as: "h1", children: "Output with Code Editor" }), _jsx(Output, {
|
|
60
|
+
const outputStore = useOutputsStore();
|
|
61
|
+
console.log('Outputs 2', outputStore.getModel(SOURCE_ID_2)?.toJSON(), outputStore.getInput(SOURCE_ID_2));
|
|
62
|
+
return (_jsxs(_Fragment, { children: [_jsx(Text, { as: "h1", children: "Output with Code Editor" }), _jsx(Output, { autoRun: false, code: SOURCE_2, id: SOURCE_ID_2, kernel: defaultKernel, outputs: OUTPUTS_2, showEditor: true })] }));
|
|
63
|
+
};
|
|
64
|
+
const OutputWithEmptyOutput = () => {
|
|
65
|
+
const { kernelManager, serviceManager } = useJupyter();
|
|
66
|
+
const outputStore = useOutputsStore();
|
|
67
|
+
const kernelsStore = useKernelsStore();
|
|
68
|
+
const [kernel, setKernel] = useState();
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (serviceManager && kernelManager) {
|
|
71
|
+
const kernel = new Kernel({
|
|
72
|
+
kernelManager,
|
|
73
|
+
kernelName: 'kernel-example',
|
|
74
|
+
kernelSpecName: 'python',
|
|
75
|
+
kernelspecsManager: serviceManager.kernelspecs,
|
|
76
|
+
path: newUuid(),
|
|
77
|
+
sessionManager: serviceManager.sessions,
|
|
78
|
+
});
|
|
79
|
+
setKernel(kernel);
|
|
80
|
+
}
|
|
81
|
+
}, [serviceManager, kernelManager]);
|
|
82
|
+
console.log('Outputs 3', outputStore.getModel(SOURCE_ID_3)?.toJSON(), outputStore.getInput(SOURCE_ID_3));
|
|
83
|
+
return (_jsxs(_Fragment, { children: [_jsx(Text, { as: "h1", children: "Output with empty Output" }), kernel &&
|
|
84
|
+
_jsxs(_Fragment, { children: [_jsxs(Box, { children: ["Kernel State: ", kernelsStore.getExecutionState(kernel.id)] }), _jsxs(Box, { children: ["Kernel Phase: ", kernelsStore.getExecutionPhase(kernel.id)] }), _jsx(Box, { children: _jsx(KernelIndicator, { kernel: kernel.connection }) }), _jsx(Box, { children: _jsx(Output, { autoRun: false, code: SOURCE_3, id: SOURCE_ID_3, kernel: kernel, outputs: OUTPUTS_3, showEditor: true }) })] })] }));
|
|
46
85
|
};
|
|
47
86
|
const div = document.createElement('div');
|
|
48
87
|
document.body.appendChild(div);
|
|
49
88
|
const root = createRoot(div);
|
|
50
|
-
root.render(_jsxs(Jupyter, { children: [_jsx(OutputWithoutEditor, {}), _jsx(OutputWithEditor, {})] }));
|
|
89
|
+
root.render(_jsxs(Jupyter, { children: [_jsx(OutputWithoutEditor, {}), _jsx(OutputWithEditor, {}), _jsx(OutputWithEmptyOutput, {})] }));
|
|
51
90
|
//# sourceMappingURL=Output.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Output.js","sourceRoot":"","sources":["../../src/examples/Output.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,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EACd,EAAE,EAAE,WAAW,EACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,SAAS,EAClB,UAAU,EAAE,IAAI,GAChB,GACE,IACL,IAEJ,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC1C,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;AAC/B,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;AAE7B,IAAI,CAAC,MAAM,CACT,MAAC,OAAO,eACN,KAAC,mBAAmB,KAAG,EACvB,KAAC,gBAAgB,KAAG,EACpB,KAAC,qBAAqB,KAAG,IACjB,CACX,CAAC"}
|
|
@@ -43,13 +43,14 @@ export declare class Kernel {
|
|
|
43
43
|
* outputs model to populate and execution options
|
|
44
44
|
* @returns The kernel executor
|
|
45
45
|
*/
|
|
46
|
-
execute(code: string, { iopubMessageHooks, shellMessageHooks,
|
|
46
|
+
execute(code: string, { model, iopubMessageHooks, shellMessageHooks, silent, stopOnError, storeHistory, allowStdin, }?: {
|
|
47
|
+
model?: IOutputAreaModel;
|
|
47
48
|
iopubMessageHooks?: IOPubMessageHook[];
|
|
48
49
|
shellMessageHooks?: ShellMessageHook[];
|
|
49
|
-
model?: IOutputAreaModel;
|
|
50
50
|
silent?: boolean;
|
|
51
51
|
stopOnError?: boolean;
|
|
52
52
|
storeHistory?: boolean;
|
|
53
|
+
allowStdin?: boolean;
|
|
53
54
|
}): KernelExecutor | undefined;
|
|
54
55
|
/**
|
|
55
56
|
* Interrupt the kernel
|
|
@@ -83,6 +84,10 @@ export declare namespace Kernel {
|
|
|
83
84
|
* Kernel options
|
|
84
85
|
*/
|
|
85
86
|
type IKernelProps = {
|
|
87
|
+
/**
|
|
88
|
+
* A path
|
|
89
|
+
*/
|
|
90
|
+
path?: string;
|
|
86
91
|
/**
|
|
87
92
|
* Kernel manager
|
|
88
93
|
*/
|
|
@@ -102,7 +107,7 @@ export declare namespace Kernel {
|
|
|
102
107
|
/**
|
|
103
108
|
* Kernel type
|
|
104
109
|
*/
|
|
105
|
-
kernelType
|
|
110
|
+
kernelType?: 'notebook' | 'file' | undefined;
|
|
106
111
|
/**
|
|
107
112
|
* Session manager
|
|
108
113
|
*/
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
6
|
import { find } from '@lumino/algorithm';
|
|
7
|
-
import { PromiseDelegate
|
|
8
|
-
import { getCookie } from '../../utils/Utils';
|
|
7
|
+
import { PromiseDelegate } from '@lumino/coreutils';
|
|
8
|
+
import { getCookie, newUuid } from '../../utils/Utils';
|
|
9
9
|
import KernelExecutor from './KernelExecutor';
|
|
10
10
|
const JUPYTER_REACT_PATH_COOKIE_NAME = 'jupyter-react-kernel-path';
|
|
11
11
|
/**
|
|
@@ -28,17 +28,17 @@ export class Kernel {
|
|
|
28
28
|
_sessionId;
|
|
29
29
|
_sessionManager;
|
|
30
30
|
constructor(props) {
|
|
31
|
-
const { kernelManager, kernelName, kernelType, kernelspecsManager, kernelSpecName, kernelModel, sessionManager, } = props;
|
|
31
|
+
const { kernelManager, kernelName, kernelType, kernelspecsManager, kernelSpecName, kernelModel, path, sessionManager, } = props;
|
|
32
32
|
this._kernelSpecManager = kernelspecsManager;
|
|
33
33
|
this._kernelManager = kernelManager;
|
|
34
34
|
this._kernelName = kernelName;
|
|
35
|
-
this._kernelType = kernelType;
|
|
35
|
+
this._kernelType = kernelType ?? 'notebook';
|
|
36
36
|
this._kernelSpecName = kernelSpecName;
|
|
37
37
|
this._sessionManager = sessionManager;
|
|
38
38
|
this._ready = new PromiseDelegate();
|
|
39
|
-
this.requestKernel(kernelModel);
|
|
39
|
+
this.requestKernel(kernelModel, path);
|
|
40
40
|
}
|
|
41
|
-
async requestKernel(kernelModel) {
|
|
41
|
+
async requestKernel(kernelModel, propsPath) {
|
|
42
42
|
await this._kernelManager.ready;
|
|
43
43
|
await this._sessionManager.ready;
|
|
44
44
|
if (kernelModel) {
|
|
@@ -52,9 +52,9 @@ export class Kernel {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
|
-
let path = getCookie(this.cookieName);
|
|
55
|
+
let path = propsPath ?? getCookie(this.cookieName);
|
|
56
56
|
if (!path) {
|
|
57
|
-
path = 'kernel-' +
|
|
57
|
+
path = 'kernel-' + newUuid();
|
|
58
58
|
document.cookie = this.cookieName + '=' + path;
|
|
59
59
|
}
|
|
60
60
|
this._path = path;
|
|
@@ -138,7 +138,7 @@ export class Kernel {
|
|
|
138
138
|
* outputs model to populate and execution options
|
|
139
139
|
* @returns The kernel executor
|
|
140
140
|
*/
|
|
141
|
-
execute(code, { iopubMessageHooks = [], shellMessageHooks = [],
|
|
141
|
+
execute(code, { model, iopubMessageHooks = [], shellMessageHooks = [], silent, stopOnError, storeHistory, allowStdin, } = {}) {
|
|
142
142
|
if (this._kernelConnection) {
|
|
143
143
|
const kernelExecutor = new KernelExecutor({
|
|
144
144
|
connection: this._kernelConnection,
|
|
@@ -150,6 +150,7 @@ export class Kernel {
|
|
|
150
150
|
silent,
|
|
151
151
|
stopOnError,
|
|
152
152
|
storeHistory,
|
|
153
|
+
allowStdin,
|
|
153
154
|
});
|
|
154
155
|
return kernelExecutor;
|
|
155
156
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Kernel.js","sourceRoot":"","sources":["../../../src/jupyter/kernel/Kernel.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"Kernel.js","sourceRoot":"","sources":["../../../src/jupyter/kernel/Kernel.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE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QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC;QACvC,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,KAAK;YAChB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,UAAU,EAAE,IAAI,CAAC,IAAI;SACtB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,MAAM,IAAI,CAAC,EAAE,gBAAgB,IAAI,CAAC,QAAQ,iBAAiB,IAAI,CAAC,SAAS,WAAW,IAAI,CAAC,KAAK,EAAE,CAAC;IAC1G,CAAC;CACF;AA0CD,eAAe,MAAM,CAAC"}
|
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import { ISignal } from '@lumino/signaling';
|
|
2
2
|
import { IOutput } from '@jupyterlab/nbformat';
|
|
3
3
|
import { IOutputAreaModel } from '@jupyterlab/outputarea';
|
|
4
|
-
import { Kernel, KernelMessage } from '@jupyterlab/services';
|
|
4
|
+
import { Kernel as JupyterKernel, KernelMessage } from '@jupyterlab/services';
|
|
5
5
|
export type IOPubMessageHook = (msg: KernelMessage.IIOPubMessage) => boolean | PromiseLike<boolean>;
|
|
6
6
|
export type ShellMessageHook = (msg: KernelMessage.IShellMessage) => boolean | PromiseLike<boolean>;
|
|
7
7
|
/**
|
|
8
8
|
* KernelExecutor options
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type IKernelExecutorOptions = {
|
|
11
11
|
/**
|
|
12
12
|
* Kernel connection
|
|
13
13
|
*/
|
|
14
|
-
connection:
|
|
14
|
+
connection: JupyterKernel.IKernelConnection;
|
|
15
15
|
/**
|
|
16
16
|
* Outputs model to populate with the execution results.
|
|
17
17
|
*/
|
|
18
18
|
model?: IOutputAreaModel;
|
|
19
|
-
}
|
|
19
|
+
};
|
|
20
20
|
export declare class KernelExecutor {
|
|
21
|
+
private _executed;
|
|
21
22
|
private _kernelConnection;
|
|
22
|
-
private
|
|
23
|
-
private _outputsChanged;
|
|
23
|
+
private _kernelState;
|
|
24
24
|
private _model;
|
|
25
25
|
private _modelChanged;
|
|
26
|
+
private _outputs;
|
|
27
|
+
private _stopOnError;
|
|
28
|
+
private _outputsChanged;
|
|
26
29
|
private _future?;
|
|
27
30
|
private _shellMessageHooks;
|
|
28
|
-
private _executed;
|
|
29
31
|
constructor({ connection, model }: IKernelExecutorOptions);
|
|
30
32
|
/**
|
|
31
33
|
* Execute a code snippet.
|
|
@@ -42,20 +44,23 @@ export declare class KernelExecutor {
|
|
|
42
44
|
* const outputs = await executor.execute("print('hello')");
|
|
43
45
|
* ```
|
|
44
46
|
*/
|
|
45
|
-
execute(code: string, { iopubMessageHooks, shellMessageHooks, silent, stopOnError, storeHistory, }?: {
|
|
47
|
+
execute(code: string, { iopubMessageHooks, shellMessageHooks, silent, stopOnError, storeHistory, allowStdin, }?: {
|
|
46
48
|
iopubMessageHooks?: IOPubMessageHook[];
|
|
47
49
|
shellMessageHooks?: ShellMessageHook[];
|
|
48
50
|
silent?: boolean;
|
|
49
51
|
stopOnError?: boolean;
|
|
50
52
|
storeHistory?: boolean;
|
|
53
|
+
allowStdin?: boolean;
|
|
51
54
|
}): Promise<IOutputAreaModel>;
|
|
52
55
|
/**
|
|
53
56
|
* Clear the kernel executor previous results.
|
|
54
57
|
*/
|
|
55
58
|
clear(): void;
|
|
56
|
-
private _onIOPub;
|
|
57
|
-
private _onReply;
|
|
58
59
|
registerIOPubMessageHook: (msg: IOPubMessageHook) => void;
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
get future(): JupyterKernel.IFuture<KernelMessage.IExecuteRequestMsg, KernelMessage.IExecuteReplyMsg> | undefined;
|
|
59
64
|
/**
|
|
60
65
|
* Promise that resolves when the execution is done.
|
|
61
66
|
*/
|
|
@@ -80,5 +85,7 @@ export declare class KernelExecutor {
|
|
|
80
85
|
* Signal emitted when the outputs model changes.
|
|
81
86
|
*/
|
|
82
87
|
get modelChanged(): ISignal<KernelExecutor, IOutputAreaModel>;
|
|
88
|
+
private _onIOPub;
|
|
89
|
+
private _onReply;
|
|
83
90
|
}
|
|
84
91
|
export default KernelExecutor;
|
|
@@ -6,21 +6,27 @@
|
|
|
6
6
|
import { PromiseDelegate } from '@lumino/coreutils';
|
|
7
7
|
import { Signal } from '@lumino/signaling';
|
|
8
8
|
import { OutputAreaModel } from '@jupyterlab/outputarea';
|
|
9
|
+
import { KernelMessage } from '@jupyterlab/services';
|
|
9
10
|
import { outputsAsString } from '../../utils/Utils';
|
|
11
|
+
import { ExecutionPhase, kernelsStore } from './KernelState';
|
|
12
|
+
import { toKernelState } from '../../components/kernel';
|
|
10
13
|
export class KernelExecutor {
|
|
14
|
+
_executed;
|
|
11
15
|
_kernelConnection;
|
|
12
|
-
|
|
13
|
-
_outputsChanged = new Signal(this);
|
|
16
|
+
_kernelState;
|
|
14
17
|
_model;
|
|
15
18
|
_modelChanged = new Signal(this);
|
|
19
|
+
_outputs;
|
|
20
|
+
_stopOnError;
|
|
21
|
+
_outputsChanged = new Signal(this);
|
|
16
22
|
_future;
|
|
17
23
|
_shellMessageHooks = new Array();
|
|
18
|
-
_executed;
|
|
19
24
|
constructor({ connection, model }) {
|
|
25
|
+
this._executed = new PromiseDelegate();
|
|
20
26
|
this._kernelConnection = connection;
|
|
21
|
-
this._outputs = [];
|
|
22
27
|
this._model = model ?? new OutputAreaModel();
|
|
23
|
-
this.
|
|
28
|
+
this._outputs = [];
|
|
29
|
+
this._kernelState = kernelsStore.getState();
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
26
32
|
* Execute a code snippet.
|
|
@@ -37,28 +43,29 @@ export class KernelExecutor {
|
|
|
37
43
|
* const outputs = await executor.execute("print('hello')");
|
|
38
44
|
* ```
|
|
39
45
|
*/
|
|
40
|
-
execute(code, { iopubMessageHooks = [], shellMessageHooks = [], silent = false, stopOnError = false, storeHistory = true, } = {}) {
|
|
46
|
+
execute(code, { iopubMessageHooks = [], shellMessageHooks = [], silent = false, stopOnError = false, storeHistory = true, allowStdin = false, } = {}) {
|
|
47
|
+
this._stopOnError = stopOnError;
|
|
41
48
|
this._shellMessageHooks = shellMessageHooks;
|
|
49
|
+
kernelsStore.getState().setExecutionPhase(this._kernelConnection.id, ExecutionPhase.running);
|
|
42
50
|
this._future = this._kernelConnection.requestExecute({
|
|
43
51
|
code,
|
|
44
|
-
allow_stdin:
|
|
52
|
+
allow_stdin: allowStdin,
|
|
45
53
|
silent,
|
|
46
54
|
stop_on_error: stopOnError,
|
|
47
55
|
store_history: storeHistory,
|
|
48
56
|
});
|
|
49
|
-
iopubMessageHooks.forEach(hook => this._future.registerMessageHook(hook));
|
|
50
57
|
this._future.onIOPub = this._onIOPub;
|
|
51
58
|
this._future.onReply = this._onReply;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
iopubMessageHooks.forEach(hook => this._future.registerMessageHook(hook));
|
|
60
|
+
this._future.onStdin = msg => {
|
|
61
|
+
if (KernelMessage.isInputRequestMsg(msg)) {
|
|
62
|
+
// FIXME Implement this.
|
|
63
|
+
// this.onInputRequest(msg, value);
|
|
64
|
+
}
|
|
58
65
|
};
|
|
59
|
-
|
|
60
|
-
// Wait for future to be done before resolving.
|
|
66
|
+
// Wait for future to be done before resolving the exectud promise.
|
|
61
67
|
this._future.done.then(() => {
|
|
68
|
+
kernelsStore.getState().setExecutionPhase(this._kernelConnection.id, ExecutionPhase.completed);
|
|
62
69
|
this._executed.resolve(this._model);
|
|
63
70
|
});
|
|
64
71
|
return this._executed.promise;
|
|
@@ -71,10 +78,61 @@ export class KernelExecutor {
|
|
|
71
78
|
this._outputs.length = 0;
|
|
72
79
|
this._model.clear();
|
|
73
80
|
}
|
|
81
|
+
registerIOPubMessageHook = (msg) => {
|
|
82
|
+
this._future?.registerMessageHook(msg);
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
*/
|
|
87
|
+
get future() {
|
|
88
|
+
return this._future;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Promise that resolves when the execution is done.
|
|
92
|
+
*/
|
|
93
|
+
get done() {
|
|
94
|
+
return this._executed.promise.then(() => {
|
|
95
|
+
return;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Code execution result as serialized JSON
|
|
100
|
+
*/
|
|
101
|
+
get result() {
|
|
102
|
+
return this._executed.promise.then(model => {
|
|
103
|
+
return outputsAsString(model.toJSON());
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Kernel outputs emitted.
|
|
108
|
+
*/
|
|
109
|
+
get outputs() {
|
|
110
|
+
return this._outputs;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Kernel outputs wrapped in a model.
|
|
114
|
+
*/
|
|
115
|
+
get model() {
|
|
116
|
+
return this._model;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Signal emitted when the outputs list changes.
|
|
120
|
+
*/
|
|
121
|
+
get outputsChanged() {
|
|
122
|
+
0;
|
|
123
|
+
return this._outputsChanged;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Signal emitted when the outputs model changes.
|
|
127
|
+
*/
|
|
128
|
+
get modelChanged() {
|
|
129
|
+
return this._modelChanged;
|
|
130
|
+
}
|
|
74
131
|
_onIOPub = (message) => {
|
|
75
132
|
if (this._future?.msg.header.msg_id !== message.parent_header.msg_id) {
|
|
76
133
|
return;
|
|
77
134
|
}
|
|
135
|
+
console.debug('Kernel IOPub message', message);
|
|
78
136
|
const messageType = message.header.msg_type;
|
|
79
137
|
const output = { ...message.content, output_type: messageType };
|
|
80
138
|
switch (messageType) {
|
|
@@ -96,6 +154,9 @@ export class KernelExecutor {
|
|
|
96
154
|
this._outputsChanged.emit(this._outputs);
|
|
97
155
|
this._model.add(output);
|
|
98
156
|
this._modelChanged.emit(this._model);
|
|
157
|
+
if (this._stopOnError) {
|
|
158
|
+
kernelsStore.getState().setExecutionPhase(this._kernelConnection.id, ExecutionPhase.completed_with_error);
|
|
159
|
+
}
|
|
99
160
|
break;
|
|
100
161
|
case 'clear_output':
|
|
101
162
|
const wait = message.content.wait;
|
|
@@ -109,9 +170,10 @@ export class KernelExecutor {
|
|
|
109
170
|
this._modelChanged.emit(this._model);
|
|
110
171
|
break;
|
|
111
172
|
case 'status':
|
|
112
|
-
// execution_state: 'busy' 'starting' 'terminating' 'restarting' 'initializing' 'connecting' 'disconnected' 'dead' 'unknown' 'idle'
|
|
113
173
|
const executionState = message.content.execution_state;
|
|
114
|
-
|
|
174
|
+
const connectionStatus = this._kernelConnection.connectionStatus;
|
|
175
|
+
const kernelState = toKernelState(connectionStatus, executionState);
|
|
176
|
+
this._kernelState.setExecutionState(this._kernelConnection.id, kernelState);
|
|
115
177
|
break;
|
|
116
178
|
default:
|
|
117
179
|
break;
|
|
@@ -121,6 +183,7 @@ export class KernelExecutor {
|
|
|
121
183
|
if (this._future?.msg.header.msg_id !== message.parent_header.msg_id) {
|
|
122
184
|
return;
|
|
123
185
|
}
|
|
186
|
+
console.debug('Kernel Reply message', message);
|
|
124
187
|
this._shellMessageHooks.forEach(hook => hook(message));
|
|
125
188
|
const content = message.content;
|
|
126
189
|
if (content.status !== 'ok') {
|
|
@@ -130,7 +193,7 @@ export class KernelExecutor {
|
|
|
130
193
|
break;
|
|
131
194
|
case 'error':
|
|
132
195
|
{
|
|
133
|
-
const { ename, evalue, traceback } = content
|
|
196
|
+
const { ename, evalue, traceback } = content;
|
|
134
197
|
this._executed.reject(`${ename}: ${evalue}\n${(traceback ?? []).join('\n')}`);
|
|
135
198
|
}
|
|
136
199
|
break;
|
|
@@ -157,50 +220,6 @@ export class KernelExecutor {
|
|
|
157
220
|
}
|
|
158
221
|
}
|
|
159
222
|
};
|
|
160
|
-
registerIOPubMessageHook = (msg) => {
|
|
161
|
-
this._future?.registerMessageHook(msg);
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Promise that resolves when the execution is done.
|
|
165
|
-
*/
|
|
166
|
-
get done() {
|
|
167
|
-
return this._executed.promise.then(() => {
|
|
168
|
-
return;
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Code execution result as serialized JSON
|
|
173
|
-
*/
|
|
174
|
-
get result() {
|
|
175
|
-
return this._executed.promise.then(model => {
|
|
176
|
-
return outputsAsString(model.toJSON());
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Kernel outputs emitted.
|
|
181
|
-
*/
|
|
182
|
-
get outputs() {
|
|
183
|
-
return this._outputs;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Kernel outputs wrapped in a model.
|
|
187
|
-
*/
|
|
188
|
-
get model() {
|
|
189
|
-
return this._model;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Signal emitted when the outputs list changes.
|
|
193
|
-
*/
|
|
194
|
-
get outputsChanged() {
|
|
195
|
-
0;
|
|
196
|
-
return this._outputsChanged;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Signal emitted when the outputs model changes.
|
|
200
|
-
*/
|
|
201
|
-
get modelChanged() {
|
|
202
|
-
return this._modelChanged;
|
|
203
|
-
}
|
|
204
223
|
}
|
|
205
224
|
export default KernelExecutor;
|
|
206
225
|
//# sourceMappingURL=KernelExecutor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KernelExecutor.js","sourceRoot":"","sources":["../../../src/jupyter/kernel/KernelExecutor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EA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,WAAW,EAAE,cAAc;oBAC3B,IAAI,EAAG,IAAY,CAAC,IAAmB;oBACvC,QAAQ,EAAE,EAAE;iBACb,CAAC;gBACF,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAC3B,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACzC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBACxB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACtC;SACF;IACH,CAAC,CAAC;CAEH;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ExecutionState } from './../../components/kernel/Kernelndicator';
|
|
2
|
+
export declare enum ExecutionPhase {
|
|
3
|
+
ready_to_run = "READY_TO_RUN",
|
|
4
|
+
running = "RUNNING",
|
|
5
|
+
completed = "COMPLETED",
|
|
6
|
+
completed_with_error = "COMPLETED_WITH_ERROR"
|
|
7
|
+
}
|
|
8
|
+
export type IKernelState = {
|
|
9
|
+
id: string;
|
|
10
|
+
executionState?: ExecutionState;
|
|
11
|
+
executionPhase?: ExecutionPhase;
|
|
12
|
+
};
|
|
13
|
+
export interface IKernelsState {
|
|
14
|
+
kernels: Map<string, IKernelState>;
|
|
15
|
+
}
|
|
16
|
+
export type KernelsState = IKernelsState & {
|
|
17
|
+
getExecutionState: (id: string) => ExecutionState | undefined;
|
|
18
|
+
setExecutionState: (id: string, executionState: ExecutionState) => void;
|
|
19
|
+
getExecutionPhase: (id: string) => ExecutionPhase | undefined;
|
|
20
|
+
setExecutionPhase: (id: string, executionState: ExecutionPhase) => void;
|
|
21
|
+
};
|
|
22
|
+
export declare const kernelsStore: import("zustand").StoreApi<KernelsState>;
|
|
23
|
+
export declare function useKernelsStore(): KernelsState;
|
|
24
|
+
export declare function useKernelsStore<T>(selector: (state: KernelsState) => T): T;
|
|
25
|
+
export default useKernelsStore;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-2023 Datalayer, Inc.
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { createStore } from 'zustand/vanilla';
|
|
7
|
+
import { useStore } from 'zustand';
|
|
8
|
+
export var ExecutionPhase;
|
|
9
|
+
(function (ExecutionPhase) {
|
|
10
|
+
ExecutionPhase["ready_to_run"] = "READY_TO_RUN";
|
|
11
|
+
ExecutionPhase["running"] = "RUNNING";
|
|
12
|
+
ExecutionPhase["completed"] = "COMPLETED";
|
|
13
|
+
ExecutionPhase["completed_with_error"] = "COMPLETED_WITH_ERROR";
|
|
14
|
+
})(ExecutionPhase || (ExecutionPhase = {}));
|
|
15
|
+
export const kernelsStore = createStore((set, get) => ({
|
|
16
|
+
kernels: new Map(),
|
|
17
|
+
getExecutionState: (id) => {
|
|
18
|
+
return get().kernels.get(id)?.executionState;
|
|
19
|
+
},
|
|
20
|
+
setExecutionState: (id, executionState) => {
|
|
21
|
+
const kernels = get().kernels;
|
|
22
|
+
const k = kernels.get(id);
|
|
23
|
+
if (k) {
|
|
24
|
+
k.executionState = executionState;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
kernels.set(id, {
|
|
28
|
+
id,
|
|
29
|
+
executionState: executionState
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
set((state) => ({ kernels }));
|
|
33
|
+
},
|
|
34
|
+
getExecutionPhase: (id) => {
|
|
35
|
+
return get().kernels.get(id)?.executionPhase;
|
|
36
|
+
},
|
|
37
|
+
setExecutionPhase: (id, executionPhase) => {
|
|
38
|
+
const kernels = get().kernels;
|
|
39
|
+
const k = kernels.get(id);
|
|
40
|
+
if (k) {
|
|
41
|
+
k.executionPhase = executionPhase;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
kernels.set(id, {
|
|
45
|
+
id,
|
|
46
|
+
executionPhase,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
set((state) => ({ kernels }));
|
|
50
|
+
},
|
|
51
|
+
}));
|
|
52
|
+
export function useKernelsStore(selector) {
|
|
53
|
+
return useStore(kernelsStore, selector);
|
|
54
|
+
}
|
|
55
|
+
export default useKernelsStore;
|
|
56
|
+
//# sourceMappingURL=KernelState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KernelState.js","sourceRoot":"","sources":["../../../src/jupyter/kernel/KernelState.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGnC,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,+CAA6B,CAAA;IAC7B,qCAAmB,CAAA;IACnB,yCAAuB,CAAA;IACvB,+DAA6C,CAAA;AAC/C,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB;AAmBD,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAe,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IACnE,OAAO,EAAE,IAAI,GAAG,EAAwB;IACxC,iBAAiB,EAAE,CAAC,EAAU,EAAE,EAAE;QAChC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC;IAC/C,CAAC;IACD,iBAAiB,EAAE,CAAC,EAAU,EAAE,cAA8B,EAAE,EAAE;QAChE,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC;QAC9B,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,EAAE;YACL,CAAC,CAAC,cAAc,GAAG,cAAc,CAAC;SACnC;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE;gBACd,EAAE;gBACF,cAA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