Skip to content

Commit 13f0619

Browse files
authored
Add kernel error log handler (#119)
* Add kernel log handler * Pin Lab in UI test
1 parent 92b43f7 commit 13f0619

File tree

6 files changed

+22
-4
lines changed

6 files changed

+22
-4
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ jobs:
108108
- name: Install the extension
109109
run: |
110110
set -eux
111-
python -m pip install "jupyterlab>=4.0.0,<5" glue_jupyterlab*.whl
111+
python -m pip install "jupyterlab==4.0.2" glue_jupyterlab*.whl
112112
113113
- name: Install dependencies
114114
working-directory: ui-tests

src/document/plugin.ts

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export const newFilePlugin: JupyterFrontEndPlugin<void> = {
117117
commandPalette?: ICommandPalette
118118
) => {
119119
const { commands } = app;
120+
120121
commands.addCommand(CommandIDs.createNew, {
121122
label: args => 'New Glue Session',
122123
caption: 'Create a new Glue Session',

src/leftPanel/data/dataPanel.ts

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { IDocumentManager } from '@jupyterlab/docmanager';
88
import { DatasetsWidget } from './datasetsWidget';
99
import { SubsetsWidget } from './subsetsWidget';
1010
import { IControlPanelModel } from '../../types';
11+
import { logKernelError } from '../../tools';
1112

1213
export class DataPanel extends SidePanel {
1314
constructor(options: {
@@ -53,6 +54,7 @@ export class DataPanel extends SidePanel {
5354
`;
5455

5556
const future = kernel.requestExecute({ code }, false);
57+
future.onReply = logKernelError;
5658
await future.done;
5759
}
5860
}

src/leftPanel/plugin.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ControlPanelModel } from './model';
22
import { ControlPanelWidget } from './widget';
3-
import { glueIcon } from '../tools';
3+
import { glueIcon, logKernelError } from '../tools';
44
import {
55
ILayoutRestorer,
66
JupyterFrontEnd,
@@ -243,6 +243,7 @@ function addCommands(
243243
`;
244244

245245
const future = kernel.requestExecute({ code }, false);
246+
future.onReply = logKernelError;
246247
await future.done;
247248
}
248249
});

src/tools.ts

+14
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import glueIconStr from '../style/icons/glue-icon.svg';
44
import { DocumentRegistry } from '@jupyterlab/docregistry';
55
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
66
import { Signal } from '@lumino/signaling';
7+
import { KernelMessage } from '@jupyterlab/services';
78

89
export const glueIcon = new LabIcon({
910
name: 'gluelab:glue-icon',
@@ -33,3 +34,16 @@ export function mockNotebook(
3334
};
3435
return panel;
3536
}
37+
38+
/**
39+
* Log the kernel error message to the JS console.
40+
*
41+
* @param {KernelMessage.IExecuteReplyMsg} msg
42+
*/
43+
export const logKernelError = (msg: KernelMessage.IExecuteReplyMsg): void => {
44+
const { content } = msg;
45+
if (content.status === 'error') {
46+
const { ename, evalue, traceback } = content;
47+
console.error('[Kernel Execution Error]', { ename, evalue, traceback });
48+
}
49+
};

src/viewPanel/sessionWidget.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { CommandIDs } from '../commands';
1313
import { HTabPanel } from '../common/tabPanel';
1414
import { GlueSessionModel } from '../document/docModel';
1515
import { LinkEditor } from '../linkPanel/linkEditor';
16-
import { mockNotebook } from '../tools';
16+
import { logKernelError, mockNotebook } from '../tools';
1717
import { DATASET_MIME, IDict, IGlueSessionSharedModel } from '../types';
1818
import { TabView } from './tabView';
1919

@@ -163,8 +163,8 @@ export class SessionWidget extends BoxPanel {
163163
from glue_jupyterlab.glue_session import SharedGlueSession
164164
GLUE_SESSION = SharedGlueSession("${this._context.localPath}")
165165
`;
166-
167166
const future = kernel.requestExecute({ code }, false);
167+
future.onReply = logKernelError;
168168
await future.done;
169169
this._pythonSessionCreated.resolve();
170170

0 commit comments

Comments
 (0)