Bokeh + Blaze Server

I’m trying to follow the blaze_server.py example and can see the results in my browser. However, when I try to set things up using my own data along with a blaze server then my plots come up empty:

import bokeh.session

import bokeh.plotting

import bokeh.models

import blaze

from blaze.server.client import Client

session = bokeh.session.Session(load_from_config=False)

bokeh.plotting.output_server(‘blaze_source’, session=session)

c = Client(‘localhost:9000’)

d = blaze.Data(c)

source = bokeh.models.BlazeDataSource()

source.from_blaze(d.dat)

plot = bokeh.plotting.figure()

plot.circle(‘A’, ‘B’, source=source)

bokeh.plotting.show(plot)

I can see the data in d.dat but I don’t know what I’m doing wrong otherwise. The data is loaded into the blaze server via:

dat = blaze.Data(‘data.csv’)

server = blaze.Server({‘dat’: dat})

server.run(host=“127.0.0.1”, port=9000)

It’s obvious that I don’t follow the logic but I’m happy to take on any suggestions or would be grateful if somebody can point me in the right direction. Ultimately, my goal is to do downsampling for a scatter/circle plot.

Hi,

There is a first problem that you are probably falling into here, which is a crossdomain origin issue on the blaze Server configs. To verify that you can check if you see something like:

XMLHttpRequest cannot load http://localhost:9000/compute.json. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:5006’ is therefore not allowed access.

``

in the JS console on your browser.

This issue should be solved tweaking the server app response headers to allow crossorigin. Try the following change on your code:

dat = blaze.Data(‘data.csv’)

server = blaze.Server({‘dat’: dat})

def add_crossdomain_headers(response):

response.headers.add('Access-Control-Allow-Origin', '*')

response.headers.add('Access-Control-Allow-Methods', 'GET,POST')

response.headers.add('Access-Control-Allow-Headers', "Origin, X-Requested-With, Content-Type, Accept")

return response

server.app.after_request(add_crossdomain_headers)

server.run(host=“127.0.0.1”, port=9000)

``

This should fix the issue related to crossdomain (if any).

Cheers

Fabio

···

On Wednesday, May 13, 2015 at 8:38:32 PM UTC+2, [email protected] wrote:

I’m trying to follow the blaze_server.py example and can see the results in my browser. However, when I try to set things up using my own data along with a blaze server then my plots come up empty:

import bokeh.session

import bokeh.plotting

import bokeh.models

import blaze

from blaze.server.client import Client

session = bokeh.session.Session(load_from_config=False)

bokeh.plotting.output_server(‘blaze_source’, session=session)

c = Client(‘localhost:9000’)

d = blaze.Data(c)

source = bokeh.models.BlazeDataSource()

source.from_blaze(d.dat)

plot = bokeh.plotting.figure()

plot.circle(‘A’, ‘B’, source=source)

bokeh.plotting.show(plot)

I can see the data in d.dat but I don’t know what I’m doing wrong otherwise. The data is loaded into the blaze server via:

dat = blaze.Data(‘data.csv’)

server = blaze.Server({‘dat’: dat})

server.run(host=“127.0.0.1”, port=9000)

It’s obvious that I don’t follow the logic but I’m happy to take on any suggestions or would be grateful if somebody can point me in the right direction. Ultimately, my goal is to do downsampling for a scatter/circle plot.

Did you ever get this to work? See there was an update here: blaze.server does not allow CORS · Issue #1131 · blaze/blaze · GitHub

I still cant seem to get rid of this CORS problem. Its fine when I run the embedding examples they provided using the bokeh server and a SimpleHTTPServer…however once you connect these two with the addition of the BlazeServer like you tried to do, it does not work.

···

On Wednesday, May 13, 2015 at 8:38:32 PM UTC+2, [email protected] wrote:

I’m trying to follow the blaze_server.py example and can see the results in my browser. However, when I try to set things up using my own data along with a blaze server then my plots come up empty:

import bokeh.session

import bokeh.plotting

import bokeh.models

import blaze

from blaze.server.client import Client

session = bokeh.session.Session(load_from_config=False)

bokeh.plotting.output_server(‘blaze_source’, session=session)

c = Client(‘localhost:9000’)

d = blaze.Data(c)

source = bokeh.models.BlazeDataSource()

source.from_blaze(d.dat)

plot = bokeh.plotting.figure()

plot.circle(‘A’, ‘B’, source=source)

bokeh.plotting.show(plot)

I can see the data in d.dat but I don’t know what I’m doing wrong otherwise. The data is loaded into the blaze server via:

dat = blaze.Data(‘data.csv’)

server = blaze.Server({‘dat’: dat})

server.run(host=“127.0.0.1”, port=9000)

It’s obvious that I don’t follow the logic but I’m happy to take on any suggestions or would be grateful if somebody can point me in the right direction. Ultimately, my goal is to do downsampling for a scatter/circle plot.