Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datashader on bokeh server #1536

Closed
stevievb opened this issue Jun 13, 2017 · 19 comments
Closed

datashader on bokeh server #1536

stevievb opened this issue Jun 13, 2017 · 19 comments
Labels
type: docs Related to the documentation and examples
Milestone

Comments

@stevievb
Copy link

stevievb commented Jun 13, 2017

I'm trying to using holoviews, bokeh server, and datashader based somewhat on the example in issue #959. I'm getting the following error and I'm not sure how to debug it:

ERROR:bokeh.server.protocol.server_handler:error handling message Message 'PATCH-DOC' (revision 1): AttributeError("'NoneType' object has no attribute '_session_callbacks'",)

The plot shows up and looks correct but the datashading aspect on zoom does not seem to be working and throws that error.

My bokeh application code is ---

import numpy as np
import holoviews as hv
from holoviews.operation.datashader import datashade
import holoviews.plotting.bokeh # noqa (Activate backend)
from bokeh.layouts import row
from bokeh.plotting import curdoc

doc = curdoc()

renderer = hv.Store.renderers['bokeh'].instance(mode='server', holomap='server')
options = hv.Store.options(backend='bokeh')

y = np.random.standard_normal(size = 2000000)
x = np.arange(len(y)) / 200000.0

curve = hv.Curve((x, y))
datashaded = datashade(curve, cmap=["blue"])

plot = renderer.get_plot(datashaded)

layout = row(plot.state)

doc.add_root(layout)

conda env ---

dependencies:
- !!python/unicode
  'colorcet=0.9.1=py35_0'
- !!python/unicode
  'datashader=0.5.0=py35_0'
- !!python/unicode
  'bleach=1.5.0=py35_0'
- !!python/unicode
  'bokeh=0.12.5=py35_1'
- !!python/unicode
  'bzip2=1.0.6=vc14_3'
- !!python/unicode
  'cloudpickle=0.2.2=py35_0'
- !!python/unicode
  'colorama=0.3.9=py35_0'
- !!python/unicode
  'cycler=0.10.0=py35_0'
- !!python/unicode
  'dask=0.14.3=py35_1'
- !!python/unicode
  'datashape=0.5.4=py35_0'
- !!python/unicode
  'decorator=4.0.11=py35_0'
- !!python/unicode
  'entrypoints=0.2.2=py35_1'
- !!python/unicode
  'freetype=2.5.5=vc14_2'
- !!python/unicode
  'h5py=2.6.0=np111py35_2'
- !!python/unicode
  'hdf5=1.8.15.1=vc14_4'
- !!python/unicode
  'holoviews=1.7.0=py35_0'
- !!python/unicode
  'html5lib=0.999=py35_0'
- !!python/unicode
  'icu=57.1=vc14_0'
- !!python/unicode
  'ipykernel=4.6.1=py35_0'
- !!python/unicode
  'ipython=6.1.0=py35_0'
- !!python/unicode
  'ipython_genutils=0.2.0=py35_0'
- !!python/unicode
  'ipywidgets=6.0.0=py35_0'
- !!python/unicode
  'jedi=0.10.2=py35_2'
- !!python/unicode
  'jinja2=2.9.4=py35_0'
- !!python/unicode
  'jpeg=9b=vc14_0'
- !!python/unicode
  'jsonschema=2.6.0=py35_0'
- !!python/unicode
  'jupyter=1.0.0=py35_3'
- !!python/unicode
  'jupyter_client=5.0.1=py35_0'
- !!python/unicode
  'jupyter_console=5.1.0=py35_0'
- !!python/unicode
  'jupyter_core=4.3.0=py35_0'
- !!python/unicode
  'libpng=1.6.27=vc14_0'
- !!python/unicode
  'libtiff=4.0.6=vc14_3'
- !!python/unicode
  'llvmlite=0.18.0=py35_0'
- !!python/unicode
  'locket=0.2.0=py35_1'
- !!python/unicode
  'markupsafe=0.23=py35_2'
- !!python/unicode
  'matplotlib=2.0.2=np111py35_0'
- !!python/unicode
  'mistune=0.7.4=py35_0'
- !!python/unicode
  'mkl=11.3.3=1'
- !!python/unicode
  'multipledispatch=0.4.9=py35_0'
- !!python/unicode
  'nbconvert=5.2.1=py35_0'
- !!python/unicode
  'nbformat=4.3.0=py35_0'
- !!python/unicode
  'networkx=1.11=py35_0'
- !!python/unicode
  'notebook=5.0.0=py35_0'
- !!python/unicode
  'numba=0.33.0=np111py35_0'
- !!python/unicode
  'numpy=1.11.2=py35_0'
- !!python/unicode
  'odo=0.5.0=py35_1'
- !!python/unicode
  'olefile=0.44=py35_0'
- !!python/unicode
  'openssl=1.0.2l=vc14_0'
- !!python/unicode
  'pandas=0.20.1=np111py35_0'
- !!python/unicode
  'pandocfilters=1.4.1=py35_0'
- !!python/unicode
  'partd=0.3.8=py35_0'
- !!python/unicode
  'path.py=10.3.1=py35_0'
- !!python/unicode
  'pickleshare=0.7.4=py35_0'
- !!python/unicode
  'pillow=4.1.1=py35_0'
- !!python/unicode
  'pip=9.0.1=py35_1'
- !!python/unicode
  'prompt_toolkit=1.0.14=py35_0'
- !!python/unicode
  'pygments=2.2.0=py35_0'
- !!python/unicode
  'pyparsing=2.1.4=py35_0'
- !!python/unicode
  'pyqt=5.6.0=py35_2'
- !!python/unicode
  'python=3.5.2=0'
- !!python/unicode
  'python-dateutil=2.6.0=py35_0'
- !!python/unicode
  'pytz=2017.2=py35_0'
- !!python/unicode
  'pyyaml=3.12=py35_0'
- !!python/unicode
  'pyzmq=16.0.2=py35_0'
- !!python/unicode
  'qt=5.6.2=vc14_4'
- !!python/unicode
  'qtconsole=4.3.0=py35_0'
- !!python/unicode
  'requests=2.12.4=py35_0'
- !!python/unicode
  'scipy=0.18.1=np111py35_0'
- !!python/unicode
  'setuptools=27.2.0=py35_1'
- !!python/unicode
  'simplegeneric=0.8.1=py35_1'
- !!python/unicode
  'sip=4.18=py35_0'
- !!python/unicode
  'six=1.10.0=py35_0'
- !!python/unicode
  'sqlalchemy=1.1.6=py35_0'
- !!python/unicode
  'testpath=0.3.1=py35_0'
- !!python/unicode
  'tk=8.5.18=vc14_0'
- !!python/unicode
  'toolz=0.8.2=py35_0'
- !!python/unicode
  'tornado=4.4.2=py35_0'
- !!python/unicode
  'traitlets=4.3.2=py35_0'
- !!python/unicode
  'vs2015_runtime=14.0.25123=0'
- !!python/unicode
  'wcwidth=0.1.7=py35_0'
- !!python/unicode
  'wheel=0.29.0=py35_0'
- !!python/unicode
  'widgetsnbextension=2.0.0=py35_0'
- !!python/unicode
  'win_unicode_console=0.5=py35_0'
- !!python/unicode
  'xarray=0.9.6=py35_0'
- !!python/unicode
  'zlib=1.2.8=vc14_3'
- !!python/unicode
  'param=1.5.1=py35_0'
- pip:
  - aiofiles==0.3.0
  - aiohttp==1.2.0
  - aiohttp-cors==0.5.0
  - aiohttp-jinja2==0.13.0
  - aiopg==0.13.0
  - alembic==0.9.0
  - async-timeout==1.1.0
  - asyncpg==0.9.0
  - asyncpgsa==0.8.2
  - bkcharts==0.1
  - certifi==2017.4.17
  - chardet==3.0.3
  - freezegun==0.3.8
  - idna==2.5
  - ipython-genutils==0.2.0
  - jupyter-client==5.0.1
  - jupyter-console==5.1.0
  - jupyter-core==4.3.0
  - mako==1.0.6
  - multidict==2.1.4
  - prompt-toolkit==1.0.14
  - psycopg2==2.6.2
  - py==1.4.32
  - pyserial==3.2.1
  - pyserial-asyncio==0.3
  - pytest==3.0.6
  - pytest-aiohttp==0.1.3
  - python-editor==1.0.3
  - rx==1.5.8
  - urllib3==1.21.1
  - win-unicode-console==0.5
  - yarl==0.8.1
@jlstevens
Copy link
Contributor

jlstevens commented Jun 13, 2017

Thanks for filing this issue!

My first suggestion is you update to Bokeh 0.12.6 which just released a few hours ago to see if the problem persists.

I think you might also want to try the holoviews dev version that you can get with:

conda install -c ioam/label/dev holoviews

Alternatively, if you are comfortable testing things against the current HoloViews master branch, that might be preferable.

@stevievb
Copy link
Author

Upgrading both of those packages as you instructed did not seem to help.

@philippjfr
Copy link
Member

@stevievb Very simple fix, I'll have a user guide up to explain this stuff soon, simply change this line by passing the doc in:

plot = renderer.get_plot(datashaded, doc=doc)

@philippjfr
Copy link
Member

That said the simpler thing to do all around is this:

import numpy as np
import holoviews as hv
from holoviews.operation.datashader import datashade
import holoviews.plotting.bokeh # noqa (Activate backend)

y = np.random.standard_normal(size = 2000000)
x = np.arange(len(y)) / 200000.0

curve = hv.Curve((x, y))
datashaded = datashade(curve, cmap=["blue"])

doc = hv.renderer('bokeh').server_doc(datashaded)

@philippjfr philippjfr added the type: docs Related to the documentation and examples label Jun 15, 2017
@philippjfr philippjfr added this to the v1.8 milestone Jun 15, 2017
@stevievb
Copy link
Author

Hey that all worked. Thanks for your help.

@jlstevens
Copy link
Contributor

@philippjfr Think you'll be able to add something to the docs about this for 1.8?

@lbbui
Copy link

lbbui commented Jun 20, 2017

How are you running this along with Bokeh server? If the application is called app.py, are you using:

bokeh serve app.py

Is this correct?

@jlstevens
Copy link
Contributor

@loc1978 That's right. You can try some of our examples here though you'll probably need a dev version of holoviews to run them.

@lbbui
Copy link

lbbui commented Jun 21, 2017

Thanks for the quick reply. Unfortunately I'm having a lot of trouble getting a simple example to work. When I try to run this one:

https://github.com/ioam/holoviews/blob/master/examples/apps/bokeh/selection_stream.py

I get: AttributeError: module 'holoviews' has no attribute 'renderer'

I'm currently using the latest holoviews version 1.8.dev1 -- Is this the correct version?

@philippjfr
Copy link
Member

I'm currently using the latest holoviews version 1.8.dev1 -- Is this the correct version?

There is currently no release that includes hv.renderer function, we'll try to releasing a 1.8dev3 asap.

@lbbui
Copy link

lbbui commented Jun 21, 2017

EDIT: Nevermind, I got it to work, there were conflicting packages in Anaconda. Here are the module versions that worked for this code: #959

bokeh: 0.12.6
holoviews: 1.8.dev1
datashader: 0.6.0.dev2

@stevievb
Copy link
Author

Somewhat related - Is it possible to pass plot or style options with this setup?

For example, is something like this supported?:

curve = hv.Curve((x, y))(plot=dict(yaxis=None))
datashaded = datashade(curve, cmap=["blue"])

I see towards the bottom of this page (https://anaconda.org/jbednar/holoviews_datashader/notebook) an example of passing width and height parameters to the datashade function but in my testing it seems to have no effect. What is the correct way to set the width/height?

datashaded = datashade(curve, cmap=["blue"], width=800, height=800)

@jbednar
Copy link
Member

jbednar commented Jun 23, 2017

The arguments to the datashade() operations determine the initial width and height of the rasterized array, which is important in that example because a static .HTML export uses only this initial value. If not for that one detail, those values can safely be omitted in normal usage.

After the initial rendering, by default the value is set dynamically by the size of the bokeh plot in which the datashader plot is embedded, and so in interactive use you will indeed not notice any effect of those settings. In this case you can use the normal HoloViews mechanisms to set the Bokeh plot size. The (plot=...) syntax is currently supported and will work fine, though there is a better syntax that has been added that maybe @jlstevens or @philippjfr could describe.

@philippjfr
Copy link
Member

Something like this should work:

datashaded = datashade(curve, cmap=["blue"])
datashaded(plot={'RGB': dict(width=800, height=800)})

@stevievb
Copy link
Author

@philippjfr Thanks that seemed to work with a slight modification.

datashaded = datashade(curve, cmap=["blue"])
datashaded = datashaded(plot={'RGB': dict(width=800, height=800)})

@philippjfr
Copy link
Member

philippjfr commented Jun 23, 2017

Ah sorry, what I did was for interactive notebook usage, in a script you definitely have to assign it back to the variable. I've also made another mistake, we recently introduced .opts which we recommend instead of the __call__ version so that should be:

plot_opts = {'RGB': dict(width=800, height=800)}
datashaded = datashade(curve, cmap=["blue"]).opts(plot=plot_opts)

@lbbui
Copy link

lbbui commented Jun 27, 2017

Hello all again,

I'd like the user to be able to filter the data and most Bokeh examples use ColumnDataSource to achieve this task (ex. https://github.com/bokeh/bokeh/blob/master/examples/app/weather/main.py). Is there a way to use this function with holoviews/datashader/bokeh? Or is there another way to filter the data that will trigger a plot update?

Something like this?

import numpy as np
import holoviews as hv
import holoviews.plotting.bokeh
from holoviews.operation.datashader import datashade
from bokeh.models import ColumnDataSource

hv.Store.current_backend = 'bokeh'
renderer = hv.Store.renderers['bokeh'].instance(mode='server', holomap='server')
d = np.random.multivariate_normal((0,0), [[0.1, 0.1], [0.1, 1.0]], (1000000,))
source = ColumnDataSource(d)
points = hv.Points(source)
datashaded = datashade(points, x_sampling=0.01, y_sampling=0.01)
doc, _ = renderer(datashaded)

@jlstevens
Copy link
Contributor

@philippjfr Should this issue be closed or bumped to the next milestone?

@philippjfr
Copy link
Member

Closing this as it seems to have been addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: docs Related to the documentation and examples
Projects
None yet
Development

No branches or pull requests

5 participants