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

Map distance app error when switching maps #27

Closed
davidwilby opened this issue Jan 10, 2025 · 2 comments
Closed

Map distance app error when switching maps #27

davidwilby opened this issue Jan 10, 2025 · 2 comments

Comments

@davidwilby
Copy link

Thanks for the awesome templates!

I'm finding that the map-distance app is erroring when switching maps on a local deployment (the gallery app is fine)

Python version 3.12 and 3.11 tried.

Environment tested python 3.11.11 ❯ pip freeze anyio==4.8.0 appdirs==1.4.4 asgiref==3.8.1 asttokens==3.0.0 branca==0.8.1 certifi==2024.12.14 charset-normalizer==3.4.1 click==8.1.8 comm==0.2.2 decorator==5.1.1 executing==2.1.0 faicons==0.2.2 geographiclib==2.0 geopy==2.4.1 h11==0.14.0 htmltools==0.6.0 idna==3.10 ipyleaflet==0.19.2 ipython==8.31.0 ipywidgets==8.1.5 jedi==0.19.2 Jinja2==3.1.5 jupyter-leaflet==0.19.2 jupyter_core==5.7.2 jupyterlab_widgets==3.0.13 linkify-it-py==2.0.3 markdown-it-py==3.0.0 MarkupSafe==3.0.2 matplotlib-inline==0.1.7 mdit-py-plugins==0.4.2 mdurl==0.1.2 narwhals==1.21.1 orjson==3.10.14 packaging==24.2 parso==0.8.4 pexpect==4.9.0 platformdirs==4.3.6 prompt_toolkit==3.0.48 ptyprocess==0.7.0 pure_eval==0.2.3 Pygments==2.19.1 python-dateutil==2.9.0.post0 python-multipart==0.0.20 questionary==2.1.0 requests==2.32.3 shiny==1.2.1 shinywidgets==0.4.2 six==1.17.0 sniffio==1.3.1 stack-data==0.6.3 starlette==0.45.2 traitlets==5.14.3 traittypes==0.2.1 typing_extensions==4.12.2 uc-micro-py==1.0.3 urllib3==2.3.0 uvicorn==0.34.0 watchfiles==1.0.3 wcwidth==0.2.13 websockets==14.1 widgetsnbextension==4.0.13 xyzservices==2024.9.0

The following error is raised when choosing a different map from the dropdown, e.g. starting with WorldImagery and selecting Mapnik:

Traceback (most recent call last):
  File ".../lib/python3.11/site-packages/shiny/reactive/_reactives.py", line 584, in _run
    await self._fn()
  File ".../lib/python3.11/site-packages/shiny/_utils.py", line 279, in fn_async
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "./map-distance/app.py", line 165, in _
    update_basemap(map.widget, input.basemap())
  File "./map-distance/app.py", line 185, in update_basemap
    map.remove(layer)
  File ".../lib/python3.11/site-packages/ipyleaflet/leaflet.py", line 3168, in remove
    if item.model_id not in self._layer_ids:
       ^^^^^^^^^^^^^
  File ".../lib/python3.11/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.11/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'

The app then freezes:

Image

Also note that when a different map is selected and the page is refreshed, the new map loads correctly, e.g. Mapnik in this example:

Image

@davidwilby
Copy link
Author

This issue is caused in shinywidgets >0.4.0 but everything still works in 0.3.4. posit-dev/py-shinywidgets#174

@cpsievert
Copy link
Contributor

Fixed by posit-dev/py-shinywidgets#179

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