-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Description
I should not have to use .to_dict() on edges defined from EdgeSpec. This should happen automatically.
"""Example 1: Text Processing Pipeline — three nodes, no special dependencies."""
import panel as pn
import param
from panel.viewable import Viewer
from panel_reactflow import EdgeSpec, NodeSpec, NodeType, ReactFlow
pn.extension("jsoneditor")
class TransformNode(Viewer):
text = param.String("Hello World")
mode = param.Selector(default="upper", objects=["upper", "lower", "title", "swapcase"])
@param.output(param.String)
@param.depends("text", "mode")
def result(self):
if not self.text:
return ""
return getattr(self.text, self.mode)()
def __panel__(self):
return pn.pane.Markdown(self.result)
transform = TransformNode(name="Text Transform")
def create_pipeline(nodes, graph=None) -> ReactFlow:
input_widgets = pn.Param(nodes[0], show_name=False)
output_view = pn.panel(nodes[0])
node_types = {"input": NodeType(type="input", label="Input", schema=type(nodes[0]))}
flow = ReactFlow(
nodes=[
NodeSpec(id="input", position={"x": 0, "y": 100}, label=f"{input_widgets.name} Input").to_dict() | {"view": input_widgets},
NodeSpec(id="transform", position={"x": 450, "y": 50}, label=f"{input_widgets.name}").to_dict() | {"view": output_view},
],
edges=[
EdgeSpec(
id="e1",
source="input",
target="transform",
), # .to_dict()
],
node_types=node_types,
sizing_mode="stretch_both",
min_height=500,
)
return flow
create_pipeline(
nodes=[transform],
).servable() File "/home/jovyan/repos/private/panel-reactflow/src/panel_reactflow/base.py", line 586, in _update_edge_editors
edge_ids = [edge["id"] for edge in self.edges]
~~~~^^^^^^
TypeError: 'EdgeSpec' object is not subscriptableReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels