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

Interaction in ipyleaflet maps stopped working in v0.4.0+ #174

Open
thohan88 opened this issue Dec 27, 2024 · 2 comments
Open

Interaction in ipyleaflet maps stopped working in v0.4.0+ #174

thohan88 opened this issue Dec 27, 2024 · 2 comments

Comments

@thohan88
Copy link

First of all, thanks for all the work on bringing ipywidgets to shiny, it is fantastic and much appreciated.

Description:
Since updating shinywidgets to v0.4.0, apps using ipyleaflet for interactive map updates (e.g., adding, updating, and removing markers) have stopped working. The app exits on update and the error message below is shown in the terminal. This issue seems to be introduced in commit 72d16f5. Installing from all previous commits (<=v0.3.4.9000) works perfectly.

Reproducible example:

Local environment:

  • python: 3.11
  • shiny: 1.2.1
  • shinywidgets: 0.4.0+
  • ipyleaflet: 0.19.1
  • ipywidgets: 8.1.5

Error message (shinylive):

Traceback (most recent call last):
  File "/lib/python3.12/site-packages/shiny/reactive/_reactives.py", line 584, in _run
    await self._fn()
  File "/lib/python3.12/site-packages/shiny/_utils.py", line 279, in fn_async
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/pyodide/app_kh331apovkrx44kaospm/app.py", line 36, in update_markers
    m.add(markers[id])
  File "/lib/python3.12/site-packages/ipyleaflet/leaflet.py", line 3150, in add
    self.layers = tuple([layer for layer in self.layers] + [item])
    ^^^^^^^^^^^
  File "/lib/python3.12/site-packages/traitlets/traitlets.py", line 716, in __set__
    self.set(obj, value)
  File "/lib/python3.12/site-packages/traitlets/traitlets.py", line 690, in set
    new_value = self._validate(obj, value)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/traitlets/traitlets.py", line 724, in _validate
    value = self._cross_validate(obj, value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/traitlets/traitlets.py", line 730, in _cross_validate
    value = obj._trait_validators[self.name](obj, proposal)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/traitlets/traitlets.py", line 1241, in __call__
    return self.func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/ipyleaflet/leaflet.py", line 2971, in _validate_layers
    self._layer_ids = [layer.model_id for layer in proposal.value]
                       ^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/ipywidgets/widgets/widget.py", line 552, in model_id
    return self.comm.comm_id
           ^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'comm_id'
/lib/python3.12/site-packages/shiny/reactive/_reactives.py:566: ReactiveWarning: Error in Effect: 'NoneType' object has no attribute 'comm_id'
  await self._run()
Unhandled error: 'NoneType' object has no attribute 'comm_id'
@davidwilby
Copy link

davidwilby commented Jan 17, 2025

I'm also experiencing this and can confirm that things are working in 0.3.4.

For example in the map distance example, as described in: posit-dev/py-shiny-templates#27

@cpsievert
Copy link
Collaborator

cpsievert commented Jan 23, 2025

Thanks for the report. #179 fixes the 'NoneType' object has no attribute 'comm_id' issue, which fully fixes posit-dev/py-shiny-templates#27, but there's another issue that still affects the original reproducible example. I'll need a bit more time to think through what I'd like to do for secondary issue.

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

3 participants