Issue with folium rendering HTML in notebooks using papermill
See original GitHub issuePlease add a code sample or a nbviewer link, copy-pastable if possible
Hi Colleagues. I’m having some issues with how folium produces html outputs in the JSON of a jupyter notebook. i posted my issue here in the papermill repo first:
https://github.com/nteract/papermill/issues/482
@mseal suggested that i post here.
I’ve been using papermill for a while to execute jupyter notebooks in a CI framework.
I’m running into an odd (i think?) bug. When i run a notebook with an interactive element that will require an iframe - case in point creating a map using leaflet (folium for python), it seems to be adding some code that makes the output render incorrectly.
I just ran one of my notebooks. Prior to running papermill, the iframe embed looked like this:
The important piece here is that the src=data:text/html
part is correctly populated in the json.
"<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><iframe src=\"data:text/html;charset=utf-8;base64,
So folium renders plots correctly when run in a notebook. HOwever, When I run papermill and execute a notebook using papermill, I get the following below: notice that the src now begins with about:blank
.
"<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><iframe src=\"about:blank\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" data-html=PCFET0NUWVBFIGh0bWw+C
@mseal mentioned this could related to something associated with headless execution and browsers. this is a but out of my scope of knowledge but i wondered if you would be willing to help me understand what is happening and what a fix might be?
I am using folium 0.10.1. And am happy to provide any additional information below. I’ve tried this on mac and linux and get the same results.
Many thanks.
# Your code here
Problem description
https://github.com/nteract/papermill/issues/482
[this should explain why the current behavior is a problem and what is the expected output.]
Expected Output
Output of folium.__version__
Issue Analytics
- State:
- Created 3 years ago
- Comments:18
Top GitHub Comments
ahhh ok thank you both @Conengmo and @MSeal i think i generally understand what you are saying. So if nbconvert is rerunning the notebook it could cause issues with the JS state.
The good news is that my student just updated their entire environment and now folium is exporting as expected. So perhaps it was a package version issue. this is all good to know for the future as conversion issues come up. these interactive elements that use JS seem to be a bit tricky when you are exporting to html!
Not yet, we’ll first have to make a release. You be notified when that happens by going to the branca repo and clicking the ‘Watch’ button.
Also note that we haven’t really solved the issue. Instead we now show a message that the user should click to trust the notebook.