Skip to content

Commit 7f5ec20

Browse files
committed
Fix file id not available for jupyter-server
Improve notebook cell server-side executor Fix for testing drive Allow to request a document from its document_id/room_id Add documentation Improve linter ignore Apply pre-commit Support long execution and (not working stdin) Add support for input
1 parent 0cc728a commit 7f5ec20

File tree

13 files changed

+399
-204
lines changed

13 files changed

+399
-204
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
**/*.d.ts
88
**/test
99
**/ui-tests
10+
**/labextension
1011

1112
docs
1213
tests

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
**/tsconfig.test.json
77
**/*.d.ts
88
**/test
9+
**/labextension
910

1011
docs
1112
tests

packages/collaboration-extension/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
},
7272
"devDependencies": {
7373
"@jupyterlab/builder": "^4.0.5",
74-
"@types/react": "~18.0.26",
74+
"@types/react": "~18.3.1",
7575
"npm-run-all": "^4.1.5",
7676
"rimraf": "^4.1.2",
7777
"typescript": "~5.0.4"

packages/collaboration/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"yjs": "^13.5.40"
5555
},
5656
"devDependencies": {
57-
"@types/react": "^18.0.27",
57+
"@types/react": "~18.3.1",
5858
"rimraf": "^4.1.2",
5959
"typescript": "~5.0.4"
6060
},

packages/docprovider-extension/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@
7070
"yjs": "^13.5.40"
7171
},
7272
"devDependencies": {
73-
"@jupyterlab/builder": "^4.0.5",
74-
"@types/react": "~18.0.26",
73+
"@jupyterlab/builder": "^4.0.0",
74+
"@types/react": "~18.3.1",
7575
"npm-run-all": "^4.1.5",
7676
"rimraf": "^4.1.2",
7777
"typescript": "~5.0.4"

packages/docprovider-extension/src/executor.ts

+5-50
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
* @module docprovider-extension
66
*/
77

8+
import { NotebookCellServerExecutor } from '@jupyter/docprovider';
89
import {
910
JupyterFrontEnd,
1011
JupyterFrontEndPlugin
1112
} from '@jupyterlab/application';
12-
import { PageConfig, URLExt } from '@jupyterlab/coreutils';
13-
import { ServerConnection } from '@jupyterlab/services';
14-
15-
import { type MarkdownCell } from '@jupyterlab/cells';
13+
import { PageConfig } from '@jupyterlab/coreutils';
1614
import { INotebookCellExecutor, runCell } from '@jupyterlab/notebook';
1715

1816
export const notebookCellExecutor: JupyterFrontEndPlugin<INotebookCellExecutor> =
@@ -24,53 +22,10 @@ export const notebookCellExecutor: JupyterFrontEndPlugin<INotebookCellExecutor>
2422
provides: INotebookCellExecutor,
2523
activate: (app: JupyterFrontEnd): INotebookCellExecutor => {
2624
if (PageConfig.getOption('serverSideExecution') === 'true') {
27-
return Object.freeze({ runCell: runCellServerSide });
25+
return new NotebookCellServerExecutor({
26+
serverSettings: app.serviceManager.serverSettings
27+
});
2828
}
2929
return Object.freeze({ runCell });
3030
}
3131
};
32-
33-
async function runCellServerSide({
34-
cell,
35-
notebook,
36-
notebookConfig,
37-
onCellExecuted,
38-
onCellExecutionScheduled,
39-
sessionContext,
40-
sessionDialogs,
41-
translator
42-
}: INotebookCellExecutor.IRunCellOptions): Promise<boolean> {
43-
switch (cell.model.type) {
44-
case 'markdown':
45-
(cell as MarkdownCell).rendered = true;
46-
cell.inputHidden = false;
47-
onCellExecuted({ cell, success: true });
48-
break;
49-
case 'code': {
50-
const kernelId = sessionContext?.session?.kernel?.id;
51-
const settings = ServerConnection.makeSettings();
52-
const apiURL = URLExt.join(
53-
settings.baseUrl,
54-
`api/kernels/${kernelId}/execute`
55-
);
56-
const cellId = cell.model.sharedModel.getId();
57-
const documentId = `json:notebook:${notebook.sharedModel.getState(
58-
'file_id'
59-
)}`;
60-
const body = `{"cell_id":"${cellId}","document_id":"${documentId}"}`;
61-
const init = {
62-
method: 'POST',
63-
body
64-
};
65-
try {
66-
await ServerConnection.makeRequest(apiURL, init, settings);
67-
} catch (error: any) {
68-
throw new ServerConnection.NetworkError(error);
69-
}
70-
break;
71-
}
72-
default:
73-
break;
74-
}
75-
return Promise.resolve(true);
76-
}

packages/docprovider/package.json

+9-3
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,23 @@
4242
},
4343
"dependencies": {
4444
"@jupyter/ydoc": "^2.0.0",
45-
"@jupyterlab/coreutils": "^6.0.5",
46-
"@jupyterlab/services": "^7.0.5",
45+
"@jupyterlab/apputils": "^4.2.0",
46+
"@jupyterlab/cells": "^4.2.0",
47+
"@jupyterlab/coreutils": "^6.2.0",
48+
"@jupyterlab/notebook": "^4.2.0",
49+
"@jupyterlab/outputarea": "^4.2.0",
50+
"@jupyterlab/services": "^7.2.0",
51+
"@jupyterlab/translation": "^4.2.0",
4752
"@lumino/coreutils": "^2.1.0",
4853
"@lumino/disposable": "^2.1.0",
4954
"@lumino/signaling": "^2.1.0",
55+
"@lumino/widgets": "^2.2.0",
5056
"y-protocols": "^1.0.5",
5157
"y-websocket": "^1.3.15",
5258
"yjs": "^13.5.40"
5359
},
5460
"devDependencies": {
55-
"@jupyterlab/testing": "^4.0.5",
61+
"@jupyterlab/testing": "^4.0.0",
5662
"@types/jest": "^29.2.0",
5763
"jest": "^29.5.0",
5864
"rimraf": "^4.1.2",

packages/docprovider/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
*/
99

1010
export * from './awareness';
11+
export * from './notebookCellExecutor';
12+
export * from './requests';
1113
export * from './ydrive';
1214
export * from './yprovider';
1315
export * from './tokens';

0 commit comments

Comments
 (0)