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

exec_doc supports re-rendering widgets #1113

Merged
merged 2 commits into from
Sep 23, 2022
Merged

Conversation

seeM
Copy link
Member

@seeM seeM commented Sep 23, 2022

If users update widgets with the exec_doc directive, the widget "view" is updated (in the cell output), but the old widget "state" is used (in notebook metadata). This refreshes widget state using ipywidgets.Widget.get_manager_state.

See Tyler's comment for context. cc @tylere

@seeM seeM added the bug Something isn't working label Sep 23, 2022
@seeM seeM requested review from jph00 and hamelsmu September 23, 2022 09:48
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@seeM
Copy link
Member Author

seeM commented Sep 23, 2022

Hmm I just realised that this always overwrites existing widget state (e.g. if a user saved it in their IDE). So if your exec_show_docs doesn't render any new widgets, all of your existing widgets will break...

@seeM seeM marked this pull request as draft September 23, 2022 09:49
@seeM
Copy link
Member Author

seeM commented Sep 23, 2022

One solution would be to merge the exec_show_docs state dict with any existing one in the nb, since the state dict is keyed on widget UID.. Will update the PR with that

@seeM seeM marked this pull request as ready for review September 23, 2022 10:10
@seeM seeM added enhancement New feature or request and removed bug Something isn't working labels Sep 23, 2022
@seeM seeM changed the title exec_doc breaks widgets exec_doc supports re-rendering widgets Sep 23, 2022
@hamelsmu
Copy link
Member

Do you think it might make sense to add a test for this?

@hamelsmu hamelsmu merged commit aa9c1d7 into fastai:master Sep 23, 2022
@seeM seeM deleted the store-widget-state branch September 23, 2022 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants