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

"Automatic" datashade/rasterize recalculation does not seem to work in the NYC Taxi example #375

Open
gwerbin opened this issue Apr 2, 2024 · 3 comments

Comments

@gwerbin
Copy link

gwerbin commented Apr 2, 2024

I am new to the Holoviz ecosystem, so I am trying to learn by following the NYC Taxi example for use of Datashader.

Specifically, I am looking at this section: https://examples.holoviz.org/gallery/nyc_taxi/nyc_taxi.html#million-point-datashaded-plots-interactive

I got a Conda environment set up and am able to reproduce all the plots. However I do not see any change when I pan or zoom in the final "rasterized" Bokeh plot.

The doc text suggests that this should "just work":

When you zoom in interactively to this plot, you can see all the points available in that viewport without ever needing to change the plot parameters for that specific zoom level. Each time you zoom or pan, a new image is rendered by Datashader (which takes a few seconds for large datasets), and displayed over or under other plot elements, providing full access to all of your data.

I am not seeing any behavior like this, even after waiting several minutes (the plot itself only takes a few seconds to load or reload). I tried removing hd.dynspread as follows, but still got the same lack of update:

import holoviews.operation.datashader as hd
import colorcet as cc
shaded = hd.rasterize(hv.Points(df, ['dropoff_x', 'dropoff_y']), aggregator=ds.sum('passenger_count'))
shaded.opts(cmap=cc.fire[100:], cnorm='eq_hist', nodata=0)
# hd.dynspread(shaded, threshold=0.5, max_px=10).opts(bgcolor='black', xaxis=None, yaxis=None, width=900, height=500)
shaded.opts(bgcolor='black', xaxis=None, yaxis=None, width=900, height=500)

Am I missing something obvious here? Do I need to enable something in the notebook to get this auto-updating behavior?

I also am not seeing any tooltips on hover, which the doc also implies I should see.

I set up my environment as follows:

git clone 'https://github.com/holoviz-topics/examples' holoviz-examples
cd holoviz-examples/nyc_taxi
micromamba create -p .local/conda -f anaconda-project.yml
micromamba install -p .local/conda ipykernel
.local/conda/bin/python -m ipykernel install --user --name=holoviz-examples.nyc_taxi --display-name='Holoviz Example: NYC Taxi'
mkdir -p data
wget 'https://s3.amazonaws.com/datashader-data/nyc_taxi_wide.parq' -O data/nyc_taxi_wide.parq

Then I ran the notebook in JupyterLab Desktop using the holoviz-examples.nyc_taxi kernel. I checked and confirmed that JL Desktop already has the bokeh-jupyter-bokeh extension installed.

@jbednar
Copy link
Contributor

jbednar commented Apr 3, 2024

Can you check your browser's JavaScript console for errors?

@gwerbin
Copy link
Author

gwerbin commented Apr 3, 2024

Can you check your browser's JavaScript console for errors?

There are errors there, but I am having a problem actually running this in a clean environment including the Jupyter installation.

I realized that Jupyter was somehow picking up my system-level jupyter executable, so I removed that from PATH and installed Jupyter Lab into the Conda env itself:

micromamba create -p .local/conda -f anaconda-project.yml
micromamba install -p .local/conda ipykernel jupyterlab

But then import holoviews as hv failed:

WARNING:param.main: pandas could not register all extension types imports failed with the following error: cannot import name 'ABCIndexClass' from 'pandas.core.dtypes.generic' (/Users/gregory.werbin/work/software/holoviz-examples/nyc_taxi/.local/conda/lib/python3.8/site-packages/pandas/core/dtypes/generic.py)
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[4], line 2
      1 import numpy as np
----> 2 import holoviews as hv
      3 from holoviews import opts
      4 from holoviews.element.tiles import EsriStreet

File ~/work/software/holoviz-examples/nyc_taxi/.local/conda/lib/python3.8/site-packages/holoviews/__init__.py:12
      8 __version__ = str(param.version.Version(fpath=__file__, archive_commit="$Format:%h$",
      9                                         reponame="holoviews"))
     11 from . import util                                       # noqa (API import)
---> 12 from .annotators import annotate                         # noqa (API import)
     13 from .core import archive, config                        # noqa (API import)
     14 from .core.boundingregion import BoundingBox             # noqa (API import)

File ~/work/software/holoviz-examples/nyc_taxi/.local/conda/lib/python3.8/site-packages/holoviews/annotators.py:10
      6 from inspect import getmro
      8 import param
---> 10 from panel.pane import PaneBase
     11 from panel.layout import Row, Tabs
     12 from panel.util import param_name

File ~/work/software/holoviz-examples/nyc_taxi/.local/conda/lib/python3.8/site-packages/panel/__init__.py:1
----> 1 from . import layout # noqa
      2 from . import links # noqa
      3 from . import pane # noqa

File ~/work/software/holoviz-examples/nyc_taxi/.local/conda/lib/python3.8/site-packages/panel/layout/__init__.py:1
----> 1 from .accordion import Accordion # noqa
      2 from .base import Column, ListLike, ListPanel, Panel, Row, WidgetBox # noqa
      3 from .card import Card # noqa

File ~/work/software/holoviz-examples/nyc_taxi/.local/conda/lib/python3.8/site-packages/panel/layout/accordion.py:5
      1 import param
      3 from bokeh.models import Column as BkColumn, CustomJS
----> 5 from .base import NamedListPanel
      6 from .card import Card
      9 class Accordion(NamedListPanel):

File ~/work/software/holoviz-examples/nyc_taxi/.local/conda/lib/python3.8/site-packages/panel/layout/base.py:11
      7 import param
      9 from bokeh.models import Column as BkColumn, Row as BkRow
---> 11 from ..io.model import hold
     12 from ..io.state import state
     13 from ..reactive import Reactive

File ~/work/software/holoviz-examples/nyc_taxi/.local/conda/lib/python3.8/site-packages/panel/io/__init__.py:9
      6 import logging
      7 import sys
----> 9 from ..config import config
     11 from .callbacks import PeriodicCallback # noqa
     12 from .embed import embed_state # noqa

File ~/work/software/holoviz-examples/nyc_taxi/.local/conda/lib/python3.8/site-packages/panel/config.py:20
     15 import param
     17 from pyviz_comms import (JupyterCommManager as _JupyterCommManager,
     18                          extension as _pyviz_extension)
---> 20 from .io.notebook import load_notebook
     21 from .io.state import state
     23 __version__ = str(param.version.Version(
     24     fpath=__file__, archive_commit="$Format:%h$", reponame="panel"))

File ~/work/software/holoviz-examples/nyc_taxi/.local/conda/lib/python3.8/site-packages/panel/io/notebook.py:39
     37 from .embed import embed_state
     38 from .model import add_to_doc, diff
---> 39 from .resources import Bundle, Resources, _env, bundle_resources
     40 from .server import _server_url, _origin_url, get_server
     41 from .state import state

File ~/work/software/holoviz-examples/nyc_taxi/.local/conda/lib/python3.8/site-packages/panel/io/resources.py:19
     13 from bokeh.embed.bundle import (
     14     Bundle as BkBundle, _bundle_extensions, extension_dirs,
     15     bundle_models
     16 )
     18 from bokeh.resources import Resources as BkResources
---> 19 from jinja2 import Environment, Markup, FileSystemLoader
     21 from ..util import url_path
     22 from .state import state

ImportError: cannot import name 'Markup' from 'jinja2' (/Users/gregory.werbin/work/software/holoviz-examples/nyc_taxi/.local/conda/lib/python3.8/site-packages/jinja2/__init__.py)

There are also several errors and warnings in the JS console that appear immediately upon refreshing the page, but I am struggling to export them from the Chrome dev tools. Nothing happens when I right click in the console window and click "Save As". I am using Chrome "Version 123.0.6312.107 (Official Build) (arm64)".

Some of them seem related to Jupyter itself being weird, but this one stood out to me for being so opaque:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'type')
    at Ae (jlab_core.23e8a6b191d1fa15c1b7.js?v=23e8a6b191d1fa15c1b7:1:1201011)
    at jlab_core.23e8a6b191d1fa15c1b7.js?v=23e8a6b191d1fa15c1b7:1:1199337
    at Array.forEach (<anonymous>)
    at r (jlab_core.23e8a6b191d1fa15c1b7.js?v=23e8a6b191d1fa15c1b7:1:1199296)
    at c (jlab_core.23e8a6b191d1fa15c1b7.js?v=23e8a6b191d1fa15c1b7:1:1200479)
    at m (jlab_core.23e8a6b191d1fa15c1b7.js?v=23e8a6b191d1fa15c1b7:1:1763907)
    at Object.l [as emit] (jlab_core.23e8a6b191d1fa15c1b7.js?v=23e8a6b191d1fa15c1b7:1:1763583)
    at a.emit (jlab_core.23e8a6b191d1fa15c1b7.js?v=23e8a6b191d1fa15c1b7:1:1761420)
    at xe._onCellInViewportChanged (jlab_core.23e8a6b191d1fa15c1b7.js?v=23e8a6b191d1fa15c1b7:1:1153452)
    at m (jlab_core.23e8a6b191d1fa15c1b7.js?v=23e8a6b191d1fa15c1b7:1:1763907)

@gwerbin
Copy link
Author

gwerbin commented May 13, 2024

Any advice would be appreciated. Is there a video out there that demonstrates what datashading recalculation on zoom should look like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants