Skip to content

node_actions

panel_flowdash.node_actions

Actions a component library adds to the menus of a node, and the provenance a node reports.

A library registers a :class:NodeAction with :func:register_node_action; the editor offers it in the â‹® menu of the sidecar's header and of the node's tile, for each node it applies to, in the modes it declares (edit mode only by default), and calls run with a :class:NodeActionContext when it is picked. An action marked admin_only is only offered to, and only runs for, a person the editor's authorize_admin says administers the project; it is asked again, with the project file read afresh, before the action runs.

A component reports where its numbers come from by defining __flowdash_provenance__(self, via=()), returning a :class:Provenance (or a dict of its fields) or None. A view that reads such a node, directly or through others, shows the nearest one's label: a chip on its tile while the dashboard is edited (and in view mode when the editor's provenance_labels is on), under the sidecar's header and first in "How was this made?". A provenance whose level is "warning", e.g. one saying a row limit cut the numbers, is a warning: every view downstream of it shows it, past nearer labels, in view mode too whatever provenance_labels says, and reports and their exports add it to the node's caption.

via holds the edges the numbers travel along from the reporting node to the view asking, nearest the reporting node first, each {"from", "to", "transform"} as :meth:NodeActionContext.inputs gives them; it is empty when a node reports on itself. A hook reads it to tell what the view shows from what the node holds, e.g. a named metric's rows from their average taken by an edge's aggregate step, and returns a label for the derived number, or None to pass the question further up. The via argument is optional: a hook that does not take it is called without it.

See the how-to guide "Node Actions and Provenance".

LEVELS = ('info', 'warning') module-attribute

MODES = ('edit', 'view') module-attribute

PROVENANCE_HOOK = '__flowdash_provenance__' module-attribute

_ACTIONS = {} module-attribute

__all__ = ['LEVELS', 'MODES', 'PROVENANCE_HOOK', 'NodeAction', 'NodeActionContext', 'NodeActionOps', 'Provenance', 'call_provenance_hook', 'node_actions', 'register_node_action', 'unregister_node_action'] module-attribute

logger = logging.getLogger(__name__) module-attribute

DashboardOps

Read and edit dashboards through an editor, with its user's rights.

Nodes and ports are named as in the dashboard YAML (see :func:~panel_flowdash.agent.dashboard_to_yaml): a node by its name, a port as "<node>.<port>". Every change applies to the editor's canvas and marks it dirty; nothing is stored until :meth:save.

Rights follow the editor: components its authorize_component refuses can neither be listed nor placed, nodes of such components cannot be changed, dashboards its authorize_dashboard does not let the user view are reported as missing, and while it is read_only (the user may not edit the dashboard) every change is refused.

Parameters:

Name Type Description Default
editor FlowDash

The editor to work through: the one on screen, or one without a page built for the purpose, e.g. FlowDash(components, store=store, authorize_component=..., authorize_dashboard=...).

required

check_timeout = CHECK_TIMEOUT class-attribute instance-attribute

editor = editor instance-attribute

last_check = CheckResult() instance-attribute

layout_notes = [] instance-attribute

placeholder_hint = None class-attribute instance-attribute

report_context = None class-attribute instance-attribute

settle_timeout = CHECK_TIMEOUT class-attribute instance-attribute

sized_tiles = {} instance-attribute

versioned = True class-attribute instance-attribute

add_filter(column, label=None, widget=None, value=None)

Add a global filter on column to the dashboard's filter bar, or change the one it has.

Returns the filter, whether it is new, which views it filters and why the others with data do not (see :meth:filter_reach), and the views it filters that a Filter node upstream already filters on the column (see :meth:filtered_locally), which then keep only the rows both keep.

Raises:

Type Description
OperationError

If no view on the dashboard has the column, or the filter is malformed.

add_node(component, config=None, position=None, name=None)

Place a component and return the name of its node.

Parameters:

Name Type Description Default
component str

A component id, e.g. "Views/kpi".

required
config dict[str, Any] | None

Values for some of its config fields.

None
position tuple[float, float] | None

Canvas position (x, y). Leave it out: the editor places the node by its dataflow and keeps it in place as it is connected.

None
name str | None

The node's name, e.g. "paid_by_region". It becomes the node's instance id, as for a node a YAML file names, so the YAML, the export and the store keep it. It starts with a letter or underscore, holds only letters, digits, _ and - but no __, is at most 64 characters long, and no node on the dashboard may have it. Defaults to a generated name like kpi_3fa2c1.

None

Raises:

Type Description
OperationError

If the component is unknown, placed once already when it can only be placed once, config is invalid or refused by the component's config check, or name is invalid or taken; for a taken name the message suggests a free one. Warnings of the config check do not refuse it; they are left in :attr:last_check.

PermissionError

If the user may not use the component, or edit the dashboard.

add_node_async(component, config=None, position=None, name=None) async

Like :meth:add_node, running the component's config check off the event loop.

arrange_canvas()

Lay out every node on the canvas by its dataflow, sources left and views right.

Nodes added without a position are placed this way already; this also moves the nodes people placed, so call it only when asked to tidy the canvas.

arrange_layout()

Lay out every visible tile by kind for each screen size, see :meth:arrange_tiles.

arrange_tiles(order=None, style='grid', keep_sizes=True)

Lay out every visible tile again in one edit, for each screen size.

With the "grid" style controls go first, then KPIs in a row, charts two to a row and tables at full width, with headings kept in front of the tile they title; "stack" puts the tiles one to a row at full width. order names nodes whose tiles go first, in that order within their kind; the others follow in their current order. This also rearranges the tiles people laid out. The tiles sized with :meth:place_tile in this request keep their size, with their rows rebalanced around them, unless keep_sizes is False.

ask_in_report(question, after=None)

Add a question to the report, not run yet, and return its turn id.

Its block goes after the block at index after, or last without it. Running it (:meth:run_pending, or the Run button in the app) asks the agent, whose answer then fills the block.

bind_parameters(values)

Write values into their parameters' fields as one edit, and return the warnings.

Values given as text are read as their parameter's type. The contract of each parameter checks its value first, then each changed node's config check runs; nothing changes unless all pass. Parameters on nodes the user may not use are not found.

Raises:

Type Description
OperationError

If a name is not a parameter, a value is not of its type, a contract refuses a value (naming the nodes that would fail) or a config check refuses the result.

connect(source, target, transform=None)

Connect the output source to the input target, both "<node>.<port>".

Returns:

Type Description
CheckResult

What the config check of the target node's component found once the node has its new input, see register(check_config=); empty without a check. Problems do not undo the connection: the node is reported invalid by :meth:preview and :meth:validate until its config is fixed. It is left in :attr:last_check too.

Raises:

Type Description
OperationError

If a port does not exist, the types do not match, the input is taken, the edge would close a cycle or the transform is invalid.

connect_async(source, target, transform=None) async

Like :meth:connect, checking the target node off the event loop.

Checks of one node that follow each other quickly, e.g. on several connections into it, are coalesced: at most one runs while another waits, and the latest state wins.

declare_parameter(name, node, field, *, type='value', description=None)

Declare a parameter on a node's config field, or redeclare one, and return it.

What its contract expects is computed by the node's component, see :meth:~panel_flowdash.editor.FlowDash.declare_parameter.

Raises:

Type Description
OperationError

If the node does not exist or the name, field or type is malformed.

describe_layout()

Describe the layout as it is now: the top bar, the sidebar and the grid's rows.

Each tile is named with its width in percent of the row and its height in pixels, or auto with the height the dashboard gives it when it has none of its own; hidden tiles are listed last.

disconnect(source, target)

Remove the edge from the output source to the input target.

Returns what the config check of the target node found without the input, like :meth:connect.

disconnect_async(source, target) async

Like :meth:disconnect, checking the target node off the event loop.

edit_report(operations, revision=None)

Change the report's blocks by index, in one edit, and return warnings about the result.

Each operation is a mapping with an op:

  • {"op": "insert", "block": {...}, "index": 2} inserts a block before the block at index, or last without it; "before": "<node>" or "after": "<node>" in place of index puts it next to the block showing that node, or its group;
  • {"op": "update", "index": 2, "block": {...}} changes keys of a block, a null value removing the key;
  • {"op": "move", "index": 2, "to": 0} moves a block to to;
  • {"op": "remove", "index": 2} removes a block;
  • {"op": "title", "title": "..."} renames the report, an empty title giving it the dashboard's.

Operations apply in order, each to the blocks the earlier ones left. A dashboard without a report of its own starts from the derived one. Nothing changes unless every operation applies, the result names only nodes, groups and turns the dashboard has and the placeholders of new or changed text can show a value. With revision, the token :meth:get_report gave, nothing changes either if the report changed since, as its indices may have moved.

Raises:

Type Description
OperationError

If an operation is malformed, the result is invalid or the report changed since revision.

export_report(format='html', *, include_pending=False) async

Export the report as a file, as the Report view's Export does, and return the file.

Pending questions are never run; with include_pending they are written as not answered yet. Raises :class:~panel_flowdash.export.ExportUnavailable when the format needs a package that is not installed.

filter_reach(column)

Return the views a global filter on column filters, and why each other view with data does not.

Views are named as in the YAML. Views that take no data, e.g. text, are left out.

filtered_locally(column, views)

Return the views a Filter node upstream already filters on column, by view name.

A Filter node is a transform tagged filter whose field or column config names the column; it is named as in the YAML.

filters()

Return the dashboard's global filters, the views they exclude by node name.

get_dashboard(dashboard_id=None)

Return a dashboard as YAML.

The YAML of the editor's dashboard starts with a # revision: <token> comment identifying the canvas it was read from; :meth:replace_yaml refuses text read from a canvas that has changed since.

Parameters:

Name Type Description Default
dashboard_id str | None

A stored dashboard. Defaults to the dashboard in the editor, with its unsaved changes.

None

Raises:

Type Description
NotFound

If there is no such dashboard or the user may not open it.

PermissionError

If the user may view it but it hides its components from viewers, as Download does.

get_report()

Return the report as YAML, each block preceded by a # <index> comment.

The first line is a # revision: <token> comment, which :meth:edit_report and :meth:set_report check. The indices are those :meth:edit_report takes. A question not run yet, or one answered, has its question in the comment.

group(name)

Return a group's label, nodes, whether it is collapsed, and its ports.

group_nodes(nodes, label=None, name=None)

Frame nodes together on the canvas as one group, which can be collapsed into one node.

Returns the group's name and its ports: one input per outside output feeding the group, with the inner ports it connects to, and one output per inner output read from outside.

hidden_tiles()

Return the names of the nodes whose tiles are hidden, e.g. data sources and transforms.

instance_id(name)

Return the instance id of the node called name, raising OperationError if there is none.

The error suggests the nearest node name, as the tools' errors do.

list_components(query='')

List the components the user may place, with their ports and config fields.

Parameters:

Name Type Description Default
query str

Only list components whose id, title, description or tags contain each of its words, ignoring case.

''

Returns:

Type Description
list of dict

One :func:~panel_flowdash.agent.component_schema per component.

list_dashboards()

List the stored dashboards the user may open, most recently changed first.

Returns:

Type Description
list of dict

id, title, description and can_edit of each dashboard.

list_templates_async() async

Describe the templates, with what each data and view slot may be bound to.

new_dashboard_from_template_async(template_id, bindings, title=None) async

Fill a template in and load it into the open canvas, which must be empty.

:class:~panel_flowdash.agent.live.LiveDashboardOps creates a new dashboard instead.

node_config(name)

Return a copy of a node's config.

Raises:

Type Description
OperationError

If there is no such node, or it could not be loaded.

PermissionError

If the dashboard hides its definition from the user, or the node is of a component the user may not use.

node_output(ref, port=None)

Return the current value of an output, as the nodes it feeds receive it.

The value is the live object, not a copy: a DataFrame or another mutable value must not be changed.

Parameters:

Name Type Description Default
ref str

The output as "<node>.<port>", or the node's name with port.

required
port str | None

The output port, when ref is only the node's name.

None

Raises:

Type Description
OutputUnavailable

If the node has no value to give, as :meth:preview reports it: status is "waiting" while a required input is missing, "pending" while its async outputs, or those upstream of it, are computing, so the value would be stale (await :meth:settled first), and "failed" when an input failed upstream or the output itself failed. Retrying the same call does not help until the dashboard changes, so it is not an :class:OperationError.

OperationError

If there is no such node or output, or the node could not be loaded.

PermissionError

If the dashboard hides its definition or its outputs from the user, or the node is of a component the user may not use.

node_placeholder_hint(name)

Return the :class:~panel_flowdash.report.PlaceholderHint of node name, None without one.

The component's own __flowdash_placeholder_hint__ comes first, then :attr:placeholder_hint.

nodes(component=None)

List the nodes of the editor's dashboard in the order they were placed.

Parameters:

Name Type Description Default
component str | None

Only list nodes of this component id, or of a former id of it.

None

Returns:

Type Description
list of dict

name and component of each node. A node of a component the user may not use is listed as flowdash:restricted, as :meth:get_dashboard writes it, and never matches component.

Raises:

Type Description
PermissionError

If the dashboard hides its definition from the user, as Download does.

open_dashboard(dashboard_id, *, discard=False)

Load a stored dashboard into the editor and return it as YAML.

A dashboard the user may only view is opened read-only, and when it hides its definition from viewers (see :meth:get_dashboard) a note saying so is returned instead.

Raises:

Type Description
OperationError

If the editor has unsaved changes and discard is not set.

parameters()

Return the dashboard's parameters by name, as the YAML writes them.

pending(names=None, downstream=False)

Return why each pending node is pending, by name.

A node is pending while its async outputs, or those upstream of it, are computing. names and downstream limit it to those nodes, as in :meth:settled.

pending_question(turn)

Return the question of the pending turn turn, raising OperationError if there is none.

place_tile(name, *, width=None, height=None, visible=None, index=None, frame=None, area=None, before=None, after=None)

Change how a node's tile is laid out and return its layout entry.

A new width or height also resizes the other tiles of the tile's row, as dragging its edge in the Layout tab does: a wider tile takes room from them and a narrower one gives it back, unless the first tile of the next row moves up into it. Tiles sized with this method earlier in the request keep their size, and :meth:arrange_tiles keeps it too. Notes on what was not applied as asked, e.g. a width bounded by the component or a hidden tile, are in :attr:layout_notes.

Parameters:

Name Type Description Default
width float | None

Percent of the row, greater than 0 and at most 100.

None
height float | None

Height in pixels.

None
visible bool | None

False hides the tile; the component keeps running in the dataflow.

None
index int | None

Position among the tiles, 0 for the first, or among the nodes of its area when it is beside the grid.

None
frame Literal['default', 'framed', 'unframed'] | None

"framed" or "unframed" draws the tile as a card in view mode or not; "default" follows the component, then the dashboard's tile_cards setting.

None
area Literal['grid', 'top', 'sidebar'] | None

"grid" shows the node as a tile; "top" in the bar above the grid and "sidebar" in the panel left of it, which only controls, KPIs and text fit.

None
before str | None

The name of a node whose tile this one goes in front of or after, in its area, instead of an index.

None
after str | None

The name of a node whose tile this one goes in front of or after, in its area, instead of an index.

None

Raises:

Type Description
NotApplied

If the node does not fit in area, or is sized while beside the grid. Sizes passed with a move out of the grid are left out and noted in :attr:layout_notes.

preview(text=None, *, rows=5)

Run a dashboard without showing it and report the health of each node.

In a running server use :meth:preview_async.

Parameters:

Name Type Description Default
text str | None

YAML to run in a separate editor, leaving this one untouched. Names map to the nodes of this editor's canvas, as for :meth:replace_yaml; YAML that names none of them is previewed as a new dashboard. Defaults to the editor's dashboard as it is now.

None
rows int

How many rows or items each output sample shows, at most 20.

5

Returns:

Type Description
dict

See :func:~panel_flowdash.agent.preview.preview_editor. Output samples are left out for someone the dashboard hides its outputs from, and only the overall status is given to someone it hides its definition from.

preview_async(text=None, *, rows=5, timeout=DEFAULT_TIMEOUT) async

Like :meth:preview, importing the components' modules off the event loop.

timeout bounds the imports and async component bodies; creating a component synchronously still runs on the event loop. Previewing text also waits for its async outputs to finish, within what is left of timeout.

remove_filter(column)

Remove the global filter on column from the dashboard's filter bar.

Raises:

Type Description
OperationError

If the dashboard has no filter on column.

remove_node(name)

Remove a node, its edges and its tile.

remove_parameter(name)

Remove a parameter; its node keeps the value the field holds.

replace_yaml(text, *, revision=None)

Replace the editor's dashboard with YAML, as importing a dashboard file does.

Node names that are already on the canvas keep their components' identity. The dashboard's turns and the origins of its nodes are kept as the editor recorded them, and those the YAML gives are ignored: nodes already on the canvas keep their origin and new nodes get the turn of whoever replaces the dashboard, the agent or the person. Restricted nodes and their connections must stay as :meth:get_dashboard wrote them; a restricted node can only be taken off with :meth:remove_node. In a running server use :meth:replace_yaml_async.

Parameters:

Name Type Description Default
text str

The whole dashboard in the YAML format.

required
revision str | None

The revision the text is based on. Defaults to the # revision: first line :meth:get_dashboard writes; one of the two is required. Pass revision=ops.revision() to replace the canvas whatever it holds now.

None

Returns:

Type Description
list of Issue

The warnings about the loaded dashboard, e.g. inputs still unconnected or turns the YAML changed to no effect, one for each node that failed once loaded, and as errors the problems the config checks of its components found, see register(check_config=). A node whose check fails is loaded all the same.

Raises:

Type Description
OperationError

If the YAML has errors, has no revision, or the canvas changed since that revision; nothing is changed.

replace_yaml_async(text, *, revision=None, timeout=DEFAULT_TIMEOUT) async

Like :meth:replace_yaml, importing the components' modules off the event loop.

timeout bounds the imports. The revision and the open dashboard are checked again once they are done, so edits made meanwhile are never lost.

report()

Return the open dashboard's report with nodes by name, as the YAML writes it.

A dashboard without a report of its own gives the one derived from its groups and tile layout, with derived set; editing it makes it the dashboard's own.

report_catalogue()

Return what the report's placeholders can read, with :attr:report_context's text after it.

See :func:~panel_flowdash.agent.report_data.report_catalogue. None when there is neither. Refused, like :meth:report_text, to people who may not read the dashboard's definition.

report_context_text()

Return what :attr:report_context adds after the report for the agent, None without it.

report_revision()

Return the token :meth:get_report writes, which :meth:edit_report can check.

report_text()

Return the report as Markdown, as a reader sees it, placeholders filled with current values.

Nodes are named, with their title, rather than rendered; a group lists its shown nodes and an answered question the nodes of its answer.

revision()

Return a token identifying the editor's canvas as it is now.

run_pending(turn, run_id=None)

Answer the pending turn turn with the agent request run_id's next edits; return its question.

Defaults to the panel-agents run the call is made in. The request's edits so far keep their turn; those it makes from now on are the answer, see :meth:FlowDash.answer_pending.

save()

Store the editor's dashboard and return its id.

Raises:

Type Description
PermissionError

If the user may not edit the dashboard.

AssetStoreError

If the store refuses, e.g. because it was saved from another session since it was opened.

send_file(file)

Make the user's browser save an exported file; False when there is no page to send it to.

set_config(name, config, inputs=None)

Change some config fields of a node and return its whole config.

inputs sets literal values of its unconnected inputs in the same edit, as :meth:set_inputs does.

Raises:

Type Description
OperationError

If a field does not exist or takes no such value, or the component's config check refuses the result; nothing is changed. Warnings of the config check do not refuse it; they are left in :attr:last_check.

set_config_async(name, config, inputs=None) async

Like :meth:set_config, running the component's config check off the event loop.

set_inputs(name, inputs)

Set literal values on inputs of a node, used while nothing is connected to them.

A connection always wins over a literal, which applies again once the connection is removed. A value of None removes the input's literal.

Returns:

Type Description
CheckResult

What the config check of the node's component found with the new inputs, like :meth:connect.

Raises:

Type Description
OperationError

If the node has no such input, the input cannot hold a literal, e.g. a DataFrame, or it refuses the value; nothing is changed.

set_inputs_async(name, inputs) async

Like :meth:set_inputs, checking the node off the event loop.

set_report(blocks_yaml)

Replace the report with YAML: a list of blocks, or a mapping with title and blocks.

A list keeps the report's title. Returns warnings about the result. YAML starting with the # revision: line :meth:get_report writes is refused if the report changed since.

Raises:

Type Description
OperationError

If the YAML is malformed, names a node, group or turn the dashboard does not have, or new or changed text has a placeholder that cannot show a value.

set_settings(settings)

Change some dashboard settings and return them all.

set_title(title, description=None)

Rename the open dashboard, and change its description when given; return the title.

Both are unsaved changes like any other edit, stored when the dashboard is saved; only the dashboard's owner or an administrator may rename it.

Raises:

Type Description
OperationError

If no dashboard is open, or the title is empty or too long.

PermissionError

If the user may not rename the dashboard.

set_transform(source, target, transform)

Replace the transform steps of an edge; an empty list removes them.

settled(timeout=None, names=None, downstream=False) async

Wait until no async output of the dashboard is computing.

Call it on the editor's event loop, e.g. from an agent tool or a test, before reading values an edit is still computing.

Parameters:

Name Type Description Default
timeout float | None

Seconds to wait at most, :attr:settle_timeout by default.

None
names Iterable[str] | None

Wait only for these nodes and the nodes upstream of them, rather than the whole dashboard.

None
downstream bool

Wait for the nodes downstream of names too, i.e. for everything an edit of names re-runs.

False

Returns:

Type Description
bool

True once settled, False if timeout passed first; then :meth:pending says which nodes are still computing.

template_document_async(template_id, bindings, *, timeout=DEFAULT_TIMEOUT) async

Return the template and its document filled in with bindings, checked.

Data and view slots are bound by the keys list_templates offers, so only components the user may place; column slots by columns the bound data has, read by running it beside the canvas.

templates()

Return the dashboard templates the user may start from, see :mod:panel_flowdash.templates.

tile_item(instance_id)

Return the editor's tile item of the node instance_id, e.g. for ui.tile_layout.area_of.

ungroup(name)

Remove a group's frame, keeping its nodes; returns their names.

validate(text=None, *, standalone=False, checks=True)

Check YAML against the components the user may place and the canvas it is meant for.

Defaults to the editor's dashboard. The canvas's restricted nodes and their connections must stay as they are, see :func:~panel_flowdash.agent.validate_dashboard, unless standalone is set, for YAML of a new dashboard rather than one for this canvas.

With checks, the config of each node whose component declares a check_config is checked too, against the live inputs of the node of the same name on the canvas, and its problems are errors at nodes.<name>.config.

view_problems_async(doc, names, *, timeout=DEFAULT_TIMEOUT) async

Run the dashboard doc beside this one and say which of the nodes names cannot show their data.

A node fails when drawing it raises, e.g. a view that needs columns its input does not have, or when a table at one of its inputs has no rows. Returns the problem by node name; nothing is shown or saved.

FlowDash

Bases: Viewer

A dataflow wiring canvas and dashboard layout editor over a set of components.

The editor pairs a ReactFlow canvas, where components are placed and their typed ports wired together, with a tile grid that lays the same components out as a dashboard. Everything to do with routing, pages and identity lives in :class:~panel_flowdash.app.FlowDashApp instead, so this can be embedded anywhere.

Parameters:

Name Type Description Default
components

The components to offer. Accepts a decorated function, a Viewer subclass, a mapping of explicit component ids, a project directory to scan, or a list mixing any of those. See :func:~panel_flowdash.component_library.normalize_components.

None
settings_class

A subclass of :class:~panel_flowdash.settings.DashboardSettings adding dashboard-wide parameters of your own, persisted with each dashboard.

required

Examples:

>>> editor = FlowDash(components=[ticker_select, price_chart])
>>> src = editor.add_component("Components/ticker_select")
>>> dst = editor.add_component("Components/price_chart")
>>> editor.connect(src, "ticker", dst, "ticker")
True

agent_state = param.ClassSelector(class_=RunState, default=None, allow_None=True, doc='\n The panel-agents ``RunState`` holding the agent\'s runs, which\n "How was this made?" shows. None uses the edit history\'s, which an\n assistant shares when history is on.') class-attribute instance-attribute

ask = param.Boolean(default=False, doc="\n Whether Ask is open. In view mode it docks the Explore view's feed\n left of the dashboard or the report, resizable by its right edge;\n on a phone, which has no room for it, Ask is the Explore view\n itself. In edit mode it is the host's assistant, see `assistant`.\n Edit mode starts with Ask as view mode left it, and view mode gets\n back the Ask it had as edit mode ends, whatever happened to the\n assistant meanwhile; `set_ask_aside` closes it for something taking\n its place in view mode without changing what view mode gets back.") class-attribute instance-attribute

ask_docked property

Whether Ask is docked left of the dashboard or the report: open, in view mode, on a wide screen.

assistant = param.Boolean(default=False, doc="\n Whether a host docks an assistant beside the editor that Ask opens in\n edit mode, as FlowDashApp does with its agent's drawer. Without one,\n Ask is offered in view mode only.") class-attribute instance-attribute

authorize_admin = param.Callable(default=None, doc='\n Called with a keyword ``fresh`` to decide whether this session\n administers the project. Node actions registered as ``admin_only``\n (see :mod:`panel_flowdash.node_actions`) are offered while it says so\n with ``fresh=False``, which should be cheap as menus ask it on every\n edit, and run only if it says so with ``fresh=True``, which should\n check again, e.g. with the project file read afresh. `FlowDashApp`\n supplies one. None makes no one an admin.') class-attribute instance-attribute

authorize_component = param.Callable(default=None, doc="\n Called with a component's `RegistryEntry` to decide whether this\n session may use it. Components it refuses are left out of the palette\n and `add_component` raises `PermissionError` for them; a loaded\n dashboard shows them as locked placeholders that are never created\n and are saved back unchanged. `FlowDashApp`\n supplies one that evaluates each component's ``allow_*``/``deny_*``\n rules and ``authorize`` callback against the signed-in user. None\n allows every component.") class-attribute instance-attribute

authorize_dashboard = param.Callable(default=None, doc='\n Called with the stored `AssetModel` and the access it needs,\n ``"view"`` or ``"edit"``, to decide whether this session may still\n read or overwrite it. `save` asks for ``"edit"`` against the\n dashboard\'s current sharing rules, so edit rights revoked from another\n session take effect without reloading; reloading and discarding\n changes ask for ``"view"``. `FlowDashApp` supplies one that checks the\n signed-in user. None allows both.') class-attribute instance-attribute

authorize_rename = param.Callable(default=None, doc="\n Called with the stored `AssetModel` to decide whether this session\n may rename it, as an administrator of the dashboard. `set_title` asks\n before renaming and `save` before storing a new title. `FlowDashApp`\n supplies one that checks the signed-in user. None lets only the\n dashboard's owner, the editor's `user`, rename it.") class-attribute instance-attribute

breakpoints = param.List(default=[768, 1200], doc='Responsive breakpoints for the tile grid.') class-attribute instance-attribute

can_redo property

Whether :meth:redo has an undone edit to redo.

can_undo property

Whether :meth:undo has an edit to undo.

code_drafts = param.Boolean(default=False, doc='\n Whether the code panel holds edits that have not been run. Managed by\n the editor; like ``dirty``, watch it to prompt before discarding work.') class-attribute instance-attribute

code_panel property

The :class:~panel_flowdash.ui.code_panel.CodePanel docked under the canvas, made on first use.

code_panel_node = param.String(default=None, allow_None=True, constant=True, doc='The id of the node the code panel under the canvas shows, or None while it is closed.') class-attribute instance-attribute

code_panel_open property

Whether the code panel shows a node, under the canvas or in the sidecar's Spec tab.

component_specs property

Specs for the available components, keyed by component id.

components = param.Parameter(default=None, doc='\n The components to offer in the editor. A decorated function, a Viewer\n subclass, a mapping of explicit component ids, a project directory, or a\n list mixing any of those. Read at construction time.') class-attribute instance-attribute

context = copy_context(self.context) class-attribute instance-attribute

controls_bar = param.Boolean(default=True, doc='\n Whether to show the views of components registered with\n ``sidebar=True`` beside the tiles (see `controls_position`), while\n the dashboard is viewed or laid out. Turn it off to render the\n `sidebar` views in a layout of your own instead. In full screen the\n editor shows them either way, since nothing around it is visible, so\n leave them out of your layout while `fullscreen` is on.') class-attribute instance-attribute

controls_position = param.Selector(default='top', objects=['top', 'left'], doc='\n Default of the ``controls_position`` dashboard setting for dashboards\n that do not store one: where the views of components registered with\n ``sidebar=True`` go. "top" puts them in one slim row above the tiles,\n which suits the few filters most dashboards have; "left" stacks them\n in a collapsible panel left of the tiles, which suits many controls.') class-attribute instance-attribute

dashboard = param.ClassSelector(class_=AssetModel, default=None, doc='\n The dashboard currently loaded. Updated by `load`, `load_model`,\n `new_dashboard` and `save`. May be passed at construction as either a\n AssetModel or, when a store is configured, a dashboard id or title.') class-attribute instance-attribute

dirty = param.Boolean(default=False, doc='\n Whether the canvas has unsaved changes. Managed by the editor; watch it\n to prompt before discarding work.') class-attribute instance-attribute

edit_history property

The versions of the open dashboard, one per edit; see :mod:panel_flowdash.history.

Its state is the panel-agents RunState they are published in, to show them in an ArtifactView or share with an AgentRunner.

editable = param.Boolean(default=True, doc='\n Whether the dashboard can be edited. When False the side panel is hidden\n and the tile grid is shown locked, giving a pure view of the dashboard.') class-attribute instance-attribute

edited = param.Event(doc='Triggered after each edit is recorded in its turn.') class-attribute instance-attribute

explore = param.Boolean(default=False, doc="\n Whether the Explore view is shown in place of the workspace: the same\n as ``surface == 'explore'``. Setting it to False returns to the\n workspace. Ask (`ask`) docks the same feed beside it instead.") class-attribute instance-attribute

explore_feed property

The :class:~panel_flowdash.explore.ExploreFeed the Explore view shows, made on first use.

feed_shown property

Whether the Explore view's feed is on screen, docked in Ask or as the Explore view.

filters property

The dashboard's global filters as a copy, the views they exclude by instance id.

See :mod:panel_flowdash.global_filters.

fullscreen = param.Boolean(default=False, doc="\n Whether the dashboard is presented on its own: the tiles and the\n controls bar fill the screen, without the dashboard bar or the page\n around the editor, and a small overlay shows the title, the health and\n an exit button while the pointer moves. Turning it on from a click\n also puts the editor into the browser's full screen; otherwise, e.g.\n when set at load time, the editor covers the browser window. Leaving\n the browser's full screen turns it off. Only available in view mode:\n switching to edit mode turns it off.") class-attribute instance-attribute

graph property

The live dataflow graph wiring the placed components together.

groups property

The groups on the canvas by id, as copies, nodes by instance id.

See :mod:panel_flowdash.groups.

header_layout = param.Selector(default='compact', objects=['compact', 'full'], doc='\n Default of the ``header_layout`` dashboard setting for dashboards that\n do not store one: how the dashboard bar is laid out. "compact" keeps\n it to one line, which a FlowDashApp with the default navigation folds\n into its top bar; "full" gives it a row of its own with a large title\n over the description, the health chip and when the dashboard was last\n refreshed.') class-attribute instance-attribute

history = param.Boolean(default=True, doc="\n Whether every edit becomes a version of the dashboard's edit history,\n which `undo` and `redo` move through and the store keeps across\n sessions (see `history_limit`). Read at each edit.") class-attribute instance-attribute

history_coalesce = param.Number(default=BURST_SECONDS, bounds=(0, None), doc="\n Seconds without an edit that end a batch of the person's edits in\n the edit history, so a burst of edits, such as a drag, typing into\n a config field or a few quick changes, is one version. An edit of the\n agent, a save, undo and redo end a batch too, and each request to the\n agent is one version. Zero records each of the person's edits on its own.") class-attribute instance-attribute

history_limit = param.Integer(default=500, bounds=(1, None), allow_None=True, doc="\n The most versions a dashboard's stored history keeps; older ones are\n dropped. None keeps them all.") class-attribute instance-attribute

history_max_bytes = param.Integer(default=HISTORY_MAX_BYTES, bounds=(0, None), allow_None=True, doc="\n About how many bytes of dashboard YAML a dashboard's stored history\n keeps; the oldest versions are dropped past it, the latest is always\n kept. None keeps versions however large they are.") class-attribute instance-attribute

history_max_days = param.Number(default=90, bounds=(0, None), allow_None=True, doc="\n How many days the store keeps a version of a dashboard's history.\n None keeps versions however old they are.") class-attribute instance-attribute

import_unknown_components = param.Boolean(default=True, doc='\n Whether importing a file may add or change items whose component this\n editor does not offer. They are imported as they are, shown as\n unavailable and saved back unchanged, so a dashboard keeps them until\n the component is offered again. Set it to False when users are\n restricted by giving each a smaller set of components rather than\n through `authorize_component`: a component one user lacks may be one\n another has, so such an item is then treated like a restricted one,\n keeping its stored config and wiring or being left out of the import.\n `authorize_component` is the better mechanism, since it also shows a\n known but denied component as restricted rather than unavailable.') class-attribute instance-attribute

include_builtin_components = param.Boolean(default=True, doc='Include Select, MultiChoice and Slider in the component palette.') class-attribute instance-attribute

include_page_dialog = param.Boolean(default=True, doc="\n Whether the editor lays out the session's page dialog, the one\n `open_dialog` and `confirm` use. Set it to False when the surrounding\n page already places `page_dialog()` itself, as `FlowDashApp` does; the\n dialog must appear in only one layout. Read when the workspace is built,\n so it needs a served session to take effect.") class-attribute instance-attribute

inspect_outputs = param.Boolean(default=False, doc="\n Whether each tile in the dashboard grid gets an Inspect action that\n opens a side sheet with the current value of every output the\n component publishes. The action is shown in the dashboard view and in\n preview, not while arranging tiles. It reveals outputs the tile itself\n may not display, so while the editor is ``read_only`` (in a\n ``FlowDashApp``, for anyone who may not edit the dashboard) it is only\n shown if the dashboard's ``viewers_can_inspect`` setting allows it. A\n component can add its own explanation per output by defining\n ``__flowdash_inspect__(self, port)``.") class-attribute instance-attribute

is_chat property

Whether the loaded asset is a chat, which shows its own bar in place of the dashboard bar.

is_report property

Whether the loaded asset is a standalone report, which has no tile grid.

layout property

The current tile layout, whether or not the grid is on screen.

One entry per tile, keyed by the tile's instance_id.

mode = param.Selector(default='wiring', objects=['wiring', 'dashboard', 'split'], doc="\n Which workspace is shown: 'wiring' for the ReactFlow canvas, 'dashboard'\n for the tile grid and 'split' for both side by side, with the canvas\n on the left. Only meaningful while `editable`.") class-attribute instance-attribute

node_previews = param.Boolean(default=False, doc='\n Default of the ``node_previews`` dashboard setting for dashboards that\n do not store one: whether each card on the wiring canvas previews its\n current value below its ports, e.g. the first rows of a table or a\n sparkline of a series, rather than summarizing it in one line.') class-attribute instance-attribute

notifications = param.Boolean(default=True, doc='\n Whether to surface user-facing messages as Panel notifications. When\n disabled (or when no notification area exists) messages are logged.') class-attribute instance-attribute

parameters property

The parameters of the open dashboard by name, as copies, nodes by instance id.

Parameters on nodes the user may not use are left out. See :mod:panel_flowdash.parameters.

popup_hover_delay = param.Integer(default=500, bounds=(0, None), doc='Delay in milliseconds before a hover value preview opens.') class-attribute instance-attribute

popup_trigger = param.ObjectSelector(default='click', objects=['click', 'hover', 'none'], doc='\n Whether live port values open on click, hover, or not automatically.\n On hover the popups cover the nodes the pointer passes over, so they\n open on click by default.') class-attribute instance-attribute

preview = param.Boolean(default=False, doc="\n Lock the tile grid as an end user sees it without leaving edit mode.\n Only meaningful while `editable` and in 'dashboard' mode. The\n dashboard bar offers no control for it, since view mode is the preview.") class-attribute instance-attribute

project = param.ClassSelector(class_=Project, default=None, allow_None=True, doc='\n The project file the app reads, which node actions get to save a\n section of it with ``Project.set``. `FlowDashApp` supplies its own.') class-attribute instance-attribute

propagate_failures = param.Boolean(default=False, doc='\n Carry a failing output or edge transform downstream instead of leaving\n the connected inputs on their last value. An input declared in\n `handles_failures` receives the failure as a `param.ReactiveError`; the\n tile of a component with any other failed input is covered by a message\n naming the failure, and its outputs pass the failure on. Read at\n construction time.') class-attribute instance-attribute

provenance = param.Boolean(default=True, doc='\n Whether a node an agent\'s request created offers "How was this\n made?", in its tile\'s More menu and in the inspector, opening a side\n sheet with that request: its question, model calls, tool calls and\n the versions it published, from the run the node\'s origin turn\n names. People who may not edit the dashboard see the request\'s\n shape without its content.') class-attribute instance-attribute

provenance_labels = param.Boolean(default=False, doc='\n Whether the views of nodes that report their provenance (see\n :mod:`panel_flowdash.node_actions`), e.g. "Metric: capacity" or "Ad\n hoc", show it as a chip in view mode too. While the dashboard is\n edited the chip is always shown, and so is a warning (a provenance\n whose level is "warning", e.g. that a row limit cut the numbers).') class-attribute instance-attribute

read_only = param.Boolean(default=False, doc='\n Whether saving is forbidden. The canvas can still be rearranged but\n `save` refuses. Set this from your own authorization logic.') class-attribute instance-attribute

refresh = param.Event(doc='\n Triggered every ``settings.refresh_period`` seconds while a dashboard is\n shown, and whenever the user clicks the refresh button. Components that\n show live data subscribe to it, see `current_dashboard`.') class-attribute instance-attribute

refuse_placement = param.Callable(default=None, doc='\n Called with a component id to ask whether this session may add new\n instances of it: None if it may, else why not, e.g. ``"turned off by\n an admin"``. A refused component is left out of the palette, the\n command palette and the agent\'s components, and `add_component`\n raises `PermissionError` for it. Unlike `authorize_component`, it\n leaves the instances a dashboard already places alone, and they keep\n working; editors are told once when a dashboard they edit has some.\n `FlowDashApp` supplies one from the project file\'s ``components``\n section.') class-attribute instance-attribute

report property

The dashboard's report as a copy, nodes by instance id, or None if it has none.

Blocks referring to nodes, groups or turns the dashboard no longer has are left out. A dashboard without a report reads as the one :func:~panel_flowdash.report.report_blocks derives from its layout. See :mod:panel_flowdash.report.

report_view property

The :class:~panel_flowdash.ui.report_view.ReportView the Report view shows, made on first use.

retitled = param.Event(doc="Triggered when the open dashboard's title changes in the editor, e.g. by set_title or undo.") class-attribute instance-attribute

run_pending = param.Callable(default=None, allow_None=True, doc="\n Called with the id of a pending turn when an editor runs its question\n from the report, e.g. to ask the assistant, which then answers it\n through :meth:`answer_pending`. None, the default without an agent,\n leaves the report's Run buttons disabled.") class-attribute instance-attribute

running_pending = param.List(default=[], item_type=str, doc='\n The ids of the pending turns whose question is being run, from the\n click on Run until the request answering it ends. Their Run buttons\n show that they are running and cannot be pressed again.') class-attribute instance-attribute

saved = param.Event(doc='Triggered after a dashboard is successfully saved.') class-attribute instance-attribute

settings = param.ClassSelector(class_=DashboardSettings, constant=True, doc="\n The dashboard-wide settings, an instance of `settings_class`. Filled\n from the loaded dashboard and written back on save. Edited in edit mode\n through the dashboard bar's Settings form.") class-attribute instance-attribute

settings_class = param.ClassSelector(class_=DashboardSettings, default=DashboardSettings, is_instance=False, doc='\n The class of `settings`. Subclass `DashboardSettings` to add your own\n dashboard-wide parameters. Read at construction time.') class-attribute instance-attribute

show_in_editor = param.Callable(default=None, allow_None=True, doc="\n Called with a tile's instance id when someone viewing the dashboard\n asks to see that component in the editor, from the tile's More menu or\n its failure message. The action is offered in view mode while this is\n set and `read_only` is False; the caller decides what showing a\n component in the editor means, e.g. switching to edit mode.") class-attribute instance-attribute

sidebar = Children(default=[], doc='\n Views of placed components that declare `sidebar=True`, which are kept\n out of the tile grid. Managed by the editor; render these wherever your\n layout wants them.') class-attribute instance-attribute

store = param.ClassSelector(class_=BaseAssetStore, default=None, doc='\n Dashboard persistence backend. Accepts a store instance or a path to a\n SQLite file. When None the editor is ephemeral and `save` merely returns\n the model for the caller to persist.') class-attribute instance-attribute

surface = param.Selector(default='workspace', objects=list(SURFACES), doc="\n What the editor shows, in view and in edit mode: 'workspace' for the\n canvas or the tile grid (as `mode` and `editable` say), 'explore' for\n the Explore view, the dashboard's turns as a feed with the outputs\n each made (see :mod:`panel_flowdash.explore`), or 'report' for the\n Report view, the dashboard read as a document (see\n :mod:`panel_flowdash.report`). The views of the tiles move between\n them, so only one is ever on screen.") class-attribute instance-attribute

tile_cards = param.Boolean(default=True, doc='\n Default of the ``tile_cards`` dashboard setting for dashboards that do\n not store one: whether tiles are drawn as framed cards. Each dashboard\n can change it in its settings.') class-attribute instance-attribute

tile_titles = param.Boolean(default=False, doc="\n Default of the ``tile_titles`` dashboard setting for dashboards that do\n not store one: whether a tile's card shows its title.") class-attribute instance-attribute

toolbar = param.Boolean(default=True, doc='\n Whether to render the dashboard bar above the workspace. In view mode\n it holds the title, Refresh and the View/Edit control; in edit mode\n the Dataflow/Layout tabs and the Settings, Discard, Save and Done\n actions. The component palette is shown regardless.') class-attribute instance-attribute

toolbar_extra = Children(default=[], doc="\n Additional items placed in the dashboard bar's actions, before the\n View/Edit control in view mode and after Settings in edit mode.") class-attribute instance-attribute

turns property

The turns of the open dashboard, oldest first, as copies.

A turn is one request to the agent, or one batch of the person's edits made between requests; each node records the turn that created it as its origin. The editor opens a turn at the first edit that needs one: an edit made in an agent's tool call joins the turn of that agent run, any other edit the person's open turn. See :mod:panel_flowdash.turns.

user = param.String(default='local', doc='Principal recorded as the owner of dashboards created here.') class-attribute instance-attribute

value_repr = param.Callable(default=None, allow_None=True, doc='Optional callable converting a live port value to a Panel viewable or displayable value.') class-attribute instance-attribute

add_component(component_id, config=None, position=None, instance_id=None, *, arrange=False)

Place a component on the canvas and return its instance id.

Parameters:

Name Type Description Default
component_id str

Id of a registered component.

required
config dict | None

Design-time configuration overrides for this instance.

None
position dict | tuple | None

Canvas position as {"x": ..., "y": ...} or (x, y). Defaults to a free spot near the top-left of the visible canvas.

None
instance_id str | None

Id for the new instance, which is also its node's name in the dashboard YAML, as a node a YAML file names gets it. It must be a valid node name without __, at most MAX_NAME_LENGTH (64) characters, that no node on the canvas has. Defaults to a generated <component>_<6 hex> id.

None
arrange bool

Without a position, place the node by its dataflow, beside the nodes it is connected to, and move it again as it is connected until someone moves it by hand, and lay its tile out with the tiles of its kind (see :mod:panel_flowdash.auto_layout). The agent's add_node does this.

False

Returns:

Type Description
str

The new instance's id, for use with connect and remove_component.

Raises:

Type Description
KeyError

If component_id is not a registered component.

ValueError

If instance_id is not a valid node name or is taken.

PermissionError

If authorize_component or refuse_placement refuses it.

answer_pending(turn_id, run_id=None)

Make the pending turn turn_id the turn of the agent request run_id's next edits.

The request's edits so far stay in its own turn. Its next edit runs the pending turn: the turn records the request, and the nodes the request creates get it as their origin, so the question's block in the report shows them as its answer. Without an edit the turn stays pending. The turn is returned.

Raises:

Type Description
ValueError

If no pending turn has the id turn_id.

arrange_canvas()

Lay out every node on the canvas by its dataflow, as one edit.

Sources go on the left and views on the right, in columns by their depth in the dataflow, ordered to reduce crossing edges. Positions set by hand are replaced too; that is what the request is for.

arrange_layout(order=None, style='grid', sizes=None)

Lay out every visible tile by its kind, as one edit.

Controls go first, then KPIs, both at their default width, charts in two columns, tables at full width and the tiles of data sources and transforms last; text tiles stay in front of the tile they preceded. Hidden tiles stay hidden. Layouts made for narrower breakpoint bands are dropped, so those bands follow the arranged layout again.

Parameters:

Name Type Description Default
order Sequence[str] | None

Instance ids of tiles to put first, in this order within their kind; the other tiles follow in their current order.

None
style str

"grid" lays the tiles out by kind as above, "stack" puts them one to a row at full width in their order.

'grid'
sizes Mapping[str, Mapping[str, float]] | None

The width and height of tiles sized on purpose, by instance id, which they keep; the other tiles of their rows make room for them.

None

ask_in_report(question, index=None)

Add a question to the report, not run yet, before the block at index (last for None).

The question becomes a pending turn and a turn block showing it, in one undoable edit, and its id is returned. A dashboard without a report of its own gets the derived one first.

Raises:

Type Description
ValueError

If question is empty or index is not a place in the report.

bind_parameters(values, *, timeout=None)

Write values into their parameters' fields, as one edit, after checking them.

Each value is read as its parameter's type, so text such as "10" for a number parameter is accepted. Before anything changes, the contract of each parameter's component checks the value against what the parameter recorded, the node's config takes the value, and the component's config check (register(check_config=...)) passes the result. Values that change nothing record no edit. Returns the warnings of the contracts.

Raises:

Type Description
ParameterError

If a name is not a parameter the user can see, a value is not of its type or not one the field takes, or a config check refuses it; nothing is changed.

ContractError

If a contract refuses a value; nothing is changed. Its problems name the nodes that would fail.

check_parameters(values)

Return what the contracts find wrong with binding values, without binding them.

Includes warnings, see :class:~panel_flowdash.parameters.ContractProblem.

Raises:

Type Description
ParameterError

If a name is not a parameter or a value is not of its type.

clear()

Remove every component and edge from the canvas.

close_code_panel()

Close the code panel, holding a draft it shows until the field is opened again.

collapse_group(group_id, collapsed=True)

Draw a group as one node with its ports, or expand it again, as one edit.

Expanding pushes the nodes to its right and below aside by the room the expanded group needs, and collapsing moves back the nodes it pushed that have not been moved since.

connect(source_id, source_port, target_id, target_port, transform=None, *, adjust_target=False)

Wire an output port to an input port.

Parameters:

Name Type Description Default
transform list[dict[str, Any]] | None

Steps applied to the values carried along the edge, see :meth:set_edge_transform.

None
adjust_target bool

Let the target component adjust its config to the new edge through its on_connect method (see :class:~panel_flowdash.Upstream), in the same edit. Off for edges that restore an earlier state, such as a load or an undo.

False

Returns:

Type Description
bool or str

True on success, or a message explaining the rejection (unknown port, type mismatch, cycle, an input that is already connected, or an invalid transform). An input fed by a component this session may not use counts as connected.

customize_report()

Make the report derived from the dashboard its own, to be edited, and return whether it did.

The derived blocks are written into the report as one undoable edit; the title stays the dashboard's until it is changed. A dashboard that already has a report keeps it.

declare_parameter(name, node, field, type='value', description=None)

Declare a parameter on a config field of a node, or redeclare one, and return it.

The parameter's expects is computed by the contract of the node's component, if it has one (register(contract=...)).

Parameters:

Name Type Description Default
name str

The parameter's name.

required
node str

The instance id of the node.

required
field str

The config field, or a dotted path into one, e.g. spec.tables.orders.

required
type str

One of :data:~panel_flowdash.parameters.PARAMETER_TYPES.

'value'
description str | None

What the parameter is, for whoever binds it.

None

Raises:

Type Description
ParameterError

If the name, field or type is malformed, the node does not exist, is one the user may not use, or the field is not one of its component's config fields, or the name is taken by a parameter the user may not see.

delete_group(group_id)

Remove a group and its nodes from the dashboard; returns the removed instance ids.

disconnect(source_id, source_port, target_id, target_port)

Remove the edge between two ports.

disconnect_input(instance_id, port)

Remove every edge into the input port of instance_id, as one edit.

dispose()

Tear down the editor, disposing every placed component.

Empties the dataflow graph, the canvas and the tile grid, then calls the dispose hook of each component that was placed, once. The editor is left empty and consistent, so it can still be used afterwards.

An editor created inside a server session disposes its components automatically when that session ends. In a notebook, under pyodide or for an editor created outside a session, call this yourself.

drop_code_drafts()

Forget the edits the code panel holds without running them, e.g. when leaving the dashboard.

edit_spec(instance_id, field=None)

Open the spec of the node instance_id in the code panel, showing the canvas if needed.

Where the browser keeps the panel in the sidecar, or the window is too narrow for it under the canvas, the sidecar's Spec tab shows it in the tab already open. Returns False to viewers.

end_agent_turns(run_id=None)

End the turns of the agent's requests, so the next request's edits start a new turn.

The dashboard tools call it when a request ends, whether it finished, failed or was cancelled. Each request's edits then become one version of the edit history. With run_id only that request's turn ends, so another agent's request running at the same time keeps its own.

end_ask_aside()

Let view mode keep Ask as it shows now, once what set_ask_aside made room for is gone.

E.g. the host's assistant closed in view mode without editing: Ask stays off, and edit mode ending later does not bring it back.

end_turn()

End the turn of the person's edits, so their next edit starts a new turn.

Call it when the person sends a request to an agent, which the FlowDash assistant does, so the edits made before and after the request form separate turns.

ensure_components_loaded(component_ids=None)

Import component modules and build their specs, if not done already.

Called automatically whenever specs are needed. On a live server prefer :meth:ensure_components_loaded_async, which imports off the event loop.

Parameters:

Name Type Description Default
component_ids Iterable[str] | None

Import only these components. Defaults to the whole catalog, which is what the editor palette needs; viewing a dashboard passes just the components it places, so an unrelated component doing work at import time cannot slow it down.

None

ensure_components_loaded_async(component_ids=None) async

Async :meth:ensure_components_loaded, importing off the event loop.

If the awaiting task is cancelled (e.g. by a newer navigation) the imports already running finish in their thread, but nothing is marked loaded and their import errors are not reported; the next call retries whatever is still unimported and reports its errors then.

exclude_from_filter(column, instance_id, excluded=True)

Opt the view instance_id out of the global filter on column, or back in.

expand_group(group_id)

Expand a collapsed group, see :meth:collapse_group.

export_dashboard(*, questions=True)

Return the canvas as a JSON-serializable dict, as the Download button writes it.

The dashboard id, owner and sharing rules are omitted, so the file can be loaded into any dashboard with :meth:import_dashboard. With questions False its turns leave out what was asked of the agent, see :func:export_model.

group_nodes(instance_ids, label=None, *, group_id=None, collapsed=False)

Frame nodes together on the canvas as one group, as one edit, and return its id.

The nodes keep their place, config, connections and tiles. A group can be collapsed into one node showing the ports its connections cross, see :meth:collapse_group.

Raises:

Type Description
ValueError

If there are no nodes, a node is not on the canvas or already in a group, or group_id is taken or not a valid name.

group_of(instance_id)

Return the id of the group a node is in, or None.

import_dashboard(data, *, keep_turns=False)

Replace the canvas with an exported dashboard, as dropping its file does.

data is a downloaded dashboard file, as JSON text or a dict, or a dashboard in the YAML format (see :mod:panel_flowdash.agent). The loaded dashboard keeps its id, owner, title and sharing rules, so saving writes the imported contents to it. Without a loaded dashboard the file's title is used and saving creates a new one. The canvas is marked dirty.

The import is an edit of its own, in the turn of whoever makes it (see :attr:turns). By default the file's turns and node origins replace the canvas's, and nodes the file gives no origin get the import's turn. With keep_turns the file's turns and origins are ignored instead: the canvas keeps its turns, nodes already on it keep their origin and new nodes get the import's turn. That is how the agent's changes are loaded, so it cannot rewrite who made what. Nodes are matched by name: a node given another component under the same name keeps its origin, and a renamed node is a new node with the import's turn as its origin. A file that changes nothing opens no turn.

Raises:

Type Description
ValueError

If data is neither a dashboard export nor a dashboard in the YAML format.

input_values(instance_id)

Return the literal values set on the unconnected inputs of a placed node, by port.

A connected input's literal is listed too; it applies once the connection is removed.

is_admin(*, fresh=False)

Whether this session administers the project, as :attr:authorize_admin says.

With fresh the host checks again from its sources, e.g. the project file read afresh, as before an admin action runs.

keep_tile_placement(instance_id)

Keep the tile of the node instance_id where it is when the agent's request ends.

While a request runs, tiles it adds are laid out only when it ends (all at once). A host that places the tile itself during the request calls this, so the layout at the end does not move it again.

later_turns(instance_id)

Return copies of the turns after a node's origin whose summary says they changed it.

load(asset_id)

Load a dashboard from the configured store, by id or title.

load_model(model)

Hydrate the canvas from an :class:AssetModel.

Items and edges that cannot be restored, such as a component this editor does not offer or an edge whose port no longer exists, do not abort the load. They are shown as placeholders and saved back unchanged.

Only the components the model places are imported, so a component that does work at import time cannot slow down dashboards that do not use it. On a live server prefer :meth:load_model_async, which imports off the event loop.

load_model_async(model) async

Async :meth:load_model, importing the model's components off the event loop.

made_by_agent(instance_id)

Whether "How was this made?" applies: an agent's request created the node.

may_rename()

Whether this session may rename the open dashboard, see :attr:authorize_rename.

A dashboard that is not stored yet may always be renamed.

new_dashboard(title)

Start a new empty dashboard, persisting it if a store is configured.

node_actions(instance_id, *, admin=None)

Return the registered node actions offered for a node to the person using the editor.

A restricted node or a placeholder gets none, nor does an action outside the editor's mode (see NodeAction.modes); an admin_only action needs :meth:is_admin, and an action whose applies fails is left out. admin says whether the session is an admin, which :meth:is_admin is asked otherwise.

node_component(instance_id)

Return the live component of the node instance_id, or None.

None for a function component, which has no instance, and for an id that is not on the canvas. The reverse of :meth:node_id.

node_id(component)

Return the id of the node component was created for, or None if it is not one of this editor's.

Only components that are Viewer classes are known by instance; a function component can call :func:current_node_id from its body.

node_inputs(instance_id, port=None)

Return the edges into the node instance_id, or only those into its input port.

Each is a dict with the source node's instance id, its source_port, the target (instance_id), the target_port and the edge's transform steps, in the order they were connected. Changing the dicts changes nothing on the canvas.

node_name(instance_id)

Return the name the node instance_id has in the dashboard YAML, e.g. "sales_chart".

node_names()

Return the YAML names of the canvas's nodes, by instance id.

They are worked out again only when the nodes change.

node_origin(instance_id)

Return the id of the turn that created a node, or None if no turn is recorded.

node_provenance(instance_id)

Return the provenance a node's numbers have, and the id of the node that reports it.

That is the node's own __flowdash_provenance__ or else the nearest upstream node's, following its inputs breadth first, each hook told the edges between it and this node (via), see :mod:panel_flowdash.node_actions. None when no node reports one.

note_own_run(run_id)

Record that the person using this editor asked for run run_id, so it is never redacted for them.

open_code_panel(instance_id, field=None, *, focus=True)

Edit the spec field field of the node instance_id in the code panel.

field defaults to the node's first spec field, a code field or a spec dict; a node without one shows its result only. The panel opens under the canvas where it was last docked there and fits, otherwise in the sidecar's Spec tab, which then shows the node. Returns False, leaving the panel as it was, where it cannot be shown: to viewers, or for a node or field it cannot edit. Callers then fall back to the field's own editor.

open_spec_in_sidecar(instance_id)

Move the code panel into the sidecar's Spec tab, remembered for the browser, showing instance_id.

origin_turn(instance_id)

Return a copy of the turn that created a node, or None if no turn is recorded.

parameters_schema()

Return the JSON Schema of a form binding the parameters, each defaulting to its field's value.

See :func:~panel_flowdash.parameters.parameters_schema.

provenance_warning(instance_id)

Return the nearest warning about a node's numbers, which tiles, reports and exports show.

Unlike :meth:node_provenance it looks past nearer provenance that is no warning, e.g. a capped analysis read through a node labelled "Derived": a label says what the nearest source is, a warning holds for everything computed from the numbers it is about. The walk stops :data:_PROVENANCE_DEPTH (64) edges up, so a warning further up than that is not found.

redo()

Redo what the last :meth:undo undid, all of it, and return whether anything was redone.

Redo is available until the next edit.

Raises:

Type Description
PermissionError

As for :meth:undo.

refresh_provenance(nodes=None)

Offer anew the node actions and provenance labels of every node, or of nodes and those downstream.

After an edit the editor does this itself for the nodes the edit may have changed. Call it when what a __flowdash_provenance__ hook or an action's applies reads changes outside the dashboard, e.g. a metric a project file defines being deleted. nodes are names as in the dashboard YAML, or instance ids.

remove_component(instance_id)

Remove a placed component along with its edges and its tile.

remove_parameter(name)

Remove a parameter; the node keeps the value its field holds.

Returns whether it existed; a parameter the user may not see counts as missing.

rename_group(group_id, label)

Change the label a group's header shows, as one edit.

report_shows(instance_id)

Whether a block of the report shows node instance_id, itself or with its group.

run_node_action(instance_id, key)

Run the node action key on a node, checking again that it is offered to this session.

An admin_only action asks :attr:authorize_admin afresh first.

Raises:

Type Description
PermissionError

If the action is not offered for the node, e.g. outside its modes or an admin_only action for someone who is no admin (any more).

run_redacted(run_id)

Whether a request is shown to the person viewing without its content.

Their own requests are always shown in full. Anyone else's are redacted for people who may not edit the dashboard, and when the request created or changed a node whose component this person may not use.

save(title=None)

Persist the current canvas and return the saved model.

With no store configured the model is still built and returned, so the caller can persist it themselves.

The owner, sharing rules and (unless title is given) title are taken from the stored dashboard rather than from the copy loaded into the editor, so saving never reverts a rename or sharing change made from another session since the dashboard was opened. If the dashboard is no longer stored (deleted from another session, or loaded from elsewhere), saving creates it with this editor's :attr:user as the owner, so it is never recreated under the previous owner's name.

Raises:

Type Description
RuntimeError

If :attr:read_only is set, or :attr:authorize_dashboard no longer grants edit access to the stored dashboard (which also sets :attr:read_only).

AssetConflictError

If the store holds a newer revision of the dashboard than the one loaded into the editor, because another session saved it since. Nothing is written; reload the dashboard or use :meth:save_as.

save_as(title)

Persist the current canvas as a new dashboard titled title and switch to it.

The new dashboard is owned by this editor's :attr:user and not shared with anyone. With no store configured the model is still built and returned.

Raises:

Type Description
RuntimeError

If :attr:read_only is set.

set_ask_aside()

Close Ask in view mode for something taking its place, such as the host's assistant.

View mode still gets Ask back as edit mode ends, e.g. after the assistant's first edit, as it does after Ask is closed in edit mode.

set_default(instance_id, config)

Give the node instance_id config values its component chose as a starting point.

A component calls it for a node :func:placement_context reports as "new", from its __init__ or function body, or later, e.g. once an input arrives. The values are saved with the dashboard like any config, and are part of the edit that brought them about: the placement, or the connection that delivered the input, so one undo takes back both. Values set outside any edit, e.g. by an input that arrives on its own, are recorded right away as a config edit of their own, so undoing a later edit keeps them. Called from a thread other than the session's event loop, they are set and recorded on the loop, as an edit of their own, and before a save.

Only fields still at their declared default take a value, so a node that arrives configured, e.g. one the agent adds or a duplicate, keeps its config. Returns whether any field took one: False, changing nothing, also while a dashboard is loaded or a version restored, to viewers and in a preview, and for a node or a config field the node does not have.

set_edge_transform(source_id, source_port, target_id, target_port, transform)

Replace the transform applied along an edge.

Each step is a dict naming an op from :data:panel_flowdash.transforms.TRANSFORMS plus its arguments, for example [{"op": "column", "column": "capacity"}, {"op": "aggregate", "how": "sum"}]. Pass an empty list to remove the transform.

Returns:

Type Description
bool or str

True on success, or a message explaining the rejection. A rejected transform leaves the edge on its previous one.

set_filter_value(column, value)

Change what the global filter on column keeps for whoever is viewing, without an edit.

value is a list of values for a select filter, [start, end] for a range, or None to keep every row.

set_filters(filters, *, label=None)

Replace the dashboard's global filters, views they exclude by instance id, as one undoable edit.

Raises:

Type Description
ValueError

If filters are malformed or exclude a node the dashboard does not have.

set_input_value(instance_id, port, value)

Give an input of a placed node a literal value, used while nothing is connected to it.

A connection always wins over the literal, which applies again once the connection is removed. None removes the literal, and the input goes back to its default. The change is recorded in the edit history.

Raises:

Type Description
KeyError

If no component is placed under instance_id.

ValueError

If the component has no such input, the input cannot hold a literal, e.g. a DataFrame, or it refuses value.

set_input_values(instance_id, values)

Set or remove (with None) the literal values of several inputs, as one edit.

Every value is checked before any is set, so a refused one changes nothing; see :meth:set_input_value.

set_report(report, *, label=None, coalesce=True)

Replace the dashboard's report, nodes by instance id, as one undoable edit.

None removes it, so the dashboard reads as its derived report again. label describes the edit in the history and the turn's summary, "Changed the report" by default, or a list of labels for an edit making several changes. A pending turn the report no longer refers to goes with its block, as it was only ever asked in the report. With coalesce False the edit is a version of its own, never batched with the quick edits before or after it, as for a structural change such as moving a block.

When the agent makes the edit, each block it adds or changes gets its turn as origin, and the blocks it leaves as they were keep theirs, whatever report gives.

Raises:

Type Description
ValueError

If report is malformed or refers to a node, group or turn the dashboard does not have.

set_title(title)

Rename the open dashboard as an edit: undoable, and stored when the dashboard is saved.

Raises:

Type Description
PermissionError

If the dashboard is read-only or this session may not rename it.

show_ask()

Bring the Explore view's feed on screen: Ask docked in view mode, the Explore view otherwise.

show_how_made(instance_id, turn_id=None)

Show the agent request that created a node, or the later turn turn_id that changed it.

It shows the request's span (question, model calls, tool calls and published versions) while :attr:agent_state holds the run's steps, and what the turn records otherwise, followed by the turns that changed the node later. In edit mode it opens the sidecar's History tab for the node; in view mode it opens the side sheet. Requests are redacted as :meth:run_redacted decides, and when the node's component is one the person may not use.

show_in_report(instance_id, label=None)

Append a block showing node instance_id to the report, unless a block shows it.

This is how a standalone report shows what is added to it, as a dashboard places a tile. Returns whether a block was added.

title_renamed(title)

Note that the open dashboard was renamed to title in the store, e.g. by the Rename action.

Undo then keeps that name rather than bringing back the old one.

to_model(title=None)

Serialize the current canvas into an :class:AssetModel.

The returned model is detached from the editor, so this is the seam to use when persisting to something other than the configured store.

toggle_palette()

Fold the component palette beside the canvas, or open it and focus its search field.

toggle_split()

Show the canvas and the tile grid side by side, or return to the previous tab.

trigger_refresh()

Trigger refresh with every change it causes delivered as one propagation pass.

A node fed by two sources that both run again then runs once, with both new values, instead of once per source.

undo(*, whole_runs=True)

Undo the last edit to the dashboard and return whether anything was undone.

A person's edits are undone one at a time, a gesture such as a drag as one edit. The edits an agent made for one request are undone together, back to the dashboard as it was before the request, unless whole_runs is False. Undo reaches back into earlier sessions, as far as the store keeps the dashboard's history (see :attr:history_limit).

Undoing restores the dashboard's turns and node origins as they were, and never brings back a node whose component the user may not use or that this editor does not offer.

Raises:

Type Description
PermissionError

If undoing would bring back such a node; nothing changes.

ungroup(group_id)

Remove a group's frame, keeping its nodes where they are, as one edit.

Returns the instance ids of the nodes that were in it.

NodeAction dataclass

An entry a component library adds to a node's â‹® menus.

admin_only = False class-attribute instance-attribute

Only offer and run the action for an admin of the project, see FlowDash.authorize_admin.

applies = None class-attribute instance-attribute

Whether the action applies to a node; None applies to all. Called whenever a menu is built.

icon = None class-attribute instance-attribute

key instance-attribute

A unique id, e.g. "lumen.save_as_metric".

label instance-attribute

The menu label, e.g. "Save as metric…".

modes = field(default_factory=lambda: frozenset({'edit'})) class-attribute instance-attribute

The modes of :data:MODES the action is offered and runs in; edit mode only by default.

run instance-attribute

Called with the :class:NodeActionContext of the node when the action is picked.

NodeActionContext

What a node action may read and change: the node, the dashboard through its ops, the project.

Nodes and ports are named as in the dashboard YAML. :attr:node is the node the action was picked on; the read methods take another node's name to read that one instead. Changes go through :attr:ops, a :class:NodeActionOps limited to the open dashboard, with the rights of the person using the editor, and :meth:edit makes several of them one step of the edit history.

context property

A read-only view of the resources the host gave the editor, see dashboard_context.

mode property

The mode the editor is in, one of :data:MODES.

node = editor.node_name(instance_id) instance-attribute

ops = NodeActionOps(self._ops) instance-attribute

project property

The project file the app reads, e.g. to save a section with Project.set; None without one.

close_dialog()

Close the session's page dialog.

component(name=None)

Return the component id of a node, or None for a placeholder or a node it does not know.

config(name=None)

Return a copy of a node's config.

edit()

Make the changes inside the block one step of the edit history, which one undo reverts.

If the block raises, the dashboard goes back to how it was before the block, also in an editor without an edit history, and the failed changes are neither undone nor redone later.

input_value(port, name=None)

Return the value a node's input port holds now, after its edge's transform.

inputs(name=None)

Return the edges into a node, each {"from", "to", "transform"} with node.port ends.

is_admin()

Whether the person still administers the project, with the project file read again.

nodes()

Return the names of the dashboard's nodes.

notify(kind, message)

Show a notification; kind is "success", "info", "warning" or "error".

open_dialog(title, content, *, width='sm')

Show content in the session's page dialog, see panel_flowdash.util.open_dialog.

output(port, name=None)

Return the current value of a node's output port, see DashboardOps.node_output.

outputs(name=None)

Return the edges out of a node, as :meth:inputs does.

replace_node(name, component, config=None, *, new_name=None, rewire=None)

Replace node name by a new node of component, wired to what it fed, in its tile slot.

Each edge out of the old node (as :meth:outputs gives it) is passed to rewire, which returns the new node's output port for it and the edge's transform; without rewire each edge keeps its port and transform. rewire may raise ValueError to refuse an edge. The new node takes the old one's tile, or stays hidden when the old one had no visible tile, and the old node is removed. One step of the edit history; if any step fails nothing is changed. Returns the new node's name.

tile(name=None)

Return where a node's visible tile is, {"area", "index", "width", "height"}, or None.

NodeActionOps

The part of :class:~panel_flowdash.agent.DashboardOps a node action may use.

It reads the open dashboard and changes its nodes, edges, tiles, groups, filters and parameters, each change checked and recorded as the full ops do. It leaves out what reaches past the node's dashboard or past an edit the person could undo: saving, opening, listing, renaming or replacing dashboards, their settings and report, sending files and running the assistant's pending questions. A library that needs one of those offers its own UI for it rather than doing it from a node's menu. It is a fence for well-behaved libraries, not a security boundary: an action runs in-process and can reach the editor through Python anyway.

METHODS = frozenset({'add_filter', 'add_node', 'arrange_canvas', 'arrange_layout', 'arrange_tiles', 'bind_parameters', 'connect', 'declare_parameter', 'describe_layout', 'disconnect', 'filter_reach', 'filters', 'group', 'group_nodes', 'hidden_tiles', 'list_components', 'node_config', 'node_output', 'nodes', 'parameters', 'place_tile', 'preview', 'remove_filter', 'remove_node', 'remove_parameter', 'revision', 'set_config', 'set_inputs', 'set_transform', 'ungroup', 'validate'}) class-attribute instance-attribute

get_dashboard()

Return the open dashboard as YAML, see DashboardOps.get_dashboard.

Project dataclass

A loaded project file.

It holds the raw data, where each key and value is written, by path (e.g. ("metrics", "capacity", "table")), the value each registered loader made of its section, the warnings found while loading and the context the loaders were given.

context = field(default_factory=dict) class-attribute instance-attribute

data = field(default_factory=dict) class-attribute instance-attribute

directory property

Return the directory the file is in, against which paths it names resolve.

path = None class-attribute instance-attribute

positions = field(default_factory=dict) class-attribute instance-attribute

warnings = field(default_factory=list) class-attribute instance-attribute

get(name, default=None)

Return the value of section name, or default if the file has none.

The value is what the section's loader returned. A section whose loader was registered after the file was loaded is loaded now (raising ProjectError); a section no loader is registered for gives its raw data.

load_all()

Load every section a loader is registered for, warning about the others.

Raises ProjectError with every problem the loaders found.

position(path)

Return the 1-based line and column of the value at path.

A path that is not in the file gives the position of its nearest enclosing value.

problem(path, message, key=False)

Return a problem at the value at path (with key, at the key naming it).

raw(name, default=None)

Return the raw YAML data of section name.

set(name, value)

Set section name to value and write it to the project's file.

The value goes through the section's dump and the result through its loader, so a value the loader rejects raises ProjectError, positioned where it would be written, and the file is left alone. Only the lines of this section change in the file; comments inside it are not kept. Text a YAML 1.1 reader would take for something else, such as no or 1:20, is quoted.

update(name, change)

Change section name from its raw data as the file has it now, and write it.

change is called with a copy of the section's raw YAML data, read again from the file (None when the file has no such section), and returns the new value, which is written as set writes it. The read, change and the write happen under FILE_LOCK, so no other write from this process comes in between. An exception from change leaves the file alone. Returns the value written.

Provenance dataclass

Where a node's numbers come from, e.g. a named metric or a query of its own.

detail = '' class-attribute instance-attribute

A sentence shown on hover, e.g. the metric's description or how the number was computed.

icon = None class-attribute instance-attribute

A Material icon name for the chip, "warning" by default for a warning.

kind = '' class-attribute instance-attribute

What kind of provenance it is, e.g. "metric" or "ad hoc", for styling and tests.

label instance-attribute

A short label, e.g. "Metric: capacity" or "Ad hoc".

level = 'info' class-attribute instance-attribute

"warning" if it warns about the numbers, e.g. that a row limit cut them, which every viewer is shown.

note property

The label and detail as one line of text, e.g. for a caption in an export.

warning property

Whether it warns about the numbers, see :attr:level.

_takes_via(hook)

call_provenance_hook(instance, via=())

Return what instance.__flowdash_provenance__ reports, or None if it has no hook or it fails.

via is passed on to a hook that takes it, see :mod:panel_flowdash.node_actions.

node_actions()

Return the registered actions, in the order they were registered.

register_node_action(action)

Offer action in the node menus of every editor, replacing one of the same key.

unregister_node_action(key)

Stop offering the action registered under key.