Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weakref to enable gc + setting children with iterable + fix loading state via jupyter.widget.control + fix various tooltips #3893

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7b393e0
Use weakref to replace strong links between widgets and comm
Mar 9, 2024
dca56e3
Replaced _show_traceback decorator with a method
Mar 9, 2024
871ba61
Fix signature of callback lamdas
fleming79 Mar 10, 2024
8f22131
revise close doc
fleming79 Mar 10, 2024
ae6df72
change so Widget.notify_change doesn't create comm
fleming79 Mar 10, 2024
200edee
Fix reject 'Control comm was closed too early' when comm closed as ex…
Mar 10, 2024
24ad054
Fix _show_traceback in _comm_changed
Mar 10, 2024
2bcbed3
Added a `closed` property to the Widget class. Modified __repr__ to i…
Mar 11, 2024
d3e5e29
Make compatible with python3.8
Mar 11, 2024
6877265
Modified Widget.open to raise a runtime error if the widget is closed.
fleming79 Mar 11, 2024
f82c35c
Removed the recently added `closed` property, instead noting that _re…
Mar 12, 2024
66ea639
Made observing box children an opt-in feature with the keyword only a…
Mar 12, 2024
6ff5b23
Update lock file
Mar 14, 2024
4c9004d
Ran jlpm lint
Mar 14, 2024
d182a47
_widget_to_json
Mar 14, 2024
5448ecc
Improve error message in `_widget_to_json`.
Mar 15, 2024
d1379cb
Update method Widget.get_view_spec.
fleming79 Mar 17, 2024
cecbb88
Optimised Widget._send
fleming79 Mar 20, 2024
5ad3723
Restore type hint info for Children.
Apr 2, 2024
2e8c784
Remove redundant type hint from `Box.children`.
Apr 6, 2024
21cb6fa
Fix Checkbox tooltips
Apr 7, 2024
24af66b
Fix tooltips for TextareaView, TextView, SelectionView.
Apr 7, 2024
ce31091
Fix invalid package dependencies @lumino/messaging & @lumino/algorithm.
May 3, 2024
9f12504
Remove unnecessary weakrefs
May 3, 2024
a634441
Using weakreference is now opt-in.
May 3, 2024
b1410eb
Unify tooltips
May 4, 2024
3972a9d
Added model_id to errorof get_model.
May 4, 2024
f6fc921
Avoid attribute error on shutdown to do with _instances being None.
May 5, 2024
fc9fb8f
Make Children validate raise TypeError for invalid items.
May 5, 2024
dbd1b19
Parametrize test_weakreference.
May 5, 2024
70b88bc
Add test_box_invalid_children convert TestBox to separate pytests.
May 5, 2024
bf3d0bc
Remove dependency for istanbul-instrumenter-loader (un-maintained).
May 5, 2024
0d80e29
Fix Output tooltip issue & restored tooltip for Box.
May 5, 2024
35be63a
Modify test_weakreference for not enabled (closing should also make w…
May 10, 2024
a776397
Fix spelling of enable_weakreference and disable_weakreference.
May 10, 2024
7741dbb
Revert Link (drop _all_links). Added type annotations for link and dl…
May 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ ui-tests/playwright-report
**/lite/.cache
**/*.doit.*
**/docs/typedoc/
.yarn/*
3 changes: 3 additions & 0 deletions docs/source/dev_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ Lerna will prompt you for version numbers for each of the changed npm packages i
## Configure twine username

If you have 2FA on, make sure you have your `~/.pypirc` file set to:

```
[pypi]
username = __token__
```

Or set the environment variable

```
export TWINE_USERNAME=__token__
```
Expand Down
5 changes: 2 additions & 3 deletions packages/base-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,20 @@
"@jupyterlab/services": "^6.0.0 || ^7.0.0",
"@lumino/coreutils": "^1.11.1 || ^2",
"base64-js": "^1.2.1",
"sanitize-html": "^2.3"
"sanitize-html": "^2.13.0"
},
"devDependencies": {
"@types/base64-js": "^1.2.5",
"@types/chai": "^4.1.7",
"@types/chai-as-promised": "^7.1.0",
"@types/expect.js": "^0.3.29",
"@types/mocha": "^9.0.0",
"@types/sanitize-html": "^2.6.0",
"@types/sanitize-html": "^2.11.0",
"@types/sinon": "^10.0.2",
"@types/sinon-chai": "^3.2.2",
"chai": "^4.0.0",
"chai-as-promised": "^7.0.0",
"expect.js": "^0.3.1",
"istanbul-instrumenter-loader": "^3.0.1",
"karma": "^6.3.3",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "^2.0.3",
Expand Down
7 changes: 5 additions & 2 deletions packages/base-manager/src/manager-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export abstract class ManagerBase implements IWidgetManager {
async get_model(model_id: string): Promise<WidgetModel> {
const modelPromise = this._models[model_id];
if (modelPromise === undefined) {
throw new Error('widget model not found');
throw new Error(`widget model '${model_id}' not found`);
}
return modelPromise;
}
Expand Down Expand Up @@ -413,7 +413,10 @@ export abstract class ManagerBase implements IWidgetManager {
resolve(null);
});

initComm.on_close(() => reject('Control comm was closed too early'));
initComm.on_close(() => {
if (data.method !== 'update_states')
reject('Control comm was closed too early');
});

// Send a states request msg
initComm.send({ method: 'request_states' }, {});
Expand Down
3 changes: 1 addition & 2 deletions packages/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"dependencies": {
"@jupyterlab/services": "^6.0.0 || ^7.0.0",
"@lumino/coreutils": "^1.11.1 || ^2.1",
"@lumino/messaging": "^1.10.1 || ^2.1",
"@lumino/messaging": "^1.10.1 || ^2.0.1",
"@lumino/widgets": "^1.30.0 || ^2.1",
"@types/backbone": "1.4.14",
"@types/lodash": "^4.14.134",
Expand All @@ -55,7 +55,6 @@
"chai": "^4.0.0",
"chai-as-promised": "^7.0.0",
"expect.js": "^0.3.1",
"istanbul-instrumenter-loader": "^3.0.1",
"karma": "^6.3.3",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "^2.0.3",
Expand Down
10 changes: 8 additions & 2 deletions packages/base/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,14 +1095,20 @@ export class DOMWidgetView extends WidgetView {
}

updateTooltip(): void {
const title = this.model.get('tooltip');
const title = this.tooltip;
if (!title) {
this.el.removeAttribute('title');
} else if (this.model.get('description').length === 0) {
} else if (!this.model.get('description')) {
this.el.setAttribute('title', title);
}
}

get tooltip() {
return (
this.model.get('tooltip') ?? (this.model.get('description'))
);
}

/**
* Update the DOM classes applied to an element, default to this.el.
*/
Expand Down
5 changes: 2 additions & 3 deletions packages/controls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
},
"dependencies": {
"@jupyter-widgets/base": "^6.0.7",
"@lumino/algorithm": "^1.9.1 || ^2.1",
"@lumino/algorithm": "^1.9.2 || ^2.0.1",
"@lumino/domutils": "^1.8.1 || ^2.1",
"@lumino/messaging": "^1.10.1 || ^2.1",
"@lumino/messaging": "^1.10.1 || ^2.0.1",
"@lumino/signaling": "^1.10.1 || ^2.1",
"@lumino/widgets": "^1.30.0 || ^2.1",
"d3-color": "^3.0.1",
Expand All @@ -57,7 +57,6 @@
"chai": "^4.0.0",
"css-loader": "^6.5.1",
"expect.js": "^0.3.1",
"istanbul-instrumenter-loader": "^3.0.1",
"karma": "^6.3.3",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "^2.0.3",
Expand Down
12 changes: 4 additions & 8 deletions packages/controls/src/widget_bool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ export class CheckboxView extends DescriptionView {
this.descriptionSpan.textContent = description;
}
this.typeset(this.descriptionSpan);
this.descriptionSpan.title = description;
this.checkbox.title = description;
}

/**
Expand All @@ -181,13 +179,11 @@ export class CheckboxView extends DescriptionView {
}

updateTooltip(): void {
super.updateTooltip();
if (!this.checkbox) return; // we might be constructing the parent
const title = this.model.get('tooltip');
if (!title) {
this.checkbox.removeAttribute('title');
} else if (this.model.get('description').length === 0) {
this.checkbox.setAttribute('title', title);
}
const title = this.tooltip;
this.checkbox.setAttribute('title', title);
this.descriptionSpan.setAttribute('title', title);
}

events(): { [e: string]: string } {
Expand Down
3 changes: 2 additions & 1 deletion packages/controls/src/widget_description.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ export class DescriptionView extends DOMWidgetView {
}

updateTooltip(): void {
super.updateTooltip();
if (!this.label) return;
this.label.title = this.model.get('tooltip');
this.label.title = this.tooltip;
}

label: HTMLLabelElement;
Expand Down
3 changes: 3 additions & 0 deletions packages/controls/src/widget_link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ export class DirectionalLinkModel extends CoreWidgetModel {
undefined
);
this.stopListening(this.sourceModel, 'destroy', undefined);
this.set('source', [null, '']);
}
if (this.targetModel) {
this.stopListening(this.targetModel, 'destroy', undefined);
this.set('target', [null, '']);
this.save_changes();
}
}

Expand Down
8 changes: 2 additions & 6 deletions packages/controls/src/widget_selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,9 @@ export class SelectionView extends DescriptionView {
}

updateTooltip(): void {
super.updateTooltip();
if (!this.listbox) return; // we might be constructing the parent
const title = this.model.get('tooltip');
if (!title) {
this.listbox.removeAttribute('title');
} else if (this.model.get('description').length === 0) {
this.listbox.setAttribute('title', title);
}
this.listbox.setAttribute('title', this.tooltip);
}

listbox: HTMLSelectElement;
Expand Down
16 changes: 4 additions & 12 deletions packages/controls/src/widget_string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,9 @@ export class TextareaView extends StringView {
}

updateTooltip(): void {
super.updateTooltip();
if (!this.textbox) return; // we might be constructing the parent
const title = this.model.get('tooltip');
if (!title) {
this.textbox.removeAttribute('title');
} else if (this.model.get('description').length === 0) {
this.textbox.setAttribute('title', title);
}
this.textbox.setAttribute('title', this.tooltip);
}

events(): { [e: string]: string } {
Expand Down Expand Up @@ -505,13 +501,9 @@ export class TextView extends StringView {
}

updateTooltip(): void {
super.updateTooltip();
if (!this.textbox) return; // we might be constructing the parent
const title = this.model.get('tooltip');
if (!title) {
this.textbox.removeAttribute('title');
} else if (this.model.get('description').length === 0) {
this.textbox.setAttribute('title', title);
}
this.textbox.setAttribute('title', this.tooltip);
}

update(options?: any): void {
Expand Down
4 changes: 2 additions & 2 deletions packages/html-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@jupyterlab/outputarea": "^3.0.0 || ^4.0.0",
"@jupyterlab/rendermime": "^3.0.0 || ^4.0.0",
"@jupyterlab/rendermime-interfaces": "^3.0.0 || ^4.0.0",
"@lumino/messaging": "^1.10.1 || ^2.1",
"@lumino/messaging": "^1.10.1 || ^2.0.1",
"@lumino/widgets": "^1.30.0 || ^2.1",
"ajv": "^8.6.0",
"jquery": "^3.1.1"
Expand All @@ -53,7 +53,7 @@
"@types/jquery": "^3.5.16",
"@types/mocha": "^9.0.0",
"@types/node": "^17.0.2",
"@types/sanitize-html": "^2.6.0",
"@types/sanitize-html": "^2.11.0",
"chai": "^4.0.0",
"css-loader": "^6.5.1",
"karma": "^6.3.3",
Expand Down
2 changes: 1 addition & 1 deletion python/ipywidgets/ipywidgets/widgets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

from .widget import Widget, CallbackDispatcher, register, widget_serialization
from .widget import Widget, CallbackDispatcher, register, widget_serialization, enable_weakreference, disable_weakreference
from .domwidget import DOMWidget
from .valuewidget import ValueWidget

Expand Down
Loading