I'm not an expert either.
I am using the web2py URL function, as listed in an earlier post:
Hi HR,
I'm no expert in web2py nor the internal machinations of Bokeh, but at a
cursory glance based on your problem definition I would say that the issue
probably lies in how web2py maps URL paths for your application/controller
and/or static files:
web2py - The core
Especially:
<<<
For the reasons mentioned above, you should always use the URL function to
generate URLs of static files for your applications. Static files are stored
in the application's static subfolder (that's where they go when uploaded
using the administrative interface). web2py provides a virtual 'static'
controller whose job is to retrieve files from the static subfolder,
determine their content-type, and stream the file to the client. The
following example generates the URL for the static file "image.png":
>>>
I have encountered problems with static files related to using Bokeh with
Flask, and it ended up being how I had Flask static file directories
configured in my application. Note that Bokeh has it's own idea about static
file directories, which you MUST tell it about when using a container
framework like Flask or web2py. The only reason I can think of something
rendering x10 faster on Chrome is maybe you have something in the cache
already from a previous test?
Hope that helps, and good luck!
- Rob
On Sep 22, 2014, at 12:43 PM, HR Gartenbauer <[email protected]> wrote:
In building a minimal example, I learned that the slowness has nothing to
do with rendering the embedded plot.
A bare-bones web2py template, named bokeh_test.html:
{{extend 'layout.html'}}
<link rel="stylesheet" href="{{=URL('static','css/bokeh-0.6.0.min.css')}}"
type="text/css" />
<script src="{{=URL('static','js/bokeh-0.6.0.min.js')}}"></script>
{{=form}}
and the corresponding web2py controller (note that it does nothing when
the plot button is clicked, I have not yet added the code to generate the
bokeh plot):
def bokeh_test():
from gluon.sqlhtml import form_factory
from exceptions import Exception
form=form_factory( submit_button=T('Plot'),)
d = {}
d['form']=form
if form.accepts(request.vars,session):
try:
pass
except Exception as e:
response.flash = str(e)
elif form.errors:
response.flash = 'form has errors'
return d
Just the initial load of this page takes 25 seconds in Firefox and IE.
The page is loaded instantaneously if this line is taken out:
<script src="{{=URL('static','js/bokeh-0.6.0.min.js')}}"></script>
It is just as slow if I change it to:
<script type="text/javascript"
src="http://cdn.pydata.org/bokeh-0.6.0.min.js"></script>
If I create a minimal html page, upload it to the internet and launch it
from there, it loads instantly:
<html>
<head>
<title>Bokeh js Load</title>
<link rel="stylesheet" href="http://cdn.pydata.org/bokeh-0.6.0.min.css"
type="text/css" />
<script type="text/javascript"
src="http://cdn.pydata.org/bokeh-0.6.0.min.js"></script>
<body>
<p>
Hello Bokeh
</p>
</body>
</html>
Does this new information provide a clue?
On Monday, September 22, 2014 1:55:12 PM UTC-5, Bryan Van de ven wrote:
I'm not sure you're doing anything wrong, you may have uncovered some bug
that is only triggered under certain circumstances. Nothing that profile
jumps out at me, unfortunately. If you are up for checking a few more
things, here are some information points that would be useful:
* does the problem happen with output_file/show instead of components?
* does the problem happen with an equally sized batch of random data?
Bryan
On Sep 22, 2014, at 1:49 PM, HR Gartenbauer <[email protected]> wrote:
>
> Right, I know I'm doing something wrong.
> I've attached a screenshot of the Firefox profile.
> Does anything jump out at you>
> Thanks for your help.
>
>
> On Monday, September 22, 2014 1:19:32 PM UTC-5, Bryan Van de ven wrote:
> Hi,
>
> I've pushed the color_scatter.py example up to tens of thousands of
> points and it is has never taken anywhere near that long. Can you provide a
> complete minimal example to reproduce the problem, along with more
> information about platform, browser versions, etc? If you are familiar with
> browser development tools, a screenshot of the profiler of the affected
> browsers after running your code would also be very useful.
>
> Than
>
> On Sep 22, 2014, at 12:57 PM, HR Gartenbauer <[email protected]> >>> > wrote:
>
> >
> > Using MPLD3, the spectrum renders in Firefox in 3 seconds.
> >
> > On Monday, September 22, 2014 12:44:44 PM UTC-5, HR Gartenbauer >>> > > wrote:
> > I should add that it is not the call to line() that is slow, it is
> > the rendering of the plot in the browser that is slow.
> > len(script) is 160794.
> >
> >
> > On Monday, September 22, 2014 12:37:46 PM UTC-5, HR Gartenbauer >>> > > wrote:
> >
> > I'm rendering a 4000 point spectrum using bokeh.
> >
> > plot = line(x, y,
> > color="#0000FF",
> > tools="pan,wheel_zoom,box_zoom,reset,resize",
> > title=title,
> > title_text_font_size="10pt",
> > plot_width=600, plot_height=300,)
> > script,div = components(plot, CDN)
> > # then deliver XML(script) into a web2py template.
> >
> > I'm not using the server, the html template includes these lines:
> > <script src="{{=URL('static','js/bokeh-0.6.0.min.js')}}"></script>
> > <link rel="stylesheet"
> > href="{{=URL('static','css/bokeh-0.6.0.min.css')}}" type="text/css" />
> >
> > It works, but is slow in Firefox and IE. In Chrome it is fast.
> > In Firefox it is 25 seconds to generate the plot, with a similar time
> > in IE.
> > In Chrome the same operation takes 1 (one) second.
> >
> > What am I doing wrong?