KeyError when embedding bokeh-server plot?

Hi everyone,

I seem to be stuck and haven’t figured out whats going on with my issue.

I run my python script to create a script tag that allows me to embed a bokeh-server downsampling plot into an html page. Okay fine.
Now when I put this generated script into the html page and open it, it renders and creates the correct

tags like its supposed to and I see a GET call to the bokeh server terminal I have open.

However, the plot is not displayed (nothing happens at all, no bokeh tools or anything) and I get this output from the bokeh-server:

2015-06-12 13:01:29,350:ERROR:bokeh.server:Exception on /bokeh/objinfo/0e04bf21-6db7-4a28-a275-ae2ff45ea599/26138982-5107-45e2-b1ad-d863e97ed1cc [GET]

Traceback (most recent call last):

File “/usr/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py”, line 1817, in wsgi_app

response = self.full_dispatch_request()

File “/usr/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py”, line 1477, in full_dispatch_request

rv = self.handle_user_exception(e)

File “/usr/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py”, line 1381, in handle_user_exception

reraise(exc_type, exc_value, tb)

File “/usr/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py”, line 1475, in full_dispatch_request

rv = self.dispatch_request()

File “/usr/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py”, line 1461, in dispatch_request

return self.view_functionsrule.endpoint

File “/usr/lib/python2.7/site-packages/bokeh/server/crossdomain.py”, line 34, in wrapped_function

resp = make_response(f(*args, **kwargs))

File “/usr/lib/python2.7/site-packages/bokeh/server/views/bbauth.py”, line 21, in wrapper

return func(*args, **kwargs)

File “/usr/lib/python2.7/site-packages/bokeh/server/views/main.py”, line 253, in get_bokeh_info_one_object

obj = clientdoc._models[objid]

KeyError: u’26138982-5107-45e2-b1ad-d863e97ed1cc’

2015-06-12 13:01:29,352:ERROR:tornado.access:500 GET /bokeh/objinfo/0e04bf21-6db7-4a28-a275-ae2ff45ea599/26138982-5107-45e2-b1ad-d863e97ed1cc (127.0.0.1) 4.97ms

I couldnt find any help online with respect to this issue :frowning:

Any help would be greatly appreciated!

I should add some additional notes:

  1. I should add that my downsampling works perfectly when I use the ‘‘normal’’ bokeh server functionality without trying to embed anything.
  2. I created an html file, included the necessary bokeh script and stylefile and am not running any other local server other than the bokeh-server.
  3. I put the html file into a subdirectory of the one which contains the running bokeh-server script. Obviously this is fine since it seems to communicate with it anyways.

Anyone? Im sure many people have embedded a downsampling plot into a custom html file using the output script tag??
My problem is that I don’t know what this ID is for…

Do you have some minimal example to reproduce this? It's hard to say with not much to go on. Are you using embed.components? autoload_server? Are you still explicitly pushing your plot the the server in the case that does not work?

Bryan

···

On Jun 15, 2015, at 7:57 AM, omearac <[email protected]> wrote:

Anyone? Im sure many people have embedded a downsampling plot into a custom html file using the output script tag??
My problem is that I don't know what this ID is for...

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/c36f92be-245c-44ee-a00f-ea2bb9056556%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan! Thanks for the reply! Here are some more details to answer some of your questions.

First I start the bokeh-server and here is some sample code

from bokeh.plotting import *

from blaze.server.client import Client

from bokeh.transforms import line_downsample

from blaze import Data

from bokeh.embed import autoload_server

c = Client(‘http://localhost:5006’)

d = Data©

table = d.aapl

source = line_downsample.source()

source.from_blaze(table, local=True)

f = figure(tools=“pan,wheel_zoom,box_zoom,reset,previewsave”, plot_width=600, plot_height=600)

f.line(‘date’, ‘close’, color=’#A6CEE3’, tools=“pan,wheel_zoom,box_zoom,reset,previewsave”, source=source)

output_server(“test_plot”)

session = cursession()

script = autoload_server(f, session)

print script

This gives me a script like:

Then I tried to simply copy paste this script and insert it into the body of a test HTML document. When I open the page and debug, I can see that the BokehJS seemed to correctly add DIV tags from that script output, and in my terminal with bokeh server running I can see the GET call as well as that KeyError saying that the “data-bokeh-modelid” is somehow incorrect. Is this something very simple I am not understanding? Surely, people have embedded a downsample example since this should be straightforward!

Thanks for your time,
Corey

···

On Monday, June 15, 2015 at 4:55:52 PM UTC+2, Bryan Van de ven wrote:

Do you have some minimal example to reproduce this? It’s hard to say with not much to go on. Are you using embed.components? autoload_server? Are you still explicitly pushing your plot the the server in the case that does not work?

Bryan

On Jun 15, 2015, at 7:57 AM, omearac [email protected] wrote:

Anyone? Im sure many people have embedded a downsampling plot into a custom html file using the output script tag??

My problem is that I don’t know what this ID is for…


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/c36f92be-245c-44ee-a00f-ea2bb9056556%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

autoload_server generates a script that will load BokehJS, and a plot from a Bokeh server. It does not actually store anything on the server. You need to push the plot to the server using bokeh.io.push

  http://bokeh.pydata.org/en/latest/docs/reference/resources_embedding.html#bokeh.io.push

The show() function implicitly pushes, but since you don't want to call show(), you will have to call push() yourself.

Bryan

···

On Jun 16, 2015, at 1:57 AM, omearac <[email protected]> wrote:

Hi Bryan! Thanks for the reply! Here are some more details to answer some of your questions.

First I start the bokeh-server and here is some sample code

from bokeh.plotting import *
from blaze.server.client import Client
from bokeh.transforms import line_downsample
from blaze import Data
from bokeh.embed import autoload_server

c = Client('http://localhost:5006')
d = Data(c)
table = d.aapl
source = line_downsample.source()
source.from_blaze(table, local=True)

f = figure(tools="pan,wheel_zoom,box_zoom,reset,previewsave", plot_width=600, plot_height=600)
f.line('date', 'close', color='#A6CEE3', tools="pan,wheel_zoom,box_zoom,reset,previewsave", source=source)

output_server("test_plot")
session = cursession()

script = autoload_server(f, session)
print script

This gives me a script like:

<script
    src="http://localhost:5006/bokeh/autoload.js/8328e50e-18b0-4bdf-9182-07b1a95a2394"
    id="8328e50e-18b0-4bdf-9182-07b1a95a2394"
    async="true"
    data-bokeh-data="server"
    data-bokeh-modelid="53e77ea1-ebab-4644-a312-10df2b0e4f9d"
    data-bokeh-root-url="http://localhost:5006/"
    data-bokeh-docid="a9989da2-6fc2-443a-9d8c-8cb6b076a79e"
    data-bokeh-docapikey="f3ffd782-4389-41f6-8399-f027d95121f9"
    data-bokeh-loglevel="info"
></script>

Then I tried to simply copy paste this script and insert it into the body of a test HTML document. When I open the page and debug, I can see that the BokehJS seemed to correctly add DIV tags from that script output, and in my terminal with bokeh server running I can see the GET call as well as that KeyError saying that the "data-bokeh-modelid" is somehow incorrect. Is this something very simple I am not understanding? Surely, people have embedded a downsample example since this should be straightforward!

Thanks for your time,
Corey

On Monday, June 15, 2015 at 4:55:52 PM UTC+2, Bryan Van de ven wrote:
Do you have some minimal example to reproduce this? It's hard to say with not much to go on. Are you using embed.components? autoload_server? Are you still explicitly pushing your plot the the server in the case that does not work?

Bryan

> On Jun 15, 2015, at 7:57 AM, omearac <[email protected]> wrote:
>
> Anyone? Im sure many people have embedded a downsampling plot into a custom html file using the output script tag??
> My problem is that I don't know what this ID is for...
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/c36f92be-245c-44ee-a00f-ea2bb9056556%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/e1c18333-9a6d-448e-84e7-ddbafaa8457d%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

I should also add that copy pasting the exact code snippet example from the server embedding page http://bokeh.pydata.org/en/latest/docs/user_guide/embed.html#userguide-embed
does not work and I get the same KeyError I described in my first post. Strange because a normal bokeh-server plot is fine, but this embedding thing doesnt seem to work when combined with a bokeh server.

Corey, the embed with server is used in the docs and tested in our CI automation, but it’s possible there is a bug, particularly in conjunction with the line downsample source. At present abstract rendering is one of the least well-covered/supported areas of the library due to the current make-up of the core team. I’d recommend submitting a GH issue so that perhaps we can get wider exposure among done people who might be able to help or suggest things.

Bryan

···

On Jun 17, 2015, at 06:58, omearac [email protected] wrote:

I should also add that copy pasting the exact code snippet example from the server embedding page http://bokeh.pydata.org/en/latest/docs/user_guide/embed.html#userguide-embed
does not work and I get the same KeyError I described in my first post. Strange because a normal bokeh-server plot is fine, but this embedding thing doesnt seem to work when combined with a bokeh server.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/dda5e42f-fb5a-4e1f-b697-f6026bd5c0c4%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan,

Thanks for the quick response! I almost have it working after your suggestion. First, to simplify things I just used show(), and second, I put out_server(’‘test_plot’’) at the start of my script.
The results are

  1. my browser opens with the correct plot
  2. when I copy paste the generated script into a simple HTML document, the webpage shows the Bokeh plot window and tools, BUT no data points.

Here,

from bokeh.plotting import *

from blaze.server.client import Client

from bokeh.transforms import line_downsample

from blaze import Data

from bokeh.embed import autoload_server

output_server(“test_plot”)

c = Client(‘http://localhost:5006’)

d = Data©

table = d.aapl

source = line_downsample.source()

source.from_blaze(table, local=True)

f = figure(tools=“pan,wheel_zoom,box_zoom,reset,previewsave”, plot_width=600, plot_height=600)

f.line(‘date’, ‘close’, color=’#A6CEE3’, tools=“pan,wheel_zoom,box_zoom,reset,previewsave”, source=source)

show(f)

script = autoload_server(f, cursession(), public=True)

print script

The bokeh-server gives me this:

2015-06-13 06:36:46,909:INFO:tornado.access:200 GET /bokeh/autoload.js/38a71c4e-cbfa-460f-b266-743a6a4357ca (127.0.0.1) 1.73ms

2015-06-13 06:36:47,126:INFO:tornado.access:200 GET /bokeh/wsurl/ (127.0.0.1) 0.68ms

2015-06-13 06:36:47,194:INFO:tornado.access:200 GET /bokeh/objinfo/ced0bc0b-91c8-48c3-80f5-98565d088701/f4a08a64-178e-4afe-9438-45ea5fff06ad (127.0.0.1) 30.16ms

2015-06-13 06:36:47,436:INFO:tornado.access:200 OPTIONS /render/ced0bc0b-91c8-48c3-80f5-98565d088701/02bbc1d1-5a9a-4f09-a892-3d50a89c096e/062422be-5c53-4629-a7c7-dbf90a40ac09 (127.0.0.1) 1.04ms

i.e no POST calls.

Do I need to run an additional server besides bokeh-server? I read that somewhere and it didn’t seem to make a difference (i.e. python SimpleHTTPServer). I am using the repo version of bokeh from about 1 month ago!

Thanks so much,
Corey

EDIT: Okay, sounds good Bryan. The embedding works for the animated plot example you guys have on github! I did indeed have to start a SimpleHTTPServer to get it working and then going to http://localhost:8000/animated_embed.html.
However, I think the issue arises when I go to downsample and have to use something like c=Client('http://localhost:5006), which is from the apple stock example. I dont really understand what this does, and if I need to set up this client to

the new SimpleHTTPServer port or what. I will continue to post on this thread for updates and if need be ill create an issue. This is still useful here in case someone has already embedded a downsampling plot - seems like it should be easy and done!

Cheers,
Corey

···

On Wednesday, June 17, 2015 at 3:11:30 PM UTC+2, Bryan Van de ven wrote:

Corey, the embed with server is used in the docs and tested in our CI automation, but it’s possible there is a bug, particularly in conjunction with the line downsample source. At present abstract rendering is one of the least well-covered/supported areas of the library due to the current make-up of the core team. I’d recommend submitting a GH issue so that perhaps we can get wider exposure among done people who might be able to help or suggest things.

Bryan

On Jun 17, 2015, at 06:58, omearac [email protected] wrote:

I should also add that copy pasting the exact code snippet example from the server embedding page http://bokeh.pydata.org/en/latest/docs/user_guide/embed.html#userguide-embed
does not work and I get the same KeyError I described in my first post. Strange because a normal bokeh-server plot is fine, but this embedding thing doesnt seem to work when combined with a bokeh server.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/dda5e42f-fb5a-4e1f-b697-f6026bd5c0c4%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

I think I found the root of the problem. Do you know much about the cross-domain properties of the bokeh-server? See, the bokeh server is my Client at localhost:5006. However, when I run the python SimpleHTTPServer, that is at localhost:8000. When I open my
html file localhost:8000/test_plot.html, the bokeh server gives me an output of OPTIONS instead of POST. It seems this problem is due to the fact that my data is located on the bokeh server listening to a different port. I see there is a crossdomain.py file for the bokeh server but Im not sure how to enable this cross host data management. Does this problem ring a bell/ make sense now?

···

On Wednesday, June 17, 2015 at 3:11:30 PM UTC+2, Bryan Van de ven wrote:

Corey, the embed with server is used in the docs and tested in our CI automation, but it’s possible there is a bug, particularly in conjunction with the line downsample source. At present abstract rendering is one of the least well-covered/supported areas of the library due to the current make-up of the core team. I’d recommend submitting a GH issue so that perhaps we can get wider exposure among done people who might be able to help or suggest things.

Bryan

On Jun 17, 2015, at 06:58, omearac [email protected] wrote:

I should also add that copy pasting the exact code snippet example from the server embedding page http://bokeh.pydata.org/en/latest/docs/user_guide/embed.html#userguide-embed
does not work and I get the same KeyError I described in my first post. Strange because a normal bokeh-server plot is fine, but this embedding thing doesnt seem to work when combined with a bokeh server.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/dda5e42f-fb5a-4e1f-b697-f6026bd5c0c4%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Corey,

I am not so sure this is a cross domain issue, but this is outside my expertise. I'd suggest making a GH issue so that we can attempt to engage some other people who know more about this side of things.

Bryan

···

On Jun 18, 2015, at 6:33 AM, omearac <[email protected]> wrote:

I think I found the root of the problem. Do you know much about the cross-domain properties of the bokeh-server? See, the bokeh server is my Client at localhost:5006. However, when I run the python SimpleHTTPServer, that is at localhost:8000. When I open my
html file localhost:8000/test_plot.html, the bokeh server gives me an output of OPTIONS instead of POST. It seems this problem is due to the fact that my data is located on the bokeh server listening to a different port. I see there is a crossdomain.py file for the bokeh server but Im not sure how to enable this cross host data management. Does this problem ring a bell/ make sense now?

On Wednesday, June 17, 2015 at 3:11:30 PM UTC+2, Bryan Van de ven wrote:
Corey, the embed with server is used in the docs and tested in our CI automation, but it's possible there is a bug, particularly in conjunction with the line downsample source. At present abstract rendering is one of the least well-covered/supported areas of the library due to the current make-up of the core team. I'd recommend submitting a GH issue so that perhaps we can get wider exposure among done people who might be able to help or suggest things.

Bryan

On Jun 17, 2015, at 06:58, omearac <[email protected]> wrote:

I should also add that copy pasting the exact code snippet example from the server embedding page http://bokeh.pydata.org/en/latest/docs/user_guide/embed.html#userguide-embed
does not work and I get the same KeyError I described in my first post. Strange because a normal bokeh-server plot is fine, but this embedding thing doesnt seem to work when combined with a bokeh server.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/dda5e42f-fb5a-4e1f-b697-f6026bd5c0c4%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/24f4ba8b-5c51-4bf4-95b1-f0ac985d71fd%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Okay, can do!

Hello,

Was there ever a resolution to this issue or a githiub issue submitted?? I am having exactly the same problem and cannot find either a solution or a github issue

···

On Friday, June 19, 2015 at 2:18:16 PM UTC+2, omearac wrote:

Okay, can do!

After posting my last reply, I think I found the problem. In my code I had

output_server(‘big_test’)

and

session.use_doc(‘something_else’)

When the two strings were set to the same value, “big_test”, everything worked fine and I got rid of the KeyError.

Code that works for me is:

import bokeh

from bokeh.plotting import figure, show, output_server, push

from bokeh.embed import autoload_server

from bokeh.session import Session

from bokeh.document import Document

output_server(‘big_test’)

document = Document()

session = Session()

session.use_doc(‘big_test’)

session.load_document(document)

p = figure(plot_width=400, plot_height=400)

add a circle renderer with a size, color, and alpha

p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color=“navy”, alpha=0.5)

show§

script = autoload_server(p, session)

followed by pasting the contents of ‘script’ into my html file.

Hope this helps.

···

On Friday, June 19, 2015 at 2:18:16 PM UTC+2, omearac wrote:

Okay, can do!