Skip to content

Commit 3d4a1f4

Browse files
fcollonvalhbcarlos
andauthored
Add logger for file editor (#145)
* Add file editor tracker * Upgrade to 4.0.0-rc.1 * Update to lab 4 * Lint --------- Co-authored-by: Carlos Herrero <[email protected]>
1 parent 4b587b7 commit 3d4a1f4

File tree

10 files changed

+642
-848
lines changed

10 files changed

+642
-848
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
uses: actions/setup-python@v4
2121
- name: Install dependencies
2222
run: |
23-
pip install jupyterlab --pre
23+
pip install jupyterlab
2424
pip install -e .
2525
jlpm
2626
- name: Run pre-commit
@@ -51,7 +51,7 @@ jobs:
5151
uses: actions/setup-python@v4
5252
- name: Install dependencies
5353
run: |
54-
pip install --pre jupyterlab
54+
pip install jupyterlab
5555
pip install -e .
5656
jlpm
5757
- name: Run Tests
@@ -79,7 +79,7 @@ jobs:
7979
- name: Install the Python dependencies
8080
run: |
8181
pip install -e ".[test]" codecov
82-
python -m pip install --pre jupyterlab
82+
python -m pip install jupyterlab
8383
- name: List installed packages
8484
run: |
8585
pip freeze
@@ -171,7 +171,7 @@ jobs:
171171
tar --strip-components=1 -zxvf *.tar.gz -C ./test
172172
cd test
173173
python -m pip install ".[test]"
174-
python -m pip install --pre jupyterlab
174+
python -m pip install jupyterlab
175175
echo "::endgroup::"
176176
- name: Run Test
177177
shell: bash

binder/environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ channels:
44
- conda-forge/label/jupyterlab_rc
55
- nodefaults
66
dependencies:
7-
- jupyterlab >=4.0.0rc0
7+
- jupyterlab >=4.0.0
88
- jupyterlab-link-share >=0.2
99
- nodejs >=18,<19
1010
- python >=3.11,<3.12

packages/collaboration-extension/package.json

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,29 @@
5555
"dependencies": {
5656
"@jupyter/collaboration": "^1.0.0-alpha.8",
5757
"@jupyter/docprovider": "^1.0.0-alpha.8",
58-
"@jupyterlab/application": "^4.0.0-rc.0",
59-
"@jupyterlab/apputils": "^4.0.0-rc.0",
60-
"@jupyterlab/codemirror": "^4.0.0-rc.0",
61-
"@jupyterlab/coreutils": "^6.0.0-rc.0",
62-
"@jupyterlab/filebrowser": "^4.0.0-rc.0",
63-
"@jupyterlab/logconsole": "^4.0.0-rc.0",
64-
"@jupyterlab/notebook": "^4.0.0-rc.0",
65-
"@jupyterlab/services": "^7.0.0-rc.0",
66-
"@jupyterlab/settingregistry": "^4.0.0-rc.0",
67-
"@jupyterlab/statedb": "^4.0.0-rc.0",
68-
"@jupyterlab/translation": "^4.0.0-rc.0",
69-
"@jupyterlab/ui-components": "^4.0.0-rc.0",
58+
"@jupyterlab/application": "^4.0.0",
59+
"@jupyterlab/apputils": "^4.0.0",
60+
"@jupyterlab/codemirror": "^4.0.0",
61+
"@jupyterlab/coreutils": "^6.0.0",
62+
"@jupyterlab/docregistry": "^4.0.0",
63+
"@jupyterlab/filebrowser": "^4.0.0",
64+
"@jupyterlab/fileeditor": "^4.0.0",
65+
"@jupyterlab/logconsole": "^4.0.0",
66+
"@jupyterlab/notebook": "^4.0.0",
67+
"@jupyterlab/services": "^7.0.0",
68+
"@jupyterlab/settingregistry": "^4.0.0",
69+
"@jupyterlab/statedb": "^4.0.0",
70+
"@jupyterlab/translation": "^4.0.0",
71+
"@jupyterlab/ui-components": "^4.0.0",
7072
"@lumino/commands": "^2.1.0",
7173
"@lumino/widgets": "^2.1.0",
7274
"y-protocols": "^1.0.5",
7375
"y-websocket": "^1.3.15",
7476
"yjs": "^13.5.40"
7577
},
7678
"devDependencies": {
77-
"@jupyterlab/builder": "^4.0.0-rc.0",
78-
"@types/react": "^18.0.27",
79+
"@jupyterlab/builder": "^4.0.0",
80+
"@types/react": "~18.0.26",
7981
"npm-run-all": "^4.1.5",
8082
"rimraf": "^4.1.2",
8183
"typescript": "~5.0.4"

packages/collaboration-extension/src/filebrowser.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,24 @@ import {
99
JupyterFrontEnd,
1010
JupyterFrontEndPlugin
1111
} from '@jupyterlab/application';
12+
import { Dialog, showDialog } from '@jupyterlab/apputils';
13+
import { IDocumentWidget } from '@jupyterlab/docregistry';
1214
import {
1315
FileBrowser,
1416
IDefaultFileBrowser,
1517
IFileBrowserFactory
1618
} from '@jupyterlab/filebrowser';
17-
import { showDialog, Dialog } from '@jupyterlab/apputils';
18-
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
19-
import { ISettingRegistry } from '@jupyterlab/settingregistry';
19+
import { IEditorTracker } from '@jupyterlab/fileeditor';
2020
import { ILogger, ILoggerRegistry } from '@jupyterlab/logconsole';
2121
import { INotebookTracker } from '@jupyterlab/notebook';
22+
import { ISettingRegistry } from '@jupyterlab/settingregistry';
23+
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
2224

2325
import { CommandRegistry } from '@lumino/commands';
2426

2527
import { YFile, YNotebook } from '@jupyter/ydoc';
2628

27-
import {
28-
ICollaborativeDrive,
29-
SharedDocumentFactory,
30-
YDrive
31-
} from '@jupyter/docprovider';
29+
import { ICollaborativeDrive, YDrive } from '@jupyter/docprovider';
3230

3331
/**
3432
* The command IDs used by the file browser plugin.
@@ -68,7 +66,7 @@ export const yfile: JupyterFrontEndPlugin<void> = {
6866
requires: [ICollaborativeDrive],
6967
optional: [],
7068
activate: (app: JupyterFrontEnd, drive: ICollaborativeDrive): void => {
71-
const yFileFactory: SharedDocumentFactory = () => {
69+
const yFileFactory = () => {
7270
return new YFile();
7371
};
7472
drive.sharedModelFactory.registerDocumentFactory('file', yFileFactory);
@@ -112,7 +110,7 @@ export const ynotebook: JupyterFrontEndPlugin<void> = {
112110
});
113111
}
114112

115-
const yNotebookFactory: SharedDocumentFactory = () => {
113+
const yNotebookFactory = () => {
116114
return new YNotebook({
117115
disableDocumentWideUndoRedo
118116
});
@@ -175,11 +173,12 @@ export const logger: JupyterFrontEndPlugin<void> = {
175173
id: '@jupyter/collaboration-extension:logger',
176174
description: 'A logging plugin for debugging purposes.',
177175
autoStart: true,
178-
optional: [ILoggerRegistry, INotebookTracker, ITranslator],
176+
optional: [ILoggerRegistry, IEditorTracker, INotebookTracker, ITranslator],
179177
activate: (
180178
app: JupyterFrontEnd,
181179
loggerRegistry: ILoggerRegistry | null,
182-
nbtracker: INotebookTracker | null,
180+
fileTracker: IEditorTracker | null,
181+
nbTracker: INotebookTracker | null,
183182
translator: ITranslator | null
184183
): void => {
185184
const trans = (translator ?? nullTranslator).load('jupyter_collaboration');
@@ -213,15 +212,21 @@ export const logger: JupyterFrontEndPlugin<void> = {
213212

214213
const loggers: Map<string, ILogger> = new Map();
215214

216-
if (nbtracker) {
217-
nbtracker.widgetAdded.connect((sender, nb) => {
218-
const logger = loggerRegistry.getLogger(nb.context.path);
219-
loggers.set(nb.context.localPath, logger);
215+
const addLogger = (sender: unknown, document: IDocumentWidget) => {
216+
const logger = loggerRegistry.getLogger(document.context.path);
217+
loggers.set(document.context.localPath, logger);
220218

221-
nb.disposed.connect(nb => {
222-
loggers.delete(nb.context.localPath);
223-
});
219+
document.disposed.connect(document => {
220+
loggers.delete(document.context.localPath);
224221
});
222+
};
223+
224+
if (fileTracker) {
225+
fileTracker.widgetAdded.connect(addLogger);
226+
}
227+
228+
if (nbTracker) {
229+
nbTracker.widgetAdded.connect(addLogger);
225230
}
226231

227232
void (async () => {

packages/collaboration/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
"dependencies": {
4242
"@codemirror/state": "^6.2.0",
4343
"@codemirror/view": "^6.7.0",
44-
"@jupyterlab/apputils": "^4.0.0-rc.0",
45-
"@jupyterlab/coreutils": "^6.0.0-rc.0",
46-
"@jupyterlab/services": "^7.0.0-rc.0",
47-
"@jupyterlab/ui-components": "^4.0.0-rc.0",
44+
"@jupyterlab/apputils": "^4.0.0",
45+
"@jupyterlab/coreutils": "^6.0.0",
46+
"@jupyterlab/services": "^7.0.0",
47+
"@jupyterlab/ui-components": "^4.0.0",
4848
"@lumino/coreutils": "^2.1.0",
4949
"@lumino/virtualdom": "^2.0.0",
5050
"@lumino/widgets": "^2.1.0",

packages/docprovider/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
},
4343
"dependencies": {
4444
"@jupyter/ydoc": "^1.0.2",
45-
"@jupyterlab/coreutils": "^6.0.0-rc.0",
46-
"@jupyterlab/services": "^7.0.0-rc.0",
45+
"@jupyterlab/coreutils": "^6.0.0",
46+
"@jupyterlab/services": "^7.0.0",
4747
"@lumino/coreutils": "^2.1.0",
4848
"@lumino/disposable": "^2.1.0",
4949
"@lumino/signaling": "^2.1.0",
@@ -52,7 +52,7 @@
5252
"yjs": "^13.5.40"
5353
},
5454
"devDependencies": {
55-
"@jupyterlab/testing": "^4.0.0-rc.0",
55+
"@jupyterlab/testing": "^4.0.0",
5656
"@types/jest": "^29.2.0",
5757
"jest": "^29.5.0",
5858
"rimraf": "^4.1.2",

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[build-system]
55
build-backend = "hatchling.build"
6-
requires = ["hatchling>=1.4.0", "hatch-nodejs-version", "jupyterlab>=4.0.0rc0"]
6+
requires = ["hatchling>=1.4.0", "hatch-nodejs-version", "jupyterlab>=4.0.0"]
77

88
[project]
99
name = "jupyter_collaboration"
@@ -48,7 +48,7 @@ test = [
4848
"pytest-cov",
4949
]
5050
docs = [
51-
"jupyterlab>=4.0.0rc0",
51+
"jupyterlab>=4.0.0",
5252
"sphinx",
5353
"myst-parser",
5454
"pydata-sphinx-theme"
@@ -114,7 +114,7 @@ before-build-python = [
114114
"jlpm clean:lib"
115115
]
116116
before-bump-version = [
117-
"python -m pip install --pre -U jupyterlab",
117+
"python -m pip install -U jupyterlab",
118118
"jlpm"
119119
]
120120

tests/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
3-

tests/test_ydoc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
33

4+
45
def test_ydoc():
56
pass

0 commit comments

Comments
 (0)