Skip to content

Can't mix pn.bind with streams in DynamicMaps anymore #6008

@TheoMathurin

Description

@TheoMathurin

HoloViews 1.18.1
Param 2.0.1
Panel 1.3.4

Description of expected behavior and the observed behavior

I used to be able to wrap a pn.bind within a DynamicMap and add a streams argument like the following:
dmap = hv.DynamicMap(pn.bind(function, arg=some_widget), streams=[some_stream])

This is useful for plots driven both by widgets and streams.

But now this causes an error where expected inputs are missing, maybe related to the new Param version.

MRE

In a panel server

import holoviews as hv
import panel as pn

pn.extension()


def make_plot(z, x_range, y_range):
    print(z)
    print(x_range, y_range)
    return hv.Curve([1, 2, 3, 4])


slider = pn.widgets.IntSlider(name='Slider', start=0, end=10)
range_xy = hv.streams.RangeXY()
dmap = hv.DynamicMap(pn.bind(make_plot, z=slider), streams=[range_xy])

pn.Column(slider, dmap).servable()

Stack traceback and/or browser JavaScript console output

return eval_fn()(*combined_args, **combined_kwargs) Traceback (most recent call last):
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/bokeh/application/handlers/code_runner.py", line 229, in run
    exec(self._code, module.__dict__)
  File "/home/mathurin/PycharmProjects/test/toast.py", line 18, in <module>
    pn.Column(slider, dmap).servable()
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/panel/viewable.py", line 394, in servable
    self.server_doc(title=title, location=location) # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/panel/viewable.py", line 1023, in server_doc
    model = self.get_root(doc)
            ^^^^^^^^^^^^^^^^^^
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/panel/layout/base.py", line 309, in get_root
    root = super().get_root(doc, comm, preprocess)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/panel/viewable.py", line 670, in get_root
    root = self._get_model(doc, comm=comm)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/panel/layout/base.py", line 177, in _get_model
    objects, _ = self._get_objects(model, [], doc, root, comm)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/panel/layout/base.py", line 159, in _get_objects
    child = pane._get_model(doc, root, model, comm)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/panel/pane/holoviews.py", line 414, in _get_model
    plot = self._render(doc, comm, root)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/panel/pane/holoviews.py", line 509, in _render
    return renderer.get_plot(self.object, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/holoviews/plotting/bokeh/renderer.py", line 68, in get_plot
    plot = super().get_plot(obj, doc, renderer, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/holoviews/plotting/renderer.py", line 217, in get_plot
    initialize_dynamic(obj)
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/holoviews/plotting/util.py", line 270, in initialize_dynamic
    dmap[dmap._initial_key()]
    ~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/holoviews/core/spaces.py", line 550, in __call__
    return self.callable.rx.value
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/param/reactive.py", line 253, in value
    return self._reactive()
           ^^^^^^^^^^^^^^^^
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/param/depends.py", line 41, in _depends
    return func(*args, **kw)
           ^^^^^^^^^^^^^^^^^
  File "/home/mathurin/miniconda3/envs/hv/lib/python3.12/site-packages/param/reactive.py", line 431, in wrapped
    return eval_fn()(*combined_args, **combined_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: make_plot() missing 2 required positional arguments: 'x_range' and 'y_range'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions