Skip to content

Viewer: AttributeError: 'MyViewer' object has no attribute '_models' #12

@MarcSkovMadsen

Description

@MarcSkovMadsen

I cannot use Viewer components because they raise errors.

Reproduce

import panel as pn

from panel_reactflow import ReactFlow


class MyViewer(pn.viewable.Viewer):
    def __panel__(self):
        return pn.pane.Markdown("Hello React Flow!")


my_viewer = MyViewer()

nodes = [
    {
        "id": "source",
        "type": "panel",
        "label": "Data Source",
        "position": {"x": 0, "y": 0},
        "data": {},
        "view": my_viewer,
    },
]

ReactFlow(nodes=nodes, edges=[], sizing_mode="stretch_both").servable()
AttributeError: 'MyViewer' object has no attribute '_models'

Traceback (most recent call last):
  File "/home/jovyan/repos/private/panel-reactflow/.pixi/envs/default/lib/python3.14/site-packages/panel/io/handlers.py", line 539, in run
    exec(self._code, module.__dict__)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/private/panel-reactflow/script.py", line 24, in <module>
    ReactFlow(nodes=nodes, edges=[], sizing_mode="stretch_both").servable()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/jovyan/repos/private/panel-reactflow/.pixi/envs/default/lib/python3.14/site-packages/panel/viewable.py", line 417, in servable
    self.server_doc(doc, title=title, location=location) # type: ignore
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/private/panel-reactflow/.pixi/envs/default/lib/python3.14/site-packages/panel/viewable.py", line 1044, in server_doc
    model = self.get_root(doc)
  File "/home/jovyan/repos/private/panel-reactflow/.pixi/envs/default/lib/python3.14/site-packages/panel/viewable.py", line 706, in get_root
    root = self._get_model(doc, comm=comm)
  File "/home/jovyan/repos/private/panel-reactflow/.pixi/envs/default/lib/python3.14/site-packages/panel/custom.py", line 567, in _get_model
    children, _ = self._get_children(model.data, doc, root, model, comm)
                  ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/private/panel-reactflow/src/panel_reactflow/base.py", line 642, in _get_children
    views, view_models = self._get_child_model(views, doc, root, parent, comm)
                         ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/private/panel-reactflow/.pixi/envs/default/lib/python3.14/site-packages/panel/custom.py", line 525, in _get_child_model
    if ref in sv._models:
              ^^^^^^^^^^
AttributeError: 'MyViewer' object has no attribute '_models'

Metadata

Metadata

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