From 1703ba3e1b9a347b70fe5898e107b169bc7e815a Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Tue, 10 Oct 2023 08:21:06 -0500 Subject: [PATCH 1/9] try patching mathjax if missing from window --- python/jupyterlab_widgets/src/manager.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/python/jupyterlab_widgets/src/manager.ts b/python/jupyterlab_widgets/src/manager.ts index 9ee14d76fc..f853695e22 100644 --- a/python/jupyterlab_widgets/src/manager.ts +++ b/python/jupyterlab_widgets/src/manager.ts @@ -24,7 +24,7 @@ import { ReadonlyPartialJSONValue } from '@lumino/coreutils'; import { INotebookModel } from '@jupyterlab/notebook'; -import { IRenderMimeRegistry } from '@jupyterlab/rendermime'; +import type { IRenderMime, IRenderMimeRegistry } from '@jupyterlab/rendermime'; import { Kernel, KernelMessage, Session } from '@jupyterlab/services'; @@ -224,6 +224,12 @@ export abstract class LabWidgetManager if (!cls) { throw new Error(`Class ${className} not found in module ${moduleName}`); } + if ( + moduleName === '@jupyter-widgets/controls' && + this._rendermime.latexTypesetter + ) { + void this._patchTypeset(this._rendermime.latexTypesetter); + } return cls; } @@ -315,6 +321,21 @@ export abstract class LabWidgetManager await this.handle_comm_open(oldComm, msg); }; + /** + * Patch typesetting in `@jupyter-widgets/controls` to use the rendermime's typesetter. + */ + protected async _patchTypeset( + latexTypesetter: IRenderMime.ILatexTypesetter + ): Promise { + const controls = await import('@jupyter-widgets/controls/lib/utils'); + controls.typeset = (element: HTMLElement, text?: string): void => { + if (text !== void 0) { + element.textContent = text; + } + latexTypesetter.typeset(element); + }; + } + protected _restored = new Signal(this); protected _restoredStatus = false; protected _kernelRestoreInProgress = false; From c52e9cdf1f6aeff0d56fe1615c96a732b6961bf2 Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Tue, 10 Oct 2023 08:31:54 -0500 Subject: [PATCH 2/9] add some yarn config --- .yarnrc.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.yarnrc.yml b/.yarnrc.yml index 42586b8950..5dd084b809 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -11,3 +11,22 @@ packageExtensions: source-map-loader@^4: dependencies: webpack: ^5 + +enableTelemetry: false + +httpTimeout: 60000 + +# these messages provide no actionable information, and make non-TTY output +# almost unreadable, masking real dependency-related information +# see: https://yarnpkg.com/advanced/error-codes +logFilters: + - code: YN0006 # SOFT_LINK_BUILD + level: discard + - code: YN0007 # MUST_BUILD + level: discard + - code: YN0008 # MUST_REBUILD + level: discard + - code: YN0013 # FETCH_NOT_CACHED + level: discard + - code: YN0019 # UNUSED_CACHE_ENTRY + level: discard From 388c782cbb1fe396ddf1b531fbccc315dbc9dacf Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Tue, 10 Oct 2023 09:13:21 -0500 Subject: [PATCH 3/9] try a different approach --- packages/controls/src/widget_description.ts | 14 ++++++++++++- python/jupyterlab_widgets/src/manager.ts | 23 +-------------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/packages/controls/src/widget_description.ts b/packages/controls/src/widget_description.ts index 40ea975278..db04bd6e22 100644 --- a/packages/controls/src/widget_description.ts +++ b/packages/controls/src/widget_description.ts @@ -66,7 +66,19 @@ export class DescriptionView extends DOMWidgetView { } typeset(element: HTMLElement, text?: string): void { - this.displayed.then(() => typeset(element, text)); + this.displayed.then(() => { + if ((window as any).MathJax) { + return typeset(element, text); + } + const widget_manager: any = this.model.widget_manager; + const latexTypesetter = widget_manager.rendermime?.latexTypesetter; + if (latexTypesetter) { + if (text !== void 0) { + element.textContent = text; + } + latexTypesetter.typeset(element); + } + }); } updateDescription(): void { diff --git a/python/jupyterlab_widgets/src/manager.ts b/python/jupyterlab_widgets/src/manager.ts index f853695e22..9ee14d76fc 100644 --- a/python/jupyterlab_widgets/src/manager.ts +++ b/python/jupyterlab_widgets/src/manager.ts @@ -24,7 +24,7 @@ import { ReadonlyPartialJSONValue } from '@lumino/coreutils'; import { INotebookModel } from '@jupyterlab/notebook'; -import type { IRenderMime, IRenderMimeRegistry } from '@jupyterlab/rendermime'; +import { IRenderMimeRegistry } from '@jupyterlab/rendermime'; import { Kernel, KernelMessage, Session } from '@jupyterlab/services'; @@ -224,12 +224,6 @@ export abstract class LabWidgetManager if (!cls) { throw new Error(`Class ${className} not found in module ${moduleName}`); } - if ( - moduleName === '@jupyter-widgets/controls' && - this._rendermime.latexTypesetter - ) { - void this._patchTypeset(this._rendermime.latexTypesetter); - } return cls; } @@ -321,21 +315,6 @@ export abstract class LabWidgetManager await this.handle_comm_open(oldComm, msg); }; - /** - * Patch typesetting in `@jupyter-widgets/controls` to use the rendermime's typesetter. - */ - protected async _patchTypeset( - latexTypesetter: IRenderMime.ILatexTypesetter - ): Promise { - const controls = await import('@jupyter-widgets/controls/lib/utils'); - controls.typeset = (element: HTMLElement, text?: string): void => { - if (text !== void 0) { - element.textContent = text; - } - latexTypesetter.typeset(element); - }; - } - protected _restored = new Signal(this); protected _restoredStatus = false; protected _kernelRestoreInProgress = false; From bbc6111ec538cc2bf52f8a32f290ee335c344ada Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Tue, 10 Oct 2023 09:33:36 -0500 Subject: [PATCH 4/9] add notebook 7 to binder --- .binder/requirements.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.binder/requirements.txt b/.binder/requirements.txt index cd8e02335f..7edf88f63f 100644 --- a/.binder/requirements.txt +++ b/.binder/requirements.txt @@ -1,9 +1,11 @@ bqplot ipyleaflet jupyterlab-myst -jupyterlab==4.0.2 +jupyterlab==4.0.6 matplotlib +nbclassic networkx +notebook==7.0.4 numpy pandas scikit-image From 538be8d62d4f1a1d0db68385b3047bbd745b8000 Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Tue, 10 Oct 2023 09:51:45 -0500 Subject: [PATCH 5/9] use private _rendermime for notebook 7 --- packages/controls/src/widget_description.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/controls/src/widget_description.ts b/packages/controls/src/widget_description.ts index db04bd6e22..97a4ab99f5 100644 --- a/packages/controls/src/widget_description.ts +++ b/packages/controls/src/widget_description.ts @@ -71,7 +71,7 @@ export class DescriptionView extends DOMWidgetView { return typeset(element, text); } const widget_manager: any = this.model.widget_manager; - const latexTypesetter = widget_manager.rendermime?.latexTypesetter; + const latexTypesetter = widget_manager._rendermime?.latexTypesetter; if (latexTypesetter) { if (text !== void 0) { element.textContent = text; From 1c7d74a62a0140e9d8de377a9769726f40b01dbc Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Tue, 10 Oct 2023 10:14:57 -0500 Subject: [PATCH 6/9] more mathjax detection --- packages/controls/src/widget_description.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/controls/src/widget_description.ts b/packages/controls/src/widget_description.ts index 97a4ab99f5..2b0ccdcf7f 100644 --- a/packages/controls/src/widget_description.ts +++ b/packages/controls/src/widget_description.ts @@ -67,7 +67,7 @@ export class DescriptionView extends DOMWidgetView { typeset(element: HTMLElement, text?: string): void { this.displayed.then(() => { - if ((window as any).MathJax) { + if ((window as any).MathJax?.Hub?.Queue) { return typeset(element, text); } const widget_manager: any = this.model.widget_manager; From d75421ed71b6953120c16e2de49df8b8ad2b1e49 Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Tue, 10 Oct 2023 11:24:57 -0500 Subject: [PATCH 7/9] add nbclassic to devinstall --- dev-install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dev-install.sh b/dev-install.sh index d8e346c41c..24cdb3ad63 100755 --- a/dev-install.sh +++ b/dev-install.sh @@ -32,10 +32,13 @@ echo -n "widgetsnbextension" pip install -v -e ./python/widgetsnbextension if [[ "$OSTYPE" == "msys" ]]; then jupyter nbextension install --overwrite --py $nbExtFlags widgetsnbextension || true + jupyter nbclassic-extension install --overwrite --py $nbExtFlags widgetsnbextension || true else jupyter nbextension install --overwrite --py --symlink $nbExtFlags widgetsnbextension || true + jupyter nbclassic-extension install --overwrite --py --symlink $nbExtFlags widgetsnbextension || true fi jupyter nbextension enable --py $nbExtFlags widgetsnbextension || true +jupyter nbclassic-nbextension enable --py $nbExtFlags widgetsnbextension || true echo -n "ipywidgets" pip install -v -e "./python/ipywidgets[test]" From b243fd37681945f81458c52ea3a44f4e647890dd Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Tue, 10 Oct 2023 12:17:31 -0500 Subject: [PATCH 8/9] add -x to dev-install for debugging --- dev-install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dev-install.sh b/dev-install.sh index 24cdb3ad63..c79fb448a1 100755 --- a/dev-install.sh +++ b/dev-install.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash - # For a clean conda environment please read docs/source/dev_install.md +set -x + echo -n "Checking pip... " pip --version if [ $? -ne 0 ]; then @@ -38,7 +39,7 @@ else jupyter nbclassic-extension install --overwrite --py --symlink $nbExtFlags widgetsnbextension || true fi jupyter nbextension enable --py $nbExtFlags widgetsnbextension || true -jupyter nbclassic-nbextension enable --py $nbExtFlags widgetsnbextension || true +jupyter nbclassic-extension enable --py $nbExtFlags widgetsnbextension || true echo -n "ipywidgets" pip install -v -e "./python/ipywidgets[test]" From 6a596086025a9752f028fbb1fea2c79ea843daff Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Thu, 12 Oct 2023 08:54:44 -0500 Subject: [PATCH 9/9] bump notebook and lab --- .binder/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.binder/requirements.txt b/.binder/requirements.txt index 7edf88f63f..34d78077a4 100644 --- a/.binder/requirements.txt +++ b/.binder/requirements.txt @@ -1,11 +1,11 @@ bqplot ipyleaflet jupyterlab-myst -jupyterlab==4.0.6 +jupyterlab==4.0.7 matplotlib nbclassic networkx -notebook==7.0.4 +notebook==7.0.5 numpy pandas scikit-image