Skip to content

Cannot use arbitrary python objects as view #13

@MarcSkovMadsen

Description

@MarcSkovMadsen

It would be easier if I could use any python objects as a view. Instead I will have to wrap it in pn.panel

import hvplot.pandas  # noqa: F401
import numpy as np
import pandas as pd

from panel_reactflow import ReactFlow

data = pd.DataFrame({"x": range(50), "y": np.random.randn(50).cumsum()})
plot = data.hvplot.line(x="x", y="y", height=300, width=400)


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

ReactFlow(nodes=nodes, edges=[], sizing_mode="stretch_both").servable()
AttributeError: 'Curve' 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 22, 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: 'Curve' object has no attribute '_models'

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