Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Update to JupyterLab 4.0 alpha #319

Merged
merged 19 commits into from
Jan 21, 2022
Merged

Update to JupyterLab 4.0 alpha #319

merged 19 commits into from
Jan 21, 2022

Conversation

jtpio
Copy link
Member

@jtpio jtpio commented Jan 5, 2022

Fixes #303
Fixes #299

To start checking for breaking changes, and the new packages / plugins to add to the build.

  • Update the @jupyterlab packages to next
  • Update the @lumino packages to latest
  • Fix plugins failing to activate
  • Fix notebook toolbar items not displayed

Keeping as a draft for now.

@jtpio jtpio added the enhancement New feature or request label Jan 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2022

Binder 👈 Launch a Binder on branch jtpio/retrolab/lab-4

@jtpio
Copy link
Member Author

jtpio commented Jan 5, 2022

cc @davidbrochart the build seems to be passing on CI

@davidbrochart
Copy link
Contributor

I tried pip install -e . with this branch and got:

    lerna ERR! yarn run build exited 1 in '@retrolab/lab-extension'
    lerna ERR! yarn run build stdout:
    $ jlpm run build:lib && jlpm run build:labextension:dev
    $ tsc
    src/index.ts(67,5): error TS2322: Type 'Token<IRetroShell>' is not assignable to type 'Token<any>'.
      Types have separate declarations of a private property '_tokenStructuralPropertyT'.

@jtpio
Copy link
Member Author

jtpio commented Jan 6, 2022

Strange. This seems to be building fine locally and also on Binder, which installs from source as follows:

#!/bin/bash
set -euo pipefail
python -m pip install -e .
jlpm && jlpm run build
jlpm run develop
jupyter server extension enable retrolab
jupyter serverextension enable retrolab

image

@jtpio
Copy link
Member Author

jtpio commented Jan 19, 2022

There is now a 0.3.x branch created from the 0.3.16 release commit: https://github.com/jupyterlab/retrolab/tree/0.3.x

So we can move forward with this PR and start targeting JupyterLab 4 on main.

@jtpio jtpio added this to the 0.4.0 milestone Jan 19, 2022
@jtpio
Copy link
Member Author

jtpio commented Jan 19, 2022

Still left to do: show the notebook toolbar items, which might be related to this upstream PR: jupyterlab/jupyterlab#10469

image

@davidbrochart
Copy link
Contributor

I was trying to set the option to not close terminals on exit, but adding terminal.content.setOption("closeOnExit", false); somewhere here doesn't seem to work. Any idea?

@jtpio jtpio mentioned this pull request Jan 19, 2022
7 tasks
@jtpio
Copy link
Member Author

jtpio commented Jan 20, 2022

@davidbrochart I wonder if this should be set here instead:

commands.execute('terminal:open', { name });

iirc the other plugin handles opening in a new browser tab.

@jtpio
Copy link
Member Author

jtpio commented Jan 20, 2022

Still left to do: show the notebook toolbar items, which might be related to this upstream PR: jupyterlab/jupyterlab#10469

This one looks like a race condition. Adding an artificial delay such as following seems lets the toolbar be correctly populated:

diff --git a/packages/application-extension/src/index.ts b/packages/application-extension/src/index.ts
index 109fd19..866570b 100644
--- a/packages/application-extension/src/index.ts
+++ b/packages/application-extension/src/index.ts
@@ -181,9 +181,11 @@ const opener: JupyterFrontEndPlugin<void> = {
         app.restored.then(() => {
           // TODO: get factory from file type instead?
           if (ext === '.ipynb') {
-            docManager.open(file, NOTEBOOK_FACTORY, undefined, {
-              ref: '_noref'
-            });
+            setTimeout(() => {
+              docManager.open(file, NOTEBOOK_FACTORY, undefined, {
+                ref: '_noref'
+              });
+            }, 1000);
           } else {
             docManager.open(file, EDITOR_FACTORY, undefined, {
               ref: '_noref'
toolbar-notebook-delay.mp4

@davidbrochart
Copy link
Contributor

Thanks, that was it!
I opened jtpio#4.

@jtpio
Copy link
Member Author

jtpio commented Jan 20, 2022

Nice thanks @davidbrochart!

@jtpio
Copy link
Member Author

jtpio commented Jan 20, 2022

Adding an artificial delay such as following seems lets the toolbar be correctly populated

cc @fcollonval who might know if this is related to the logic in jupyterlab/jupyterlab#10469

@jtpio
Copy link
Member Author

jtpio commented Jan 20, 2022

Using the following trick like in the toolbar.spec.ts upstream tests seems to do it:

https://github.com/jupyterlab/jupyterlab/blob/50fa0047d63287005a2c3b1d8f5bfedfe56cde7e/packages/apputils/test/toolbar.spec.ts#L304-L308

await settingRegistry?.load('@jupyterlab/notebook-extension:panel');
await Promise.resolve();

@jtpio
Copy link
Member Author

jtpio commented Jan 20, 2022

This is what the user menu dropdown looks like in RetroLab when RTC is enabled:

image

Comment on lines +186 to +188
// TODO: fix upstream?
await settingRegistry?.load('@jupyterlab/notebook-extension:panel');
await Promise.resolve();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should investigate if it is possible to fix this upstream as this is very brittle.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A toolbar definition may indeed not be fully known by the time the open is triggered as some plugins may not yet be loaded or the treatment of the settings may not be complete yet. Hence adding some sort of delay does the trick.

@jtpio jtpio marked this pull request as ready for review January 21, 2022 12:58
@jtpio
Copy link
Member Author

jtpio commented Jan 21, 2022

Merging that one since CI is now green.

Will make a 0.4.0a0 prerelease with this right after.

@jtpio
Copy link
Member Author

jtpio commented Jan 21, 2022

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update to JupyterLab 4.0 Exiting terminal doesn't close window tab
3 participants