Quickstart¶
Get a FlowDash project running with two wired components and a CLI-served dashboard. By the end of this page you will have a working dataflow app.
Install¶
panel-flowdash needs Python 3.12 or newer and Panel 1.11 or newer.
Create a project¶
FlowDash expects a directory with section folders containing Python modules.
Each module exports an app object decorated with @register:
Define components¶
from panel_flowdash import register
@register(
page=False,
component=True,
provides=[{"key": "company", "type": "str"}],
title="Company Selector",
)
def app(config):
import panel_material_ui as pmui
select = pmui.Select(label="Company", options=["ACME", "Globex", "Initech"])
config.company = select.param.value
return select
from panel_flowdash import register
@register(
page=False,
component=True,
requires=[{"key": "company", "type": "str"}],
title="Company Chart",
)
def app(config):
import panel as pn
def title(company):
return f"## Revenue chart for {company}"
return pn.pane.Markdown(pn.bind(title, config.param.company))
The provides list declares output ports and requires declares input ports.
Each placed component gets its own config object, a param.Parameterized
with one parameter per port. A component publishes an output by assigning to
it: assigning the widget's value parameter, rather than its current value,
keeps the output following the selection. An input is read the same way, here
through config.param.company so the Markdown updates whenever a new value
arrives. When the two are wired together, picking a company in the selector
updates the chart.
Until the chart's company input receives a value its tile shows a "This tile
needs company" placeholder, because inputs are required by default. See
Define Ports for optional inputs and fallbacks.
Serve¶
This scans my_project/, discovers the two components, builds the application,
and serves it on port 5006. Open http://localhost:5006 in your browser,
create a dashboard, drop both components onto the wiring canvas and drag from
the selector's company output to the chart's company input.
Wire it in Python¶
The same dashboard can be built without the browser, which is also how you
would test it. FlowDash scans the project the way flowdash serve does:
from panel_flowdash import FlowDash, MemoryAssetStore
editor = FlowDash("my_project", store=MemoryAssetStore())
selector = editor.add_component("Analytics/selector")
chart = editor.add_component("Analytics/chart")
assert editor.connect(selector, "company", chart, "company") is True
assert editor.graph.get_state(chart).company == "ACME"
See Embed the Editor for everything the editor can do from code.
What happens under the hood¶
build_registry()imports each module and extracts@registermetadata.build_component_specs()creates typed port definitions for each component.DataflowGraphmanages wiring between component node states.AssetStorepersists the layout tomy_project/assets.db.
Next steps¶
- Register Components for the full decorator API
- Define Ports for typed ports and Viewer introspection
- Wire the Dataflow for validation rules and runtime error handling