-
Notifications
You must be signed in to change notification settings - Fork 56
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
Discuss or document how to include widget output #39
Comments
Yes, this is the minimal example that I am having trouble with: ipywidgets.ipynb:
from nbformat import read
from nbclient import execute
nb = read("ipywidgets.ipynb", 4)
execute(nb) output:
As you can see, |
Same here, I could not get the widget in the notebook, either by using nbclient or nbconvert with:
|
It works fine if you replace from ipywidgets import IntSlider
IntSlider() ipywidgets.ipynb:```json { "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from ipywidgets import IntSlider\n", "\n", "IntSlider()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.10" } }, "nbformat": 4, "nbformat_minor": 4 } ```output:```json {"cells": [{"cell_type": "code", "execution_count": 1, "metadata": {"execution": {"iopub.status.busy": "2020-03-15T20:11:39.500488Z", "iopub.execute_input": "2020-03-15T20:11:39.502425Z", "shell.execute_reply": "2020-03-15T20:11:39.555759Z", "iopub.status.idle": "2020-03-15T20:11:39.556131Z"}}, "outputs": [{"output_type": "display_data", "metadata": {}, "data": {"text/plain": "IntSlider(value=0)", "application/vnd.jupy ter.widget-view+json": {"version_major": 2, "version_minor": 0, "model_id": "5eda644bac78432fbc8b15c6d535d84f"}}}], "source": "from ipywidgets import IntSlider\n\nIntSlider()"}], "metadata": {"kernelspec": {"dis play_name": "Python 3", "language": "python", "name": "python3"}, "language_info": {"name": "python", "version": "3.6.10", "mimetype": "text/x-python", "codemirror_mode": {"name": "ipython", "version": 3}, "pygm ents_lexer": "ipython3", "nbconvert_exporter": "python", "file_extension": ".py"}, "widgets": {"application/vnd.jupyter.widget-state+json": {"state": {"2f8b466793ef448fa09311ed9397d53c": {"model_name": "LayoutMo del", "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "displa y": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_ar eas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_he ight": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": nu ll, "width": null}}, "e0e4171b772142c68de1410e7c141e88": {"model_name": "SliderStyleModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {"_model_module": "@jupyter-widg ets/controls", "_model_module_version": "1.5.0", "_model_name": "SliderStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "desc ription_width": "", "handle_color": null}}, "5eda644bac78432fbc8b15c6d535d84f": {"model_name": "IntSliderModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {"_dom_clas ses": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "IntSliderModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version" : "1.5.0", "_view_name": "IntSliderView", "continuous_update": true, "description": "", "description_tooltip": null, "disabled": false, "layout": "IPY_MODEL_2f8b466793ef448fa09311ed9397d53c", "max": 100, "min": 0, "orientation": "horizontal", "readout": true, "readout_format": "d", "step": 1, "style": "IPY_MODEL_e0e4171b772142c68de1410e7c141e88", "value": 0}}}, "version_major": 2, "version_minor": 0}}}, "nbformat": 4, "nbformat_minor": 4} ```In your example, |
Thanks @davidbrochart good spot! |
I have updated the issue in jupyter/nbconvert#1214, the issue seems to be only related to |
Posting on both threads -- doing this planned work should fix the Output widget object states, if that is the root cause here: #24 |
Awesome, thanks so much @MSeal - and I hope you enjoyed your vacation! It was a good time to take off work before the global economy comes to a halt 😆 😭 |
#68 solved this and is out in the 0.4.0 release! |
Over in executablebooks/jupyter-cache#31 @chrisjsewell and I ran into a bunch of confusing issues where executing notebooks results in widget state not making it into the output notebook. We've tried a bunch of stuff around "trusting" the notebook etc but can't seem to figure it out.
In the docs we allude to this:
But is there a place to programmatically "trust" a notebook so one can do it just before running nbclient?
I imagine that others that use nbclient might run into the same issues, so perhaps this issue is worth documenting a bit more.
The text was updated successfully, but these errors were encountered: