export_png fails when extending existing bokeh widgets
See original GitHub issueALL software version info (bokeh, python, notebook, OS, browser, any other relevant packages)
bokeh: 1.1.0.dev9
python: 2.7.15
OS: Linux debian 4.9.0-8-amd64 (debian 9)
browser: firefox 65.0.2
Description of expected behavior and the observed behavior
I’m trying to export figures to files, and I have a custom widget that I use to get float inputs from the user. When the custom widget is created, export_png fails to load bokeh.
Expected
Exporting a figure should work no matter what custom widgets are created.
Observed
When export_png is used an a custom widget is created, it fails with “Bokeh was not loaded in time. Something may have gone wrong.”.
Complete, minimal, self-contained example code that reproduces the issue
Here is a small example that fails to export a figure. It works again if you comment out the class declaration and instanciation (FloatTextInput and ftextinput).
from bokeh.models import TextInput
from bokeh.io import export_png, curdoc
from bokeh.layouts import layout
from bokeh.plotting import figure
JS_CODE = """
import {TextInput} from "models/widgets/text_input"
export class FloatTextInput extends TextInput
type: "FloatTextInput"
"""
class FloatTextInput(TextInput):
__implementation__ = JS_CODE
# FloatTextInput does some input validation on value change (left out for readability)
ftextinput = FloatTextInput()
textinput = TextInput()
fig = figure()
layout = layout([textinput, fig])
curdoc().add_root(layout)
export_png(fig, "out.png")
Stack traceback and/or browser JavaScript console output
2019-03-19 13:58:23,850 Error running application handler <bokeh.application.handlers.script.ScriptHandler object at 0x7fbafcd005d0>: Bokeh was not loaded in time. Something may have gone wrong.
File "wait.py", line 80, in until:
raise TimeoutException(message, screen, stacktrace) Traceback (most recent call last):
File "/home/rmelotte/anaconda3/envs/cdotool/lib/python2.7/site-packages/bokeh/application/handlers/code_runner.py", line 179, in run
exec(self._code, module.__dict__)
File "/home/rmelotte/Documents/bokeh-experiments/custom_model_exports_fails.py", line 31, in <module>
export_png(fig, "out.png")
File "/home/rmelotte/anaconda3/envs/cdotool/lib/python2.7/site-packages/bokeh/io/export.py", line 92, in export_png
image = get_screenshot_as_png(obj, height=height, width=width, driver=webdriver)
File "/home/rmelotte/anaconda3/envs/cdotool/lib/python2.7/site-packages/bokeh/io/export.py", line 210, in get_screenshot_as_png
wait_until_render_complete(web_driver)
File "/home/rmelotte/anaconda3/envs/cdotool/lib/python2.7/site-packages/bokeh/io/export.py", line 282, in wait_until_render_complete
raise_with_traceback(RuntimeError('Bokeh was not loaded in time. Something may have gone wrong.'))
File "/home/rmelotte/anaconda3/envs/cdotool/lib/python2.7/site-packages/bokeh/io/export.py", line 280, in wait_until_render_complete
WebDriverWait(driver, 5, poll_frequency=0.1).until(is_bokeh_loaded)
File "/home/rmelotte/anaconda3/envs/cdotool/lib/python2.7/site-packages/selenium/webdriver/support/wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
RuntimeError: Bokeh was not loaded in time. Something may have gone wrong.
I tried to port FloatTextInput’s JS_CODE to Typescript, but the issue remains the same. I also have other custom widgets (mainly extending Row and Column) and they work fine with export_png.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Exporting plots — Bokeh 2.4.3 Documentation
Exporting PNG images Bokeh can generate RGBA-format Portable Network Graphics (PNG) images from layouts using the export_png() function. This functionality ...
Read more >Bokeh Custom Extension Issues - python - Stack Overflow
Your code works just fine for me with Bokeh 2.1.0. ... If that still gives you the error, then maybe your Bokeh installation...
Read more >Exporting dashboards to PDF or images — Dataiku DSS 8.0 ...
Dashboards can be exported to PDF or image (PNG, JPG) files in order to propagate information inside your organization more easily. Dashboard exports...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’re right. I could reproduce the issue with 1.1.0dev9, but it’s gone in 1.1.0dev10.
Thanks!
If it’s not the timeout then I am afraid I have no idea what the issue could be at the moment.
Edit: especially given that the code above runs fine for me on OSX with 1.1.0dev11