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

Lonboard (anywidget) map not rendering layers #3909

Open
fabito opened this issue Feb 25, 2025 · 6 comments
Open

Lonboard (anywidget) map not rendering layers #3909

fabito opened this issue Feb 25, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@fabito
Copy link

fabito commented Feb 25, 2025

Describe the bug

Lonboard map visualization not working as expected.
Layers aren't rendered.

Environment

{
  "marimo": "0.11.9",
  "OS": "Darwin",
  "OS Version": "22.6.0",
  "Processor": "arm",
  "Python Version": "3.11.7",
  "Binaries": {
    "Browser": "133.0.6943.127",
    "Node": "v20.17.0"
  },
  "Dependencies": {
    "click": "8.1.8",
    "docutils": "0.21.2",
    "itsdangerous": "2.2.0",
    "jedi": "0.19.2",
    "markdown": "3.7",
    "narwhals": "1.28.0",
    "packaging": "24.2",
    "psutil": "7.0.0",
    "pygments": "2.19.1",
    "pymdown-extensions": "10.14.3",
    "pyyaml": "6.0.2",
    "ruff": "0.9.7",
    "starlette": "0.46.0",
    "tomlkit": "0.13.2",
    "typing-extensions": "4.12.2",
    "uvicorn": "0.34.0",
    "websockets": "15.0"
  },
  "Optional Dependencies": {
    "anywidget": "0.9.14",
    "duckdb": "1.2.0",
    "pandas": "2.1.4",
    "polars": "1.23.0",
    "pyarrow": "19.0.1"
  },
  "Experimental Flags": {
    "chat_sidebar": true,
    "multi_column": true
  }
}

Code to reproduce

More details in #3908

The expected map should look like:

Image

But I am getting:

Image

@fabito fabito added the bug Something isn't working label Feb 25, 2025
@mscolnick
Copy link
Contributor

I did a bit of digging.

This field is returning undefined when it expects a list of ids https://github.com/developmentseed/lonboard/blob/510af74c550eced13a79d80f16cee38b98df69b7/src/index.tsx#L137

But this is the initial state that marimo passes to the widget.

{
    "_height": null,
    "basemap_style": "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",
    "custom_attribution": "",
    "parameters": null,
    "picking_radius": 5,
    "selected_bounds": null,
    "show_tooltip": true,
    "use_device_pixels": null,
    "view_state": [
        -48.32,
        -25.340000000000003,
        9,
        0,
        0
    ]
}

Still not sure if its a marimo error on lonboard

@mscolnick
Copy link
Contributor

It is this trailet that is not being passed.

https://github.com/developmentseed/lonboard/blob/510af74c550eced13a79d80f16cee38b98df69b7/lonboard/_map.py#L186C14-L189

Likely because we don't support custom traitlet serialization, but there might be another reason.

@mscolnick
Copy link
Contributor

mscolnick commented Feb 26, 2025

Got further in #3921, with the serialization, but marimo doesn't support the widget_manager (at least yet), and lonboard does make use of this, so still will be an error

cc @manzt, do you know what it would take to support widget_manager in marimo?

@manzt
Copy link
Contributor

manzt commented Feb 26, 2025

The main thing necessary to support he widget_manger is the ability for other widgets to access instances of Model by some id. I think some Map<modelId, Model> would allow for implementing such a thing:

  widget_manger: {
    get_model(model_id: string): Model {
      return MODELS.get(model_id)
    }
  }

I'd be happy to help land this as I know a few more sophisticated anywidgets use this feature. Every ipywidget.Widget has a model_id. When created, it emits a a "open_open" event to the front end with the initial state. This creates an evented Model object, regardless of whether there is a corresponding view for that model. The widget_manager lets other views access (and subscribe to methods on other other models that are in the front end).

conceptually, for marimo I think this would entail creating a "global" registry of Model instances. Any time a Widget is instantiated on the Python side, it should create an instance on the front end keyed in the registry by it's corresponding ID.

mscolnick added a commit that referenced this issue Feb 26, 2025
Part of #3909. It ublocks part of the error, but then hits
`widget_manager not supported in marimo`.

I'm not sure what itll take to support `widget_manager`, but i think
this is a relic of anywidget tightly integrated with jupyter
@mscolnick
Copy link
Contributor

@manzt, would love your help on this in any capacity

@manzt
Copy link
Contributor

manzt commented Feb 26, 2025

Sure, i could find time next week to pair

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants