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

Widgets not Exporting to HTML #920

Closed
pgierz opened this issue Nov 27, 2018 · 8 comments
Closed

Widgets not Exporting to HTML #920

pgierz opened this issue Nov 27, 2018 · 8 comments
Labels
format:HTML pertains to exporting to the HTML format

Comments

@pgierz
Copy link

pgierz commented Nov 27, 2018

Hello,
First off, I think that the jupyter project is fantastic, it's completely changed my workflow! Great work!
Currently, I'm trying to export widgets to a static html page. Note that these widgets are not expected to actually work (obviously I'd need to connect to a kernel to do that). For right now, I just want them to render.

I have installed the dev version (eb3b0a7) of nbconvert using the instructions from the README.

$ git log --pretty=format:'%h' -n 1
eb3b0a7
$ jupyter nbconvert --version
5.4.0.dev0

I also have installed jupyter and ipywidgets via Conda:

$ conda list | grep jupyter 
jupyter                   1.0.0                    py36_4    anaconda
jupyter_client            5.2.3                    py36_0  
jupyter_console           5.2.0            py36he59e554_1  
jupyter_contrib_core      0.3.3                      py_2    conda-forge
jupyter_contrib_nbextensions 0.5.0                    py36_0    conda-forge
jupyter_core              4.4.0            py36h7c827e3_0  
jupyter_highlight_selected_word 0.2.0                    py36_0    conda-forge
jupyter_latex_envs        1.4.4                    py36_0    conda-forge
jupyter_nbextensions_configurator 0.4.0                    py36_0    conda-forge
$ conda list | grep ipywidgets
 ipywidgets                7.4.2                      py_0    conda-forge

Unfortunately, if I try to export ipywidgets to html, they do not appear in my browser when I open the html file (see screenshots).

screenshot 2018-11-27 at 09 11 24

screenshot 2018-11-27 at 09 11 29

Any help would be greatly appreciated, and please let me know if I can provide any further information to help debug this problem.

Thanks!
Paul

@maartenbreddels
Copy link
Collaborator

First off, I think that the jupyter project is fantastic

Thank you for the positive feedback!

You might want to take a look at #900 for embedding the widget state (and possibly #901 for embedding a png version of it).

Would be great if you can test it out and give feedback.

An easy way to install would be:
$ pip install https://github.com/maartenbreddels/nbconvert/archive/widget_state.zip

@pgierz
Copy link
Author

pgierz commented Nov 30, 2018

Hi,

I did the following (I guess this installs the version for #900? I must admit I'm still a bit new to this...):

$ pip install https://github.com/maartenbreddels/nbconvert/archive/widget_state.zip
Collecting https://github.com/maartenbreddels/nbconvert/archive/widget_state.zip
  Downloading https://github.com/maartenbreddels/nbconvert/archive/widget_state.zip
     / 2.8MB 154.1MB/s
Requirement already satisfied (use --upgrade to upgrade): nbconvert==5.4.0.dev0 from https://github.com/maartenbreddels/nbconvert/archive/widget_state.zip in ./nbconvert
Requirement already satisfied: mistune>=0.8.1 in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from nbconvert==5.4.0.dev0) (0.8.3)
Requirement already satisfied: jinja2 in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from nbconvert==5.4.0.dev0) (2.9.6)
Requirement already satisfied: pygments in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from nbconvert==5.4.0.dev0) (2.2.0)
Requirement already satisfied: traitlets>=4.2 in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from nbconvert==5.4.0.dev0) (4.3.2)
Requirement already satisfied: jupyter_core in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from nbconvert==5.4.0.dev0) (4.4.0)
Requirement already satisfied: nbformat>=4.4 in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from nbconvert==5.4.0.dev0) (4.4.0)
Requirement already satisfied: entrypoints>=0.2.2 in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from nbconvert==5.4.0.dev0) (0.2.3)
Requirement already satisfied: bleach in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from nbconvert==5.4.0.dev0) (2.0.0)
Requirement already satisfied: pandocfilters>=1.4.1 in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from nbconvert==5.4.0.dev0) (1.4.2)
Requirement already satisfied: testpath in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from nbconvert==5.4.0.dev0) (0.3.1)
Requirement already satisfied: defusedxml in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from nbconvert==5.4.0.dev0) (0.5.0)
Requirement already satisfied: MarkupSafe>=0.23 in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from jinja2->nbconvert==5.4.0.dev0) (1.0)
Requirement already satisfied: ipython_genutils in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from traitlets>=4.2->nbconvert==5.4.0.dev0) (0.2.0)
Requirement already satisfied: six in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from traitlets>=4.2->nbconvert==5.4.0.dev0) (1.11.0)
Requirement already satisfied: decorator in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from traitlets>=4.2->nbconvert==5.4.0.dev0) (4.1.2)
Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from nbformat>=4.4->nbconvert==5.4.0.dev0) (2.6.0)
Requirement already satisfied: html5lib>=0.99999999 in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from bleach->nbconvert==5.4.0.dev0) (0.999999999)
Requirement already satisfied: webencodings in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from html5lib>=0.99999999->bleach->nbconvert==5.4.0.dev0) (0.5.1)
Requirement already satisfied: setuptools>=18.5 in /scratch/work/pgierz/anaconda3/lib/python3.6/site-packages (from html5lib>=0.99999999->bleach->nbconvert==5.4.0.dev0) (36.5.0.post20170921)
Building wheels for collected packages: nbconvert
  Running setup.py bdist_wheel for nbconvert ... done
  Stored in directory: /tmp/pip-ephem-wheel-cache-rwnpo9ej/wheels/f3/26/74/00a61f31642422bde1cb5ae767b6c2d47a86bd935b2c4b95f7
Successfully built nbconvert
You are using pip version 18.0, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Followed by:

$ jupyter nbconvert --execute test.ipynb --output-dir=/home/csys/pgierz/public_html/

Note that the test.ipynb notebook is what I had posted above, just a small import of ipywidgets and generation of a slider. Unfortunately the result is unchanged, I still don't see the widget.

To be honest, a png version would already be perfectly sufficient, my use case is going to eventually be to display progress bars (see here: https://github.com/tqdm/tqdm#ipython-jupyter-integration). I'd like to use this to monitor some long supercomputer simulations I have running.

Should I instead try #901? If yes, how do I go about installing that one? Or should I provide some more information to understand why #900 doesn't work?

@maartenbreddels
Copy link
Collaborator

I'd like to know why this does not work first. If you do:

$ python -m nbconvert test.ipynb  --to ipynb --execute

Does your test.nbconvert.ipynb file contain the ['metadata']['widgets'] key? If not, the installation didn't succeed. And looking at your otuput I think it did not.
Try uninstalling it first, then installing.

$ pip uninstall nbconvert # or conda uninstall nbconvert 
$ pip install https://github.com/maartenbreddels/nbconvert/archive/widget_state.zip

@pgierz
Copy link
Author

pgierz commented Nov 30, 2018

Awesome! That seemed to do the trick! Thanks!!!!!

screenshot 2018-11-30 at 12 41 17

It also works in my monitoring notebook that I had planned on using! The red progress bar is a widget instance:
screenshot 2018-11-30 at 12 41 44

Very cool...I'd recommend that we can close this issue, but maybe it would be good if #900 gets merged into the main nbconvert? Then other people won't have to install it by hand.

@maartenbreddels
Copy link
Collaborator

Great to hear it is working.

Could you explain a bit more on what kind of workflow you have here? How is the notebook generated, from some cron job?

@pgierz
Copy link
Author

pgierz commented Nov 30, 2018

Sure:

I work in climate modelling, and we often have very long simulations. Walltimes for one experiment can range from 1 week to, in extreme cases, 3-4 months. The "normal" workflow in our department normally involves coming to the institute in the morning, logging on to whatever supercomputer your job is running on, and doing a bunch of maintenance and checks by hand. Since I'm lazy, I thought I should find a way for this to work automatically.

I write a small template notebook which has some things I'd like to check. It uses paramiko to execute some remote commands to figure out the computing queue, opens some log files and parses out information from them. In principle, I could also make plots of some interesting climate quantities (temperature, precipitation, whatever else)

I test this by hand for until it looks like I want, and then I have a cronjob running which automatically executes the notebook, converts it to html, and then moves the file to our webserver. So, now I can keep an eye on my simulations from anywhere with a browser and vpn access. Putting the widgets in is basically just beautification, I could just plot the progress with Matplotlib, but that looked (in my option) ugly.

@maartenbreddels
Copy link
Collaborator

Thanks for sharing!

Since I'm lazy,

I translate that as 'I prefer to automate simple/dumb stuff' ;)

@t-makaro t-makaro added the format:HTML pertains to exporting to the HTML format label Aug 2, 2019
@MSeal
Copy link
Contributor

MSeal commented Sep 4, 2019

Closing since the associated PR was merged a while back and released.

@MSeal MSeal closed this as completed Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
format:HTML pertains to exporting to the HTML format
Projects
None yet
Development

No branches or pull requests

4 participants