holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.66k stars 396 forks source link

QuadMesh update when running bokeh server #3107

Closed pjvalla closed 5 years ago

pjvalla commented 5 years ago

Getting this very lengthy error output when running a bokeh server app.

ERROR:bokeh.server.protocol_handler:error handling message Message 'PATCH-DOC' (revision 1) content: {'references': [{'type': 'Range1d', 'id': '1036', 'attributes': {'callback': None, 'end': 3011764, 'reset_start': 0, 'reset_end': 3011764}}, {'type': 'Range1d', 'id': '1037', 'attributes': {'callback': None, 'start': -0.03666035132482648, 'end': 0.036965536419302225, 'reset_start': -0.03666035132482648, 'reset_end': 0.0369655 ...

(this message goes on for a long while -- log file is on the order of mega bytes).

However, the application does run and behaves how I expect it.

selection_holo

The issue is occurs when trying to update 'hover' quadmesh frame p3 created by the hover_gen function. I get the above message even when just plotting p3. Sorry I can post fully functional code as it currently requires other modules that I cannot share.

I am fairly new to using holoviews. Assuming the error is on my end, but I don't seem to have the proper visibility to make progress.

def plot_bokeh_spectrum(sig, legend=None, fft_size=1024):

    plot_height = 400
    opts_spec = dict(width=1200, height=plot_height, xticks=10, yticks=10, xrotation=10, colorbar=False, fontsize=dict(xlabel=20, ylabel=20, xticks=10, yticks=10))
    opts_hover = dict(tools=['hover'], alpha=0, hover_alpha=0.2, fill_alpha=0)
    def gen_spec_points(rangex):
        if rangex is None:
            sig_int = sig
        else:
            lidx = int(rangex[0])
            ridx = int(rangex[1])
            sig_int = sig[lidx:ridx]

        (omega_init, resp_init) = waterfall_spec(sig_int, fft_size=fft_size, window='rect', noverlap=0, num_avgs=1)
        step_size = 2. / fft_size
        discrete_freq = omega_init[0, :]
        spectral_slice = np.arange(0, np.shape(omega_init)[0], dtype=np.int)
        df = pd.DataFrame(resp_init, index=spectral_slice, columns=discrete_freq)
        df.columns.name = 'Discrete Frequency'
        df.index.name = 'Spectral Slice'
        xrange = (discrete_freq[0], discrete_freq[-1])
        yrange = (spectral_slice[0], spectral_slice[-1])
        source = pd.DataFrame(df.stack(), columns=['PowerdB']).reset_index()
        step_size = source['Discrete Frequency'][1] - source['Discrete Frequency'][0]
        points = hv.Points(source, kdims=['Discrete Frequency', 'Spectral Slice'], vdims=['PowerdB'], group='Spectrum', label='Waterfall')
        return points, xrange, yrange, step_size

    def hover_gen(xrange):
        points, xrange, yrange, step_size = gen_spec_points(xrange)
        ymax = np.max(points['Spectral Slice'])
        xlen = points.shape[0] // ymax
        width = int(xlen / 50)
        # divide height into 50 blocks
        height = int(ymax / 50)
        print(height, width)

        agg = aggregate(points, width=50, height=50, x_range=xrange, y_range=yrange, dynamic=False,
                        aggregator=ds.max('PowerdB'), x_sampling=step_size, y_sampling=1, link_inputs=False)  
        return hv.QuadMesh(agg).options(**opts_hover)

    def gen_spec(xrange):
        points, xrange, yrange, step_size = gen_spec_points(xrange)
        heat_ds = datashade(points, aggregator=ds.min('PowerdB'), dynamic=False, cmap=Viridis256, clims=(0, 255),
                            normalization='linear', x_sampling=step_size, y_sampling=1, x_range=xrange, y_range=yrange).options(**opts_spec)

        return heat_ds

    x_vals = np.arange(0, len(sig), dtype=np.int)
    data_dict = {'time':x_vals, 'real':np.real(sig), 'imag':np.imag(sig)}
    data = pd.DataFrame(data_dict, columns = ['time', 'real', 'imag'])

    yrange0 = (1.25*data.real.min(), 1.25*data.real.max())
    yrange1 = (1.25*data.imag.min(), 1.25*data.imag.max())
    xrange = (int(data.time.min()), int(data.time.max()))

    Curve = hv.Curve(data, 'time', vdims='real', group='Time', label='Real')
    Curve1 = hv.Curve(data, 'time', vdims='imag', group='Time', label='Imag')
    rangex = hv.streams.RangeX(source=Curve)
    opts = dict(width=600, height=plot_height, xticks=5, yticks=10, xrotation=10, fontsize=dict(xlabel=20, ylabel=20, xticks=10, yticks=10))
    p0 = datashade(Curve, cmap='red', y_range=yrange0).options(**opts)
    p1 = datashade(Curve1, y_range=yrange1).options(**opts)

    p2 = hv.DynamicMap(lambda x_range : gen_spec(x_range), streams=[rangex]).opts(norm=dict(framewise=True)) # , kdims=['Spectral Slice'])
    p3 = hv.DynamicMap(lambda x_range : hover_gen(x_range), streams=[rangex]).opts(norm=dict(framewise=True)) # , kdims=['Spectral Slice'])

    layout = (p0 + p1 + p2 * p3).cols(2)
    app = renderer.app(layout, show=True, new_window=False)

    print(app)
philippjfr commented 5 years ago

Thanks for reporting this, I think this is a duplicate of https://github.com/ioam/holoviews/issues/2777.

pjvalla commented 5 years ago

Okay. Thanks, so just deal with the output until the next release?

BTW, great work.

pjvalla commented 5 years ago

Just for completeness -- these are the packages I am using:

# Name                    Version                   Build  Channel
arrow-cpp                 0.2.post                      0    conda-forge
asn1crypto                0.24.0                   py36_0  
atomicwrites              1.2.1                      py_0    conda-forge
attrs                     18.2.0                     py_0    conda-forge
backcall                  0.1.0                      py_0    conda-forge
blas                      1.0                         mkl  
bleach                    3.0.2                    py36_0  
bokeh                     1.0.0                    py36_0  
bottleneck                1.2.1            py36h035aef0_1  
bzip2                     1.0.6                h470a237_2    conda-forge
ca-certificates           2018.03.07                    0  
cairo                     1.14.12              h7636065_2  
cartopy                   0.16.0           py36hfa13621_0  
certifi                   2018.10.15               py36_0  
cffi                      1.11.5           py36he75722e_1  
cftime                    1.0.0b1          py36h035aef0_0  
chardet                   3.0.4                    py36_1  
click                     7.0                        py_0    conda-forge
click-plugins             1.0.4                    py36_0  
cligj                     0.5.0                    py36_0  
cloudpickle               0.6.1                      py_0    conda-forge
colorcet                  1.0.0                      py_0    conda-forge
cryptography              2.3.1            py36hc365091_0  
curl                      7.61.1               h74213dd_2    conda-forge
cycler                    0.10.0                     py_1    conda-forge
cython                    0.28.5           py36hf484d3e_0  
cytoolz                   0.9.0.1          py36h14c3975_1  
dask                      0.19.4                     py_0    conda-forge
dask-core                 0.19.4                     py_0    conda-forge
datashader                0.6.8                      py_0    conda-forge
datashape                 0.5.4                    py36_1  
dbus                      1.13.0               h3a4f0e9_0    conda-forge
decorator                 4.3.0                      py_0    conda-forge
descartes                 1.1.0                    py36_0  
distributed               1.23.3                   py36_0  
entrypoints               0.2.3                    py36_2  
expat                     2.2.5                hfc679d8_2    conda-forge
fastparquet               0.1.6            py36h7b6447c_0  
fiona                     1.7.12           py36h3f37509_0  
fontconfig                2.12.6               h49f89f6_0  
freetype                  2.8                  hab7d2ae_1  
freexl                    1.0.5                h14c3975_0  
futures-compat            1.0                       py3_0  
gdal                      2.2.4            py36h04863e7_1  
geopandas                 0.3.0                    py36_0  
geos                      3.6.2                hfc679d8_3    conda-forge
geoviews                  1.5.4a13                   py_0    pyviz/label/dev
geoviews-core             1.5.4a13                   py_0    pyviz/label/dev
gettext                   0.19.8.1             h5e8e0c9_1    conda-forge
giflib                    5.1.4                h14c3975_1  
glib                      2.56.2               h464dc38_0    conda-forge
gmp                       6.1.2                h6c8ec71_1  
gst-plugins-base          1.12.5               hde13a9d_0    conda-forge
gstreamer                 1.12.5               h5856ed1_0    conda-forge
h5netcdf                  0.6.2                      py_0    conda-forge
h5py                      2.8.0            py36h39dcb92_0  
hdf4                      4.2.13               h951d187_2    conda-forge
hdf5                      1.8.18               h6792536_1  
heapdict                  1.0.0                    py36_2  
holoviews                 1.11.0a8                   py_0    pyviz/label/dev
hvplot                    0.2.1                      py_1    conda-forge
icu                       58.2                 hfc679d8_0    conda-forge
idna                      2.7                      py36_0  
imageio                   2.3.0                      py_1    conda-forge
intel-openmp              2019.0                      118  
ipdb                      0.11                       py_1    conda-forge
ipykernel                 5.1.0            py36h39e3cac_0  
ipython                   7.0.1            py36h39e3cac_0  
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.4.2                    py36_0  
jedi                      0.13.1                   py36_0  
jemalloc                  5.1.0                hfc679d8_0    conda-forge
jinja2                    2.10                       py_1    conda-forge
jpeg                      9c                   h470a237_1    conda-forge
json-c                    0.13.1               h1bed415_0  
jsonschema                2.6.0                    py36_0  
jupyter                   1.0.0                      py_1    conda-forge
jupyter_client            5.2.3                    py36_0  
jupyter_console           6.0.0                    py36_0  
jupyter_core              4.4.0                    py36_0  
jupyterlab                0.35.2                   py36_0  
jupyterlab_server         0.2.0                      py_0    conda-forge
kealib                    1.4.7                h5472223_5  
kiwisolver                1.0.1            py36hf484d3e_0  
krb5                      1.16.1               hbb41f41_0    conda-forge
libboost                  1.67.0               h46d08c1_4  
libcurl                   7.61.1               hbdb9355_2    conda-forge
libdap4                   3.19.1               h6ec2957_0  
libedit                   3.1.20170329         haf1bffa_1    conda-forge
libffi                    3.2.1                hfc679d8_5    conda-forge
libgcc-ng                 8.2.0                hdf63c60_1  
libgdal                   2.2.4                heea9cce_1  
libgfortran               3.0.0                         1    conda-forge
libgfortran-ng            7.2.0                hdf63c60_3    conda-forge
libiconv                  1.15                 h470a237_3    conda-forge
libkml                    1.3.0                h590aaf7_4  
libnetcdf                 4.6.1                h015f1c5_0  
libpng                    1.6.35               ha92aebf_2    conda-forge
libpq                     10.5                 h1ad7b7a_0  
libsodium                 1.0.16               h1bed415_0  
libspatialindex           1.8.5                h20b78c2_2  
libspatialite             4.3.0a              he475c7f_19  
libssh2                   1.8.0                h5b517e9_2    conda-forge
libstdcxx-ng              8.2.0                hdf63c60_1  
libtiff                   4.0.9                he6b73bb_2    conda-forge
libuuid                   1.0.3                h1bed415_2  
libxcb                    1.13                 h470a237_2    conda-forge
libxml2                   2.9.8                h422b904_5    conda-forge
libxslt                   1.1.32               h88dbc4e_2    conda-forge
llvmlite                  0.24.0           py36hdbcaa40_0  
locket                    0.2.0                      py_2    conda-forge
lxml                      4.2.5            py36hefd8a0e_0  
markdown                  3.0.1                    py36_0  
markupsafe                1.0              py36h14c3975_1  
matplotlib                2.2.2            py36h0e671d2_0  
mistune                   0.8.4            py36h7b6447c_0  
mkl                       2019.0                      118  
mkl_fft                   1.0.4            py36h4414c95_1  
mkl_random                1.0.1            py36h4414c95_1  
more-itertools            4.3.0                    py36_0  
mpmath                    1.0.0                      py_1    conda-forge
msgpack-python            0.5.6            py36h6bb024c_1  
multipledispatch          0.6.0                      py_0    conda-forge
munch                     2.3.2                    py36_0  
nbconvert                 5.3.1                    py36_0  
nbformat                  4.4.0                    py36_0  
ncurses                   6.1                  hfc679d8_1    conda-forge
netcdf4                   1.4.1            py36h083d9da_0  
networkx                  2.2                        py_1    conda-forge
notebook                  5.7.0                    py36_0  
numba                     0.39.0           py36h04863e7_0  
numpy                     1.15.3           py36h1d66e8a_0  
numpy-base                1.15.3           py36h81de0dd_0  
olefile                   0.46                       py_0    conda-forge
openblas                  0.3.3                ha44fe06_1    conda-forge
openjpeg                  2.3.0                h05c96fa_1  
openssl                   1.0.2p               h14c3975_0  
owslib                    0.17.0                     py_0    conda-forge
packaging                 18.0                       py_0    conda-forge
pandas                    0.23.4           py36h04863e7_0  
pandoc                    2.2.3.2                       0  
pandocfilters             1.4.2                    py36_1  
panel                     0.1.2                         0    conda-forge
param                     1.8.1                      py_0    conda-forge
parambokeh                0.2.3                      py_0    pyviz/label/dev
paramnb                   2.0.4                      py_0    pyviz/label/dev
parquet-cpp               1.1.0                         1    conda-forge
parso                     0.3.1                      py_0    conda-forge
partd                     0.3.9                      py_0    conda-forge
pcre                      8.42                 h439df22_0  
pexpect                   4.6.0                    py36_0  
phantomjs                 2.1.1                         0    pyviz/label/dev
pickleshare               0.7.5                    py36_0  
pillow                    5.1.0            py36h3deb7b8_0  
pip                       10.0.1                   py36_0  
pixman                    0.34.0               hceecf20_3  
pluggy                    0.8.0                      py_0    conda-forge
poppler                   0.65.0               ha54bb34_0  
poppler-data              0.4.9                         0  
proj4                     5.0.1                h14c3975_0  
prometheus_client         0.4.2                    py36_0  
prompt_toolkit            2.0.6                      py_0    conda-forge
psutil                    5.4.7            py36h14c3975_0  
psycopg2                  2.7.5            py36hb7f436b_0  
pthread-stubs             0.4                  h470a237_1    conda-forge
ptyprocess                0.6.0                    py36_0  
py                        1.7.0                      py_0    conda-forge
pyarrow                   0.1.post                      1    conda-forge
pycparser                 2.19                       py_0    conda-forge
pyct                      0.4.5                      py_0    conda-forge
pyct-core                 0.4.5                      py_0    conda-forge
pyepsg                    0.3.2                      py_1    conda-forge
pygments                  2.2.0                      py_1    conda-forge
pyopenssl                 18.0.0                   py36_0  
pyparsing                 2.2.2                      py_0    conda-forge
pyproj                    1.9.5.1          py36h7b21b82_1  
pyqt                      5.6.0            py36h22d08a2_6  
pysal                     1.14.4.post1             py36_1  
pyshp                     1.2.12                     py_0    conda-forge
pysocks                   1.6.8                    py36_0  
pytest                    3.9.1                    py36_0  
python                    3.6.6                hc3d631a_0  
python-dateutil           2.7.3                      py_0    conda-forge
python-snappy             0.5.2            py36hf484d3e_0  
pytz                      2018.5                     py_0    conda-forge
pyviz                     0.9.13a2                   py_0    pyviz/label/dev
pyviz_comms               0.6.0                      py_0    pyviz
pywavelets                1.0.1            py36hdd07704_0  
pyyaml                    3.13             py36h14c3975_0  
pyzmq                     17.1.2           py36h14c3975_0  
qt                        5.6.2               h974d657_12  
qtconsole                 4.4.2                    py36_0  
readline                  7.0                  haf1bffa_1    conda-forge
requests                  2.19.1                   py36_0  
rise                      5.3.0                    py36_0    pyviz/label/dev
rtree                     0.8.3                    py36_0  
scikit-image              0.14.0           py36hf484d3e_1  
scipy                     1.1.0            py36hfa4b5c9_1  
selenium                  3.14.1           py36h7b6447c_0  
send2trash                1.5.0                    py36_0  
setuptools                40.4.3                   py36_0  
shapely                   1.6.4            py36h7ef4460_0  
simplegeneric             0.8.1                      py_1    conda-forge
sip                       4.18.1           py36hf484d3e_2  
six                       1.11.0                   py36_1  
snappy                    1.1.7                hbae5bb6_3  
sortedcontainers          2.0.5                      py_0    conda-forge
sqlalchemy                1.2.12           py36h7b6447c_0  
sqlite                    3.25.2               hb1c47c0_0    conda-forge
streamz                   0.5.0                    py36_0  
tblib                     1.3.2                      py_1    conda-forge
terminado                 0.8.1                    py36_1  
testpath                  0.3.1                    py36_0  
thrift                    0.11.0           py36hf484d3e_0  
tk                        8.6.8                ha92aebf_0    conda-forge
toolz                     0.9.0                      py_1    conda-forge
tornado                   5.1.1            py36h7b6447c_0  
traitlets                 4.3.2                    py36_0  
urllib3                   1.23                     py36_0  
wcwidth                   0.1.7                      py_1    conda-forge
webencodings              0.5.1                    py36_1  
wheel                     0.32.2                   py36_0  
widgetsnbextension        3.4.2                    py36_0  
xarray                    0.10.9                   py36_0  
xerces-c                  3.2.1                hac72e42_0  
xorg-libxau               1.0.8                h470a237_6    conda-forge
xorg-libxdmcp             1.1.2                h470a237_7    conda-forge
xz                        5.2.4                h470a237_1    conda-forge
yaml                      0.1.7                h470a237_1    conda-forge
zeromq                    4.2.5                hf484d3e_1  
zict                      0.1.3                      py_0    conda-forge
zlib                      1.2.11               h470a237_3    conda-forge
philippjfr commented 5 years ago

I think it requires an upstream fix in bokeh (see https://github.com/bokeh/bokeh/issues/4096). I'll try to put together a PR this weekend.

philippjfr commented 5 years ago

Just submitted a PR upstream: https://github.com/bokeh/bokeh/pull/8371

philippjfr commented 5 years ago

My PR in bokeh fixing this was just merged, and the fix should land in bokeh 1.0.1.