Groups¶
panel_flowdash.groups
¶
Groups: nodes framed together on the canvas, which can be collapsed into one node.
A group is a label and a set of nodes. It changes nothing about the dataflow: the nodes stay ordinary nodes, with their own config, connections and tiles, and collapsing a group only changes how the canvas draws them. A collapsed group shows the ports its nodes are connected through, the ones of the connections that cross its border, so the dataflow stays readable.
In the dashboard YAML groups are a top-level mapping by name, and each node names its group::
groups:
revenue: {label: Paid revenue by region, collapsed: true}
nodes:
revenue_sql: {component: Lumen/sql, group: revenue, config: {...}}
A node belongs to at most one group, and groups do not nest.
GROUP_HEADER_HEIGHT = 32
module-attribute
¶
GROUP_ID_PATTERN = re.compile('^[A-Za-z_][A-Za-z0-9_-]{0,63}$')
module-attribute
¶
GROUP_NODE_PREFIX = 'group:'
module-attribute
¶
GROUP_NODE_TYPE = 'group'
module-attribute
¶
GROUP_PORT_ROW_HEIGHT = 22
module-attribute
¶
INPUT_HANDLE_PREFIX = 'in:'
module-attribute
¶
MAX_GROUP_PORT_ROWS = 12
module-attribute
¶
MAX_LABEL_LENGTH = 200
module-attribute
¶
OUTPUT_HANDLE_PREFIX = 'out:'
module-attribute
¶
PortInfo = Callable[[str, str, str], tuple[str, str | None]]
module-attribute
¶
DashboardGroup
dataclass
¶
Nodes framed together on the canvas.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Unique within the dashboard, a name like the dashboard YAML's node names. |
label |
str | None
|
Shown in the group's header; the id is shown when it is None. |
nodes |
list[str]
|
Instance ids of the nodes in the group, in the order they were grouped. |
collapsed |
bool
|
Whether the canvas draws the group as one node. |
GroupError
¶
GroupPort
dataclass
¶
A port of a group: the inner ports one connection across its border reaches.
An input is named after the inner port it feeds and reaches every inner port fed by the same outside output; an output is one inner output read from outside the group.
check_group_id(group_id)
¶
Raise :class:GroupError unless group_id can name a group.
component_nodes(nodes)
¶
Return the canvas nodes that are components, leaving out group frames.
copy_groups(groups)
¶
Return groups as copies, so changing them changes no group of an editor.
decode_groups(value)
¶
Return the groups a stored dashboard holds, raising ValueError when malformed.
A node in more than one group stays in the first, and groups left with no node are dropped.
group_class(inputs, outputs)
¶
Return the CSS class that sizes a collapsed group's frame for its port rows.
group_id_of(node_id)
¶
Return the group a canvas node id draws, or None for a component's node.
group_node_data(group, inputs, outputs)
¶
Return the canvas node data that draws group with its ports.
handle_map ties each inner port to the group handle that stands in for
it while the group is collapsed, so connections are drawn to it and a
connection made to it reaches every inner port it maps.
group_node_id(group_id)
¶
Return the id of the canvas node that draws group group_id.
group_ports(members, edges, port_info=None)
¶
Return the inputs and outputs of a group from the connections crossing its border.
edges are (source, source_port, target, target_port) tuples by
instance id. port_info(instance_id, port, direction) returns the label
and type of an inner port, which the group's port takes over.
is_group_node(node)
¶
Whether a canvas node draws a group rather than a component.
unique_group_id(base, taken)
¶
Return a group id made from base that is not in taken.