API Reference¶
The objects exported from panel_flowdash. Each module has its own page in the navigation.
panel_flowdash
¶
panel-flowdash: Dataflow and draggable grid based dashboard editor for Panel.
PlacementReason = t.Literal['new', 'load', 'restore']
module-attribute
¶
PreviewCaller = t.Literal['card', 'popout', 'inspector', 'code_panel']
module-attribute
¶
RENAMED_CLASSES = {'AssetModel': 'DashboardModel', 'AssetItem': 'DashboardItem', 'AssetEdge': 'DashboardEdge', 'AssetTurn': 'DashboardTurn', 'BaseAssetStore': 'BaseDashboardStore', 'AssetStore': 'DashboardStore', 'MemoryAssetStore': 'MemoryDashboardStore', 'JSONFolderAssetStore': 'JSONFolderDashboardStore', 'AssetStoreError': 'DashboardStoreError', 'AssetConflictError': 'DashboardConflictError'}
module-attribute
¶
SELECTION_TYPE = register_port_type('Selection')
module-attribute
¶
_OLD_NAMES = {old: new for new, old in RENAMED_CLASSES.items()}
module-attribute
¶
__all__ = ['SELECTION_TYPE', 'AssetConflictError', 'AssetEdge', 'AssetItem', 'AssetModel', 'AssetStore', 'AssetStoreError', 'AssetTurn', 'AuthConfig', 'BaseAssetStore', 'CheckDiagnostic', 'CheckWarning', 'Choices', 'ComponentSpec', 'ConfigField', 'ContractContext', 'ContractError', 'ContractProblem', 'DashboardParameter', 'DashboardSettings', 'DataAction', 'DataChip', 'DataflowGraph', 'FilterTarget', 'FlowDash', 'Identity', 'InputPort', 'JSONFolderAssetStore', 'MemoryAssetStore', 'NodeAction', 'NodeActionContext', 'NodeActionOps', 'OutputPort', 'PanelAppMetadata', 'ParameterContract', 'ParameterError', 'Permission', 'PlacementReason', 'Predicate', 'PreviewCaller', 'Provenance', 'Registration', 'RegistryEntry', 'Selection', 'SelectionLink', 'SidebarAction', 'SidebarContext', 'SidebarItem', 'SidebarSection', 'SpecSetting', 'Suggestion', 'Transform', 'Upstream', '__version__', 'agent_edits', 'build_component_spec', 'build_component_specs', 'build_node_state_class', 'build_session_state_class', 'can_administer', 'can_edit', 'check_requirements', 'columns_of', 'current_dashboard', 'current_node_id', 'dashboard_context', 'from_holoviews', 'from_vega', 'is_authorized', 'link_selection', 'normalize_components', 'normalize_port_type', 'panel_app', 'placement_context', 'port_type_color', 'port_types_compatible', 'preview_context', 'preview_off_loop', 'register', 'register_node_action', 'register_port_type', 'request_filters', 'resolve_identity', 'unregister_node_action']
module-attribute
¶
__version__ = importlib.metadata.version(__name__)
module-attribute
¶
panel_app = register
module-attribute
¶
AssetConflictError
¶
Bases: AssetStoreError
A save was refused because the dashboard changed since it was loaded.
Raised by :meth:BaseAssetStore.save_asset when the stored
revision differs from the revision the saved model was loaded at, that is
when another session saved the dashboard in the meantime.
Attributes:
| Name | Type | Description |
|---|---|---|
asset_id |
The dashboard that was being saved. |
|
expected |
The revision the rejected model was based on. |
|
current |
The revision now stored. |
AssetEdge
dataclass
¶
A connection between two component ports, with the transform steps it applies.
AssetItem
dataclass
¶
A component instance on the dashboard.
x, y store the ReactFlow node canvas position. Grid layout (widths, heights, visibility) lives in AssetModel.tile_layout. origin is the id of the turn that created the item, see AssetModel.turns. inputs holds literal values of unconnected inputs, by port; a connection wins over them.
collapsed = False
class-attribute
instance-attribute
¶
component_id
instance-attribute
¶
config = field(default_factory=dict)
class-attribute
instance-attribute
¶
inputs = field(default_factory=dict)
class-attribute
instance-attribute
¶
instance_id
instance-attribute
¶
origin = None
class-attribute
instance-attribute
¶
preview_output = None
class-attribute
instance-attribute
¶
x = 0
class-attribute
instance-attribute
¶
y = 0
class-attribute
instance-attribute
¶
from_dict(data)
classmethod
¶
to_dict()
¶
AssetModel
dataclass
¶
A persisted dashboard: nodes + edges + tile layout, and the turns that made them.
asset_id
instance-attribute
¶
breakpoints = field(default_factory=list)
class-attribute
instance-attribute
¶
dashboard_id
property
writable
¶
Deprecated alias of :attr:asset_id.
edges = field(default_factory=list)
class-attribute
instance-attribute
¶
filters = field(default_factory=list)
class-attribute
instance-attribute
¶
groups = field(default_factory=list)
class-attribute
instance-attribute
¶
items = field(default_factory=list)
class-attribute
instance-attribute
¶
kind = DASHBOARD_KIND
class-attribute
instance-attribute
¶
owner
property
¶
The owner principal: the creating user, unless an admin gave it to someone else.
parameters = field(default_factory=dict)
class-attribute
instance-attribute
¶
permission = field(default_factory=Permission)
class-attribute
instance-attribute
¶
reference_width = None
class-attribute
instance-attribute
¶
report = None
class-attribute
instance-attribute
¶
responsive_layouts = field(default_factory=dict)
class-attribute
instance-attribute
¶
revision = None
class-attribute
instance-attribute
¶
settings = field(default_factory=dict)
class-attribute
instance-attribute
¶
source = None
class-attribute
instance-attribute
¶
tile_layout = field(default_factory=list)
class-attribute
instance-attribute
¶
title
instance-attribute
¶
turns = field(default_factory=list)
class-attribute
instance-attribute
¶
updated_at = field(default=None, compare=False)
class-attribute
instance-attribute
¶
user_id
instance-attribute
¶
version = MODEL_VERSION
class-attribute
instance-attribute
¶
from_dict(data)
classmethod
¶
Read a model from its dict, including one written before the rename with dashboard_id.
to_dict()
¶
AssetStore
¶
Bases: BaseAssetStore
SQLite-backed store for dashboard models.
Each thread reuses one connection, so a _get_conn() block nested in
another on the same thread (for example in a subclass) shares its
transaction: the inner block's commit or rollback ends the outer one too.
all_assets(kind=None)
¶
append_history(asset_id, record)
¶
close()
¶
Close the connections this process opened; later calls reopen them.
delete_asset(user_id, asset_id)
¶
delete_history(asset_id)
¶
find_by_id_or_title(ref, identity=None, *, default_allow=True)
¶
list_assets(user_id, kind=DASHBOARD_KIND)
¶
load_asset(user_id, asset_id)
¶
load_history(asset_id)
¶
rename_asset(user_id, asset_id, new_title)
¶
replace_history(asset_id, records)
¶
rewrite_history(asset_id, rewrite)
¶
save_asset(dashboard)
¶
set_owner(asset_id, owner)
¶
set_permission(asset_id, permission)
¶
Persist a new permission set on a dashboard. Returns success.
title_exists(user_id, title, exclude_id=None, kind=DASHBOARD_KIND)
¶
Check if a dashboard of kind with the given title already exists for this user.
AssetStoreError
¶
Bases: Exception
A store refused an operation for a reason the user should see.
Raise it from a :class:BaseAssetStore method to reject a request, for
example a duplicate title, a name the backend cannot store or a missing
permission. The app shows the message to the user as written and leaves
its state unchanged, so phrase it for an end user. Any other exception is
treated as a bug or an infrastructure failure and is logged with its
traceback.
AssetTurn
dataclass
¶
One request to an agent, or one batch of a person's edits, that changed a dashboard.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Unique within the dashboard and never reused, so the nodes'
|
actor |
str | None
|
|
at |
str | None
|
When the turn's first edit was made, as ISO 8601 UTC, e.g.
|
run |
str | None
|
The panel-agents run id of the agent's request. |
question |
str | None
|
What the person asked the agent. Recorded by default; exports can
leave it out, see :func: |
summary |
str | None
|
What the turn changed, a few words per change. |
status |
str | None
|
|
actor = None
class-attribute
instance-attribute
¶
at = None
class-attribute
instance-attribute
¶
id
instance-attribute
¶
question = None
class-attribute
instance-attribute
¶
run = None
class-attribute
instance-attribute
¶
status = None
class-attribute
instance-attribute
¶
summary = None
class-attribute
instance-attribute
¶
from_dict(data)
classmethod
¶
Read a turn written by :meth:to_dict, ignoring keys it does not know.
Raises:
| Type | Description |
|---|---|
TurnError
|
If a field has the wrong type or value, or one that is required is missing. |
to_dict()
¶
Return the turn as JSON data, leaving out fields that are not set.
AuthConfig
dataclass
¶
Project-level authorization configuration.
Loaded from the project's __init__.py by the serve command. All fields
are optional; the defaults reproduce the pre-auth behavior (allow by
default, groups read from the standard claim keys, no admin groups).
admin_groups = field(default_factory=frozenset)
class-attribute
instance-attribute
¶
default_allow = True
class-attribute
instance-attribute
¶
group_claims = DEFAULT_GROUP_CLAIMS
class-attribute
instance-attribute
¶
resolve_groups = None
class-attribute
instance-attribute
¶
user_groups = field(default_factory=dict)
class-attribute
instance-attribute
¶
from_module(module)
classmethod
¶
Build an :class:AuthConfig from names on a project __init__.
Reads group_claims, user_groups, resolve_groups,
admin_groups and default_allow if present, falling back to the
defaults otherwise. Missing module or names yield a default config.
BaseAssetStore
¶
Bases: ABC
The persistence interface the editor and app shell depend on.
Subclasses implement the six storage primitives below; the access-control and lookup helpers are backend-independent and inherited. Implement this to back dashboards with something other than SQLite.
To refuse a create, save, rename, delete or permission change, raise
:class:AssetStoreError with a message for the user.
Stores that detect concurrent edits keep a revision per dashboard: every
save stores dashboard.revision + 1 (see :func:check_revision), and a
save based on an older revision than the stored one raises
:class:AssetConflictError. A store that does not support revisions
simply ignores the field and saves last-writer-wins.
Models returned by listings may be shared with a backend cache, so callers treat them as read-only; single-dashboard lookups return private copies.
Set :attr:random_ids to False in a store whose ids can be guessed.
random_ids = True
class-attribute
instance-attribute
¶
Whether dashboard ids are random, so only someone given a link knows one.
The default :meth:create_asset makes random ids. A store whose ids
can be guessed (derived from titles, say) sets this to False, and the app
then answers a dashboard someone may not open exactly like a missing one,
rather than saying it exists and who owns it. Even with random ids, an id
a caller chose when saving (see :meth:guessable_id) is treated so.
all_assets(kind=None)
¶
Every stored dashboard regardless of owner, most recently updated first.
kind keeps only assets of that kind ("dashboard", "report"
or "chat"); None keeps every kind. No access check is applied: use
:meth:list_accessible for what a user may open. Some stores hand out
shared, cached models, so copy one (or load it with
:meth:load_asset) before changing it. Custom stores implement
:meth:_all_assets, not this method.
append_history(asset_id, record)
¶
Add a record to the end of a dashboard's edit history.
Does nothing when the dashboard is not stored, e.g. because it was deleted while an editor still had it open.
can_administer(identity, asset_id, admin_groups=frozenset())
¶
Whether identity may administer (rename/delete/share) the dashboard.
Administering includes editing, see :meth:can_edit.
can_administer_model(identity, dashboard, admin_groups=frozenset())
¶
Like :meth:can_administer, for a dashboard that is already loaded.
Listings use it to avoid loading every dashboard a second time.
Override this method, not :meth:can_administer, to change who may
administer a dashboard.
can_edit(identity, asset_id, admin_groups=frozenset())
¶
Whether identity may edit and save the dashboard's contents and settings.
can_edit_model(identity, dashboard, admin_groups=frozenset())
¶
Like :meth:can_edit, for a dashboard that is already loaded.
Administrators (see :meth:can_administer_model) may always edit;
anyone else needs an allow_edit_users/allow_edit_groups grant
on the dashboard's permission. Override this method, not
:meth:can_edit, to change who may edit a dashboard. A chat is
edited only by its owner, administrators included.
create_asset(user_id, title, kind=DASHBOARD_KIND)
¶
Create, persist and return a new empty dashboard (or chat or report, with kind).
A report starts with an empty document, so it never reads as the report a dashboard derives from its tiles.
delete_asset(user_id, asset_id)
abstractmethod
¶
Delete a dashboard owned by user_id. Returns whether one was removed.
delete_history(asset_id)
¶
Drop a dashboard's edit history.
find_by_id_or_title(ref, identity=None, *, default_allow=True)
¶
Resolve a dashboard by its id first, then by title.
Titles are only unique per user, so a title can match several
dashboards. Without identity (trusted code, such as
:meth:FlowDash.load) the most recently updated match is returned.
With identity, as when resolving the operator-configured home
dashboard, a dashboard the identity may not open is never returned.
The identity's own dashboard with that title wins. Otherwise a title
owned by a single user resolves to that user's most recently updated
dashboard, while a title owned by several users is ambiguous and
resolves to None (the app then shows the launcher) with an error
logged asking for the dashboard id. Picking one of them instead would
let any user take over everyone's home page by creating a dashboard
with the same title.
get_owner(asset_id)
¶
Return the owner (user_id) of a dashboard, or None if missing.
guessable_id(asset_id)
¶
Whether asset_id could be guessed rather than only learned from a link.
Only ids of the form :meth:create_asset makes count as random in
a store with :attr:random_ids. Any store saves whatever id a model
carries, so one chosen by the caller, like the slug an example seeds
its dashboards under, can be guessed. A store whose own ids look
different overrides this.
list_accessible(identity, *, default_allow=True, kind=DASHBOARD_KIND)
¶
List dashboards of kind the identity owns or has been granted access to.
Chats are left out unless kind is "chat" or None, and only
the identity's own chats are ever listed. Owned dashboards sort first
(both groups by recency), so a user's own dashboards stay visually
grouped ahead of ones shared with them.
list_assets(user_id, kind=DASHBOARD_KIND)
¶
Dashboards of kind owned by user_id, most recently updated first.
Pass kind="chat" for the user's chats, kind="report" for their
reports, or None for every kind.
load_asset(user_id, asset_id)
¶
Load a dashboard, but only if user_id owns it.
load_for_access(identity, asset_id, *, default_allow=True)
¶
Load a dashboard if identity is authorized, else None.
Returns None both when the dashboard does not exist and when access
is denied, so callers render a single "not found / denied" view.
load_history(asset_id)
¶
Return the edit history records of a dashboard, oldest first.
rename_asset(user_id, asset_id, new_title)
abstractmethod
¶
Retitle a dashboard owned by user_id. Returns whether one was updated.
replace_history(asset_id, records)
¶
Replace a dashboard's edit history, e.g. with what retention keeps of it.
rewrite_history(asset_id, rewrite)
¶
Replace a dashboard's history with what rewrite returns for it, and return that.
rewrite returns its argument itself when nothing changes, which writes nothing. Stores used by several sessions at once override this to read and write in one transaction, so no record appended meanwhile is lost.
save_asset(dashboard)
abstractmethod
¶
Insert or update a dashboard.
Stores that support revisions refuse a dashboard whose revision
is not the stored one with :class:AssetConflictError, as one
atomic check and write, and on success set dashboard.revision to
the stored revision. Renaming a dashboard or changing its permission
does not change its revision.
set_owner(asset_id, owner)
¶
Give a dashboard to owner. Returns whether one was updated.
Only the admin view calls it, after checking that the caller is an
admin. Like renaming, it does not change the dashboard's revision. A
store that cannot change owners raises :class:AssetStoreError,
as this default does.
set_permission(asset_id, permission)
abstractmethod
¶
Persist a new permission set on a dashboard. Returns success.
title_exists(user_id, title, exclude_id=None, kind=DASHBOARD_KIND)
¶
Check if a dashboard of kind with the given title already exists for this user.
CheckDiagnostic
¶
Bases: str
A problem a config check returns with the field and the place in its text it concerns.
It is a str, the message, so a list of diagnostics is still a list of
problems. Lines and columns count from 1, and end_column is the column
just past the problem, so column=5, end_column=9 covers four
characters. suggestion is a replacement for that text, if the check
knows one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
What is wrong. |
required | |
field
|
The config field the problem is in, e.g. |
required | |
line
|
Where in the field's text the problem is. |
required | |
column
|
Where in the field's text the problem is. |
required | |
end_column
|
Where in the field's text the problem is. |
required | |
suggestion
|
Text that would fix it. |
required |
CheckWarning
¶
Bases: str
A message a config check returns that does not refuse the config.
Return it in place of a problem string, alone or in the list of problems, for something the check could not verify, e.g. a query whose probe timed out. The config is applied all the same, and the warning shown with it.
Choices
dataclass
¶
The values one config field may take.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
list[Any] | dict[str, Any]
|
The values, or a |
list()
|
restrict
|
bool
|
Whether only these values are allowed. With |
True
|
types
|
dict[Any, str] | None
|
A short type name per value, e.g. |
None
|
options = field(default_factory=list)
class-attribute
instance-attribute
¶
restrict = True
class-attribute
instance-attribute
¶
types = None
class-attribute
instance-attribute
¶
labelled()
¶
Return the options as {label: value}, each label showing the value's type if known.
values()
¶
Return the values, without labels.
ComponentSpec
dataclass
¶
Full specification of a component's ports and metadata.
check_config = None
class-attribute
instance-attribute
¶
component_id
instance-attribute
¶
config = field(default_factory=list)
class-attribute
instance-attribute
¶
config_choices = None
class-attribute
instance-attribute
¶
config_completions = None
class-attribute
instance-attribute
¶
config_editor = None
class-attribute
instance-attribute
¶
config_state_class = None
class-attribute
instance-attribute
¶
contract = None
class-attribute
instance-attribute
¶
default_size
instance-attribute
¶
description
instance-attribute
¶
framed = None
class-attribute
instance-attribute
¶
icon
instance-attribute
¶
inputs
instance-attribute
¶
max_size = None
class-attribute
instance-attribute
¶
min_size = None
class-attribute
instance-attribute
¶
outputs
instance-attribute
¶
port_aliases = field(default_factory=dict)
class-attribute
instance-attribute
¶
tags
instance-attribute
¶
title
instance-attribute
¶
resolve_name(name)
¶
Return the current name of a port or config field that may have been renamed.
A name that is still a port or config field is never redirected, so an alias cannot shadow a live name.
ConfigField
dataclass
¶
ContractContext
dataclass
¶
What a :class:ParameterContract gets to compute or check a parameter's contract.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The parameter's name. |
parameter |
DashboardParameter
|
The parameter, with |
value |
Any
|
The value the parameter's field holds, the bound one when checking. |
document |
dict[str, Any]
|
The whole dashboard in the YAML format, with the value bound, as plain data. |
context |
Mapping[str, Any]
|
The editor's context (see |
ContractError
¶
Bases: ValueError
A bound value breaks what the dashboard relies on; nothing was applied.
problems maps each failing parameter's name to its problems.
ContractProblem
dataclass
¶
Something a bound value lacks that the dashboard relies on.
node names the node (as in the YAML) that would fail, or is None
for a problem with the value as a whole, e.g. a source that cannot be
read. A warning does not refuse the value, e.g. a node whose query
could not be analysed, so the contract does not cover it.
DashboardParameter
dataclass
¶
A named pointer to one config field of one node.
Attributes:
| Name | Type | Description |
|---|---|---|
node |
str
|
The node: its instance id in a :class: |
field |
str
|
A dotted path into the node's config, e.g. |
type |
str
|
One of :data: |
description |
str | None
|
What the parameter is, for whoever binds it. |
expects |
dict[str, Any] | None
|
What the dashboard relies on of a bound value, as the node's
component's :class: |
description = None
class-attribute
instance-attribute
¶
expects = None
class-attribute
instance-attribute
¶
field
instance-attribute
¶
node
instance-attribute
¶
type = 'value'
class-attribute
instance-attribute
¶
from_dict(data)
classmethod
¶
Read a parameter, raising :class:ParameterError if it is malformed.
to_dict()
¶
DashboardSettings
¶
Bases: Parameterized
Values that apply to a whole dashboard rather than to one component.
The editor keeps one instance in FlowDash.settings, fills it from the
loaded dashboard and writes its current values back on save. Subclass it to
add application-specific parameters and pass the subclass as
FlowDash(settings_class=...). Every parameter must hold a JSON
serializable value, since the stores persist settings as JSON.
controls_position = param.Selector(default='top', objects=['top', 'left'], label='Controls position', doc='\n Where the dashboard\'s controls (components registered with\n ``sidebar=True``) go: "top" in a slim row above the tiles, "left" in\n a collapsible panel beside them. Defaults to the editor\'s\n ``controls_position``.')
class-attribute
instance-attribute
¶
description = param.String(default='', label='Description', doc='\n A sentence or two on what the dashboard shows. Empty by default.')
class-attribute
instance-attribute
¶
header_layout = param.Selector(default='compact', objects=['compact', 'full'], label='Header layout', doc='\n How the dashboard\'s title, health and actions are laid out: "compact"\n on one line (in a FlowDashApp\'s top bar with the default navigation),\n "full" in a row of their own with a large title over the description,\n the health chip and when the dashboard was last refreshed. Defaults to\n the editor\'s ``header_layout``.')
class-attribute
instance-attribute
¶
node_previews = param.Boolean(default=False, label='Preview values on the canvas', doc="\n Whether each card on the wiring canvas previews its component's\n current value below its ports: the first rows of a table, a sparkline\n of numbers, a few items of a list. Without it a card summarizes the\n value in one line. Defaults to the editor's ``node_previews``.")
class-attribute
instance-attribute
¶
refresh_period = param.Number(default=0.0, bounds=(0, 86400), step=1, label='Refresh period (s)', doc='\n Seconds between automatic refreshes of the dashboard, which the editor\n announces by triggering its ``refresh`` event. 0 turns automatic\n refreshing off.')
class-attribute
instance-attribute
¶
tile_cards = param.Boolean(default=True, label='Show tiles as cards', doc="\n Whether each tile is drawn as a framed card with a bar for its status\n and actions. Without the card the tile renders as the component's own\n view, and its actions appear over its top-right corner on hover or\n keyboard focus.")
class-attribute
instance-attribute
¶
tile_titles = param.Boolean(default=False, label='Show tile titles', doc="\n Whether a card's bar also shows the tile's title and the component's\n description. Off by default, since most components show their own\n heading. Only applies while ``tile_cards`` is on.")
class-attribute
instance-attribute
¶
viewers_can_inspect = param.Boolean(default=False, label='Viewers can inspect outputs', doc='\n Whether people who may only view the dashboard get the inspect button\n on its tiles, when the editor has ``inspect_outputs`` on. Editors and\n administrators always get it. Leave it off when an output carries\n data a tile deliberately hides.')
class-attribute
instance-attribute
¶
DataAction
dataclass
¶
The Ask home's "add data" action, shown after the data chips.
Attributes:
| Name | Type | Description |
|---|---|---|
label |
str
|
What the action reads, e.g. |
action |
Callable[[FlowDashApp], Any] | str
|
A route or URL to open, or a callable given the session's
:class: |
icon |
str
|
Material icon name shown beside the label. |
DataChip
dataclass
¶
A piece of the project's data the Ask home offers to scope a question to.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
What the host knows the data by, e.g. |
label |
str
|
What the chip reads, e.g. |
group |
str | None
|
Chips of the same group are shown together under it, e.g. the source. |
detail |
str | None
|
A short note shown after the label, e.g. |
detail = None
class-attribute
instance-attribute
¶
group = None
class-attribute
instance-attribute
¶
id
instance-attribute
¶
label
instance-attribute
¶
coerce(value)
classmethod
¶
Return value, a chip or a mapping with id, label and group, as a chip.
to_dict()
¶
Return the chip as stored on a chat, without an empty group.
DataflowGraph
¶
Manages node state instances and wires edges with runtime validation.
edges
property
¶
All current edges.
node_ids
property
¶
All current node instance IDs.
propagate_failures = propagate_failures
instance-attribute
¶
wiring
property
¶
Whether an edge or literal is being changed, so the inputs it sets change because of an edit.
add_edge(source_id, source_port, target_id, target_port, transform=None)
¶
Wire an edge, returning True on success or a rejection reason.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transform
|
list[dict[str, Any]] | None
|
Steps applied to every value carried along the edge, each a dict
naming an |
None
|
add_node(instance_id, component_id)
¶
Create a new node state instance.
batch()
¶
Defer binding list inputs until the block exits.
Every edge into a list input rebinds it to all of its edges, so wiring N edges into one list input one by one costs O(N^2). Inside this block each list input is bound once, when the block exits, with all of its edges. Wiring an edge into any other input from a node downstream of a pending list input binds the pending inputs first, since validating the edge reads the value that node produces.
clear_literal(instance_id, port)
¶
Remove the literal value of an input; an unwired input goes back to its default.
That is the port's default, or for a port without one the default of the component's Parameter, the value the component had before.
get_config_state(instance_id)
¶
Get the config state instance for a node, if it has config.
get_edge_expression(source_id, source_port, target_id, target_port, stage=-1)
¶
Return the reactive expression carrying values along an edge, if it is wired.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
int
|
Number of transform steps applied: 0 is the source port's own value.
The default -1 is what the target receives, which with
|
-1
|
get_edge_transform(source_id, source_port, target_id, target_port)
¶
Return the transform steps of an edge as stored, or None if it is not wired.
get_failures(instance_id)
¶
Get the failures held by a node's inputs, if the node exists.
get_state(instance_id)
¶
Get the state instance for a node.
is_wired(instance_id, port)
¶
Whether an edge feeds the input port of a node.
literals(instance_id)
¶
Return a copy of the literal values set on a node's inputs, by port.
propagation()
¶
Deliver the values reaching node inputs inside this block as one pass.
Every value an edge carries to an input is held until the block exits, then each node receives all of its held values in one update, upstream nodes first, so a node whose inputs change together runs once with all of them. Values the nodes produce meanwhile join the same pass. A change of an output opens a pass of its own; wrap a change of several nodes at once, such as a refresh that runs every source again, in this block. Nested blocks join the outer pass.
register_specs(specs)
¶
Add component specs to the graph, keeping existing nodes intact.
Components are imported on demand, so specs arrive after the graph is constructed. Registering them incrementally avoids rebuilding the graph and losing the nodes and edges already placed on it.
remove_edge(source_id, source_port, target_id, target_port)
¶
Remove an edge and reset the target input to its literal or its default, see _default.
remove_node(instance_id)
¶
Remove a node and any edges connected to it.
The node's state is detached from everything it was bound to, both the edges feeding its inputs and any references its outputs follow, so it stops receiving values but keeps the ones it last held.
set_edge_transform(source_id, source_port, target_id, target_port, transform)
¶
Replace the transform of an existing edge, returning True or a rejection reason.
A rejected transform leaves the edge on its previous one.
set_literal(instance_id, port, value)
¶
Give the input port of a node a literal value, used while no edge feeds it.
The value is checked against the input first; a wired input keeps the value of its edge and takes the literal once the edge is removed.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the input does not exist, cannot hold a literal or rejects value. |
validate_connection(source_id, source_port, target_id, target_port, transform=None, *, types=True)
¶
Return a rejection reason without changing graph state, or None if allowed.
With types False the ports' types and the value the edge would carry are not checked, only the wiring rules: ports that exist, a free input, no duplicate and no cycle.
FilterTarget
¶
Bases: Protocol
A component that applies global filters itself, e.g. by pushing them into a query.
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 |
None
|
|
settings_class
|
A subclass of :class: |
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 |
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 |
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: |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The new instance's id, for use with |
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 |
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'
|
sizes
|
Mapping[str, Mapping[str, float]] | None
|
The |
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: |
None
|
adjust_target
|
bool
|
Let the target component adjust its config to the new edge
through its |
False
|
Returns:
| Type | Description |
|---|---|
bool or str
|
|
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. |
required |
type
|
str
|
One of :data: |
'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: |
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 |
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: |
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(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: |
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
|
|
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.
Identity
dataclass
¶
The resolved principal for a session.
groups = field(default_factory=frozenset)
class-attribute
instance-attribute
¶
oauth_user = None
class-attribute
instance-attribute
¶
system_user = None
class-attribute
instance-attribute
¶
user
instance-attribute
¶
user_info = field(default_factory=dict)
class-attribute
instance-attribute
¶
user_names
property
¶
All names this identity may be referenced by in a rule.
in_groups(groups)
¶
Whether the identity belongs to any of groups.
is_user(users)
¶
Whether the identity matches any of users (OAuth or system name).
InputPort
dataclass
¶
Describes a single input port on a component node.
blocking = True
class-attribute
instance-attribute
¶
default = None
class-attribute
instance-attribute
¶
handles_failures = False
class-attribute
instance-attribute
¶
label = None
class-attribute
instance-attribute
¶
multiple = None
class-attribute
instance-attribute
¶
name
instance-attribute
¶
parameter = field(default=None, compare=False, repr=False)
class-attribute
instance-attribute
¶
required = True
class-attribute
instance-attribute
¶
type = None
class-attribute
instance-attribute
¶
check_value(value)
¶
Return why value would be rejected by this input, or None.
JSONFolderAssetStore
¶
Bases: BaseAssetStore
Stores each dashboard as <folder>/<asset_id>.json.
The files are plain, human-readable AssetModel JSON, so a folder can
be reviewed, diffed and versioned alongside the project that serves it, or
shipped read-only with a deployment. Every listing scans the folder, so
files edited or added outside the application show up on the next request;
only files whose size, modification time or inode changed since the last
listing are parsed again. Models returned by listings are shared with that
cache and must not be mutated; load_asset and the other single
dashboard lookups return a private copy.
New dashboards get an id derived from their title (Sales Overview becomes
sales-overview, then sales-overview-2 and so on), which keeps file
names and /asset/<id> URLs readable. A file whose asset_id differs
from its name, or that cannot be parsed, is skipped with one warning.
Writes are atomic, so a reader never sees a half-written file. Several
server processes may share a folder: creating a dashboard claims its id
exclusively, and the other writes hold an advisory lock on the folder
(on Windows on a .flowdash.lock file in it) while they check the file
they replace. Saving
never replaces a file that belongs to another user, and each file stores
a revision that saving checks and increments, so a save based on an
outdated copy raises :class:AssetConflictError. Edit the files by
hand only while no server writes to the folder; a hand edit that keeps
the revision is not detected as a conflict.
A store over several folders, for example a read-only shared folder and
a per-user one, can delegate to one store per folder: :meth:scan lists
a folder's files with their parsed models and :meth:parse_file parses
one file, both skipping unusable files with the warning described above.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
The folder holding the dashboard files. Created if missing unless read_only is set or create is False. |
required |
create
|
bool
|
Create the folder if it is missing. With False the store never
creates it: while it is missing the store lists no dashboards and
writes raise an |
True
|
read_only
|
bool
|
Serve the dashboards without allowing changes. Writes raise
|
False
|
path = Path(path)
instance-attribute
¶
random_ids = False
class-attribute
instance-attribute
¶
read_only = read_only
instance-attribute
¶
append_history(asset_id, record)
¶
can_administer_model(identity, dashboard, admin_groups=frozenset())
¶
can_edit_model(identity, dashboard, admin_groups=frozenset())
¶
create_asset(user_id, title, kind=DASHBOARD_KIND)
¶
delete_asset(user_id, asset_id)
¶
delete_history(asset_id)
¶
load(asset_id)
¶
Load a dashboard by id whoever owns it, or None if it is missing or unusable.
Ids that cannot be file names give None without touching the disk. No access check is applied.
load_history(asset_id)
¶
parse_file(path)
¶
Parse one dashboard file, or return None if it cannot be used.
A file that is malformed, holds another dashboard id than its name or
was left empty by a crashed writer is logged once with its path and
the reason. The model is a private copy, not shared with the cache of
:meth:scan. Raises OSError if the file cannot be read.
Does not check that path is inside the folder: build paths from
:meth:scan, or use :meth:load to look a dashboard up by id.
rename_asset(user_id, asset_id, new_title)
¶
replace_history(asset_id, records)
¶
rewrite_history(asset_id, rewrite)
¶
save_asset(dashboard)
¶
Write dashboard, refusing to replace a file another user owns.
Raises :class:AssetConflictError if the file holds a different
revision than dashboard was loaded at.
scan()
¶
Every usable dashboard file in the folder with its model, most recently updated first.
Only files whose size, modification time or inode changed since the
last scan are parsed again, so the models are shared with that cache
and must not be mutated. Files that cannot be used are left out and
logged as :meth:parse_file describes; a missing or unreadable folder
gives an empty list.
set_owner(asset_id, owner)
¶
set_permission(asset_id, permission)
¶
MemoryAssetStore
¶
Bases: BaseAssetStore
Dict-backed store for notebooks, scripts and tests.
Dashboards live for as long as the store does and are never written to disk. Models are deep-copied in and out so a caller mutating a dashboard it saved (or loaded) cannot retroactively change what is stored, matching how the SQLite store behaves.
append_history(asset_id, record)
¶
delete_asset(user_id, asset_id)
¶
delete_history(asset_id)
¶
load_history(asset_id)
¶
rename_asset(user_id, asset_id, new_title)
¶
replace_history(asset_id, records)
¶
rewrite_history(asset_id, rewrite)
¶
save_asset(dashboard)
¶
set_owner(asset_id, owner)
¶
set_permission(asset_id, permission)
¶
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.
OutputPort
dataclass
¶
PanelAppMetadata
dataclass
¶
Metadata attached to a component or page by the @register decorator.
aliases = field(default_factory=list)
class-attribute
instance-attribute
¶
allow_groups = field(default_factory=list)
class-attribute
instance-attribute
¶
allow_users = field(default_factory=list)
class-attribute
instance-attribute
¶
auth_pending = False
class-attribute
instance-attribute
¶
authorize = None
class-attribute
instance-attribute
¶
check_config = None
class-attribute
instance-attribute
¶
component = False
class-attribute
instance-attribute
¶
config = field(default_factory=list)
class-attribute
instance-attribute
¶
config_choices = None
class-attribute
instance-attribute
¶
config_completions = None
class-attribute
instance-attribute
¶
config_editor = None
class-attribute
instance-attribute
¶
config_schema = None
class-attribute
instance-attribute
¶
contract = None
class-attribute
instance-attribute
¶
default_size = None
class-attribute
instance-attribute
¶
deny_groups = field(default_factory=list)
class-attribute
instance-attribute
¶
deny_users = field(default_factory=list)
class-attribute
instance-attribute
¶
description = None
class-attribute
instance-attribute
¶
extensions = field(default_factory=list)
class-attribute
instance-attribute
¶
framed = None
class-attribute
instance-attribute
¶
handles_failures = field(default_factory=list)
class-attribute
instance-attribute
¶
icon = None
class-attribute
instance-attribute
¶
max_size = None
class-attribute
instance-attribute
¶
min_size = None
class-attribute
instance-attribute
¶
page = True
class-attribute
instance-attribute
¶
palette_presets = None
class-attribute
instance-attribute
¶
permission
property
¶
Build a :class:~panel_flowdash.auth.Permission from the declared rules.
placeholder = None
class-attribute
instance-attribute
¶
port_aliases = field(default_factory=dict)
class-attribute
instance-attribute
¶
presets_pending = False
class-attribute
instance-attribute
¶
provides = field(default_factory=list)
class-attribute
instance-attribute
¶
requires = field(default_factory=list)
class-attribute
instance-attribute
¶
sidebar = False
class-attribute
instance-attribute
¶
singleton = False
class-attribute
instance-attribute
¶
tags = field(default_factory=list)
class-attribute
instance-attribute
¶
title = None
class-attribute
instance-attribute
¶
from_app(app)
classmethod
¶
Extract metadata from an app object.
is_registered(app)
staticmethod
¶
Whether @register attached metadata to app.
ParameterContract
¶
Bases: Protocol
What a component requires of a value bound to a parameter on its config.
Pass one to register(contract=...). Both methods are synchronous and
should not fetch data beyond metadata.
check(context, expects)
¶
Return the problems of the value in context against expects, none when it fits.
expects(context)
¶
Return what the dashboard relies on of the parameter's current value, as JSON data.
None when it cannot tell, e.g. without access to the data; the parameter then keeps what it recorded before.
ParameterError
¶
Permission
dataclass
¶
An allow/deny rule set evaluated against an :class:Identity.
The rule fields match either the resolved user (OAuth login or system
user) or one of the identity's groups. An empty Permission declares
no constraints and defers entirely to the caller's default policy.
allow_edit_users and allow_edit_groups only apply to dashboards:
they grant editing (which includes viewing) on top of the view rules,
without restricting who else may view.
allow_edit_groups = field(default_factory=frozenset)
class-attribute
instance-attribute
¶
allow_edit_users = field(default_factory=frozenset)
class-attribute
instance-attribute
¶
allow_groups = field(default_factory=frozenset)
class-attribute
instance-attribute
¶
allow_users = field(default_factory=frozenset)
class-attribute
instance-attribute
¶
deny_groups = field(default_factory=frozenset)
class-attribute
instance-attribute
¶
deny_users = field(default_factory=frozenset)
class-attribute
instance-attribute
¶
is_empty
property
¶
Whether the permission declares no allow, deny or edit rules.
from_dict(data)
classmethod
¶
Deserialize from a (possibly None or partial) mapping.
from_spec(*, allow_users=None, allow_groups=None, deny_users=None, deny_groups=None, allow_edit_users=None, allow_edit_groups=None)
classmethod
¶
Build a :class:Permission from loosely-typed iterables.
grants_edit(identity)
¶
Whether an edit rule names identity; deny rules are not consulted.
to_dict()
¶
Serialize to sorted lists for JSON persistence.
Predicate
dataclass
¶
Rows whose field lies in a range or is one of a set of values.
op is "range", with values the (start, end) bounds, either
of which may be None, or "in", with values the values to keep.
closed says which bounds of a range are included: "both", or
"left" for start <= x < end.
closed = 'both'
class-attribute
instance-attribute
¶
field
instance-attribute
¶
op
instance-attribute
¶
values
instance-attribute
¶
from_dict(data)
classmethod
¶
Return the predicate :meth:to_dict described.
mask(frame)
¶
Return which rows of frame match.
Bounds and values are made comparable with the column: on a datetime
column dates become midnights, and naive datetimes, which charts
report in UTC, are converted to the column's timezone. A range on an
unordered categorical column raises ValueError.
to_dict()
¶
Return the predicate as a dict JSON can hold.
Dates and datetimes are written in ISO format, and types names
the kind of each value that was one, e.g. [None, "datetime"].
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.
Registration
¶
The decorator :func:register returns, holding the metadata it attaches.
record is the :class:PanelAppMetadata that applying the decorator
attaches to the app, readable before the app exists.
record = record
instance-attribute
¶
RegistryEntry
dataclass
¶
A registered component/page with its metadata.
app = None
class-attribute
instance-attribute
¶
app_id
instance-attribute
¶
load_error = field(default=None, repr=False, compare=False)
class-attribute
instance-attribute
¶
metadata
instance-attribute
¶
module_name
instance-attribute
¶
module_path = None
class-attribute
instance-attribute
¶
name
instance-attribute
¶
page_path
instance-attribute
¶
section
instance-attribute
¶
spec = field(default=None, repr=False, compare=False)
class-attribute
instance-attribute
¶
title
property
¶
Human-readable title.
from_app(app, *, app_id=None, section=None, name=None)
classmethod
¶
Build an entry from an already-imported app object.
Unlike :func:build_registry, which discovers modules on disk and defers
importing them, this wraps a live object so load() is a no-op. Used
by the programmatic API where components are passed in directly.
Objects without @register metadata are treated as components, since
a bare Viewer subclass handed to the editor is only ever meant to be
one.
load()
¶
Import the module and return the app object.
Caches the result on self.app. Raises on import failure.
Selection
dataclass
¶
A plot selection: rows matching every predicate, made on the node source.
A selection with no predicates is empty and selects every row.
Some selections cannot be turned into predicates on fields, and filters
refuse them: index holds rows named by their position in the chart's
data, such as a Vega-Lite point selection without fields, and
unsupported says why another kind of selection cannot filter data,
such as a lasso or a brush on a repeating time unit.
empty
property
¶
Whether the selection keeps every row.
fields
property
¶
The fields the predicates are on, in order.
index = None
class-attribute
instance-attribute
¶
predicates = ()
class-attribute
instance-attribute
¶
source = None
class-attribute
instance-attribute
¶
unsupported = None
class-attribute
instance-attribute
¶
check_filterable()
¶
Raise ValueError if the selection cannot be applied to data as predicates on fields.
filter(frame)
¶
Return the rows of frame matching every predicate; an empty selection keeps them all.
from_dict(data)
classmethod
¶
Return the selection :meth:to_dict described.
to_dict()
¶
Return the selection as a dict of plain values, e.g. to store it.
SelectionLink
¶
Bases: Parameterized
Reports the selection made on a Vega pane or HoloViews stream as value.
Equal selections in a row are reported once. Selections that arrive
while one is being reported, for example while the filters it drives
run their queries, replace each other, and only the newest is reported
next, so at most one is in flight. After a slow report the link waits
half as long, up to COALESCE_MAX milliseconds, before the next, so
a drag's selections collect rather than each running its own report.
debounce = param.Integer(default=DEBOUNCE, bounds=(0, None), doc="\n Milliseconds a Vega pane waits after the last change of a selection\n before sending it, unless the pane's own debounce was set. Bokeh's\n selection tools report on release already.")
class-attribute
instance-attribute
¶
source
property
¶
The node the selection is made on.
value = param.ClassSelector(class_=Selection, default=EMPTY, doc='The latest selection.')
class-attribute
instance-attribute
¶
clear()
¶
Report an empty selection.
link_stream(stream, element=None, *, key=None)
¶
Follow a HoloViews BoundsXY, BoundsX, BoundsY or Selection1D stream.
Replacing a linked pane or stream clears the selection.
link_vega(pane, spec=None)
¶
Follow the selections of pane, replacing what was linked before.
The pane's debounce is set to this link's unless it was set
before. spec defaults to the pane's object. Replacing a linked pane
or stream clears the selection.
push(selection)
¶
Report selection, unless it equals the one reported last.
In a served session it is reported shortly after, together with any that follow it; outside one, at once.
unlink()
¶
Stop following the pane or stream linked last.
SidebarAction
dataclass
¶
An optional create action (e.g. "+ New") shown at the end of a :class:SidebarSection.
Attributes:
| Name | Type | Description |
|---|---|---|
label |
str
|
Text shown for the action, e.g. |
action |
Callable[[SidebarContext], Any] | str
|
Either a callable |
icon |
str
|
Material icon name shown beside the label. Defaults to |
SidebarContext
dataclass
¶
Session context passed to :class:SidebarSection and :class:SidebarAction callables.
Attributes:
| Name | Type | Description |
|---|---|---|
app |
FlowDashApp
|
The session's :class: |
user |
Identity
|
The session's resolved :class: |
section |
SidebarSection
|
The :class: |
app
instance-attribute
¶
is_admin
property
¶
Whether this session administers the project (cached per session).
Use this for showing or hiding UI. Before performing a privileged write
or admin action, re-check with :meth:still_admin.
section
instance-attribute
¶
user
instance-attribute
¶
navigate(url)
¶
Navigate this session to url.
Internal routes open through the app's router; external http:// and
https:// URLs open in a new browser tab.
refresh(section_id=None)
¶
Refresh cached section items; defaults to this section's id.
still_admin()
¶
Whether this session is still an admin, with the project file read again.
SidebarItem
dataclass
¶
One destination listed inside a :class:SidebarSection.
Attributes:
| Name | Type | Description |
|---|---|---|
title |
str
|
Display label shown in the rail menu and narrow-screen drawer. |
url |
str
|
App route (e.g. |
subtitle |
str | None
|
Optional secondary text such as the owner or last updated time. Shown
under the item title in the narrow-screen drawer; desktop rail menus
show titles only ( |
icon |
str | None
|
Optional Material icon name for the item. |
SidebarSection
dataclass
¶
Specification for a navigation section in the FlowDash rail and drawer.
Sidebar sections render only with nav_variant="rail" (the default).
A section may either:
- list destinations via
itemsand/ornew_action(rendered as a menu in the desktop rail and an expanded group in the narrow drawer), - link directly to a landing route via
path(rendered as a single button), or - pass a callable
path(ctx)returning a route string orNoneto switch dynamically between direct-link mode and menu mode (as the built-in Dashboards section does forhome_dashboard).
Setting both route and view lets the section serve its own routes
at /<route> and /<route>/<subpath> through view(ctx, subpath)
without appearing in Pages. When route and view are set without
items, new_action or path, the section links directly to
/<route>.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Unique section identifier (e.g. |
label |
str
|
Heading displayed in the rail button, narrow-screen drawer and breadcrumbs. |
icon |
str
|
Material icon name for the section (e.g. |
items |
Callable[[SidebarContext], Sequence[SidebarItem]] | None
|
Optional callable |
order |
float
|
Sort key controlling section order (ascending). Ties preserve
registration order. The built-in Dashboards section uses |
new_action |
SidebarAction | None
|
Optional :class: |
visible |
Callable[[SidebarContext], bool] | None
|
Optional predicate |
path |
str | Callable[[SidebarContext], str | None] | None
|
Optional landing route (or callable |
route |
str | None
|
Optional URL prefix served by this section, e.g. |
view |
Callable[[SidebarContext, str], Any] | None
|
Optional callable |
icon
instance-attribute
¶
id
instance-attribute
¶
items = None
class-attribute
instance-attribute
¶
label
instance-attribute
¶
new_action = None
class-attribute
instance-attribute
¶
order = 100
class-attribute
instance-attribute
¶
path = None
class-attribute
instance-attribute
¶
route = None
class-attribute
instance-attribute
¶
view = None
class-attribute
instance-attribute
¶
visible = None
class-attribute
instance-attribute
¶
SpecSetting
dataclass
¶
One setting of a spec that a form shows as a control bound to a path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | tuple[str, ...]
|
Where the setting lives in the spec, dotted ( |
required |
label
|
str | None
|
The control's label; defaults to the last key of the path. |
None
|
widget
|
str
|
The control: |
'text'
|
options
|
list[Any] | dict[str, Any] | None
|
The values a select or radio offers, a list or a |
None
|
group
|
str | None
|
The heading the control is listed under. |
None
|
default
|
Any
|
What the spec means when it leaves the path out. The control shows it then, and setting it removes the path. |
None
|
doc
|
str | None
|
A sentence shown as the control's tooltip. |
None
|
choices
|
str | None
|
|
None
|
of
|
str | None
|
|
None
|
get
|
Callable[[dict], Any] | None
|
For a setting that is not one path: |
None
|
set
|
Callable[[dict], Any] | None
|
For a setting that is not one path: |
None
|
covers
|
tuple[str | tuple[str, ...], ...]
|
Further paths the setting controls, e.g. those its |
()
|
enabled
|
Callable[[dict], bool | str] | None
|
|
None
|
restrict
|
bool
|
Whether a select or radio accepts only its options. |
True
|
choices = None
class-attribute
instance-attribute
¶
covers = ()
class-attribute
instance-attribute
¶
default = None
class-attribute
instance-attribute
¶
doc = None
class-attribute
instance-attribute
¶
enabled = field(default=None, compare=False)
class-attribute
instance-attribute
¶
get = field(default=None, compare=False)
class-attribute
instance-attribute
¶
group = None
class-attribute
instance-attribute
¶
key
property
¶
The setting's dotted path, which names it, e.g. in choices.
label = None
class-attribute
instance-attribute
¶
of = None
class-attribute
instance-attribute
¶
options = None
class-attribute
instance-attribute
¶
path
instance-attribute
¶
paths
property
¶
The paths the setting controls.
restrict = True
class-attribute
instance-attribute
¶
set = field(default=None, compare=False)
class-attribute
instance-attribute
¶
title
property
¶
widget = 'text'
class-attribute
instance-attribute
¶
accepts(value)
¶
Whether value fits the control and, for a restricted select or radio, its options.
disabled_reason(spec)
¶
Return why the control cannot be used for spec, or None if it can.
enabled may return a sentence saying why instead of False.
fits(value)
¶
Whether the control can show value without changing it.
A select or radio shows any plain value, one outside its options as an extra option.
is_enabled(spec)
¶
labelled()
¶
Return the options as {label: value}.
read(spec)
¶
Return the setting's value in spec, its default if the spec leaves it out.
write(spec, value)
¶
Return a copy of spec with the setting set to value.
Everything else is kept as it was, in its order. Setting the default removes the path.
Raises:
| Type | Description |
|---|---|
SpecPathError
|
If the path runs through a value that is not an object. |
Suggestion
dataclass
¶
A question the Ask home suggests, with the columns it is about.
Attributes:
| Name | Type | Description |
|---|---|---|
text |
str
|
The question, e.g. |
columns |
tuple[str, ...]
|
The columns the question uses, shown below it, e.g. |
icon |
str | None
|
Material icon name shown beside the question, e.g. |
Transform
¶
Bases: Parameterized
One step of an edge transform.
Subclasses set op to register themselves under that name and implement
:meth:apply. accepts tells the editor which values a step can follow.
label = ''
class-attribute
¶
op = ''
class-attribute
¶
accepts(value)
classmethod
¶
Return whether this step can be applied to value.
apply(value)
¶
Return value transformed by this step.
arguments()
classmethod
¶
Names of the arguments a step of this operation stores.
summary()
¶
Return a few words describing the step, for the label on an edge.
to_dict()
¶
Serialize the step to the dict it is stored as.
Upstream
dataclass
¶
The output a new edge into a component reads, as passed to its on_connect.
A Viewer or Viewable component may define
on_connect(self, port: str, upstream: Upstream) -> dict | None, a
plain (sync) method. FlowDash calls it after a person, a palette drop or
the agent wires a new edge into the input port, and applies the config
changes it returns in the same edit as the connection, so they are saved
and undone with it. Moving an edge onto a new node, as replacing the
upstream node does, counts as connecting it. It is not called when a
saved dashboard loads or an undo restores edges, nor on a component with
no config fields.
component_id
instance-attribute
¶
The upstream node's component id.
node
instance-attribute
¶
The upstream node's name, as in the dashboard YAML.
port
instance-attribute
¶
The upstream output port.
type
instance-attribute
¶
The type of the upstream output port.
value
instance-attribute
¶
The output's current value, before any transform on the edge.
__getattr__(name)
¶
agent_edits(run=None, question=None)
¶
Count the edits made inside the block as the agent's, in the turn of request run.
The dashboard tools wrap each call in it. Tools of your own that change an
editor need it only when they do not run in a panel-agents AgentRunner,
whose tool calls count as the agent's anyway.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run
|
str | None
|
The run id of the agent's request; edits of the same run share a turn. Defaults to the panel-agents run the block executes in. |
None
|
question
|
str | None
|
What the person asked, recorded on the turn when it opens. |
None
|
build_component_spec(entry)
¶
Build a ComponentSpec from a registry entry, caching it on the entry.
A spec is derived purely from the component's class/metadata, so it does not vary between sessions. Registry entries are shared across sessions, which makes the cache process-wide.
build_component_specs(registry, component_ids=None)
¶
Build specs for component-enabled entries in a registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry
|
dict[str, RegistryEntry]
|
Registry entries keyed by component id. |
required |
component_ids
|
Iterable[str] | None
|
Restrict spec building to these ids. Entries outside the set are skipped without being introspected, so an unloaded component costs nothing. |
None
|
build_node_state_class(spec)
¶
Create a Parameterized subclass with one param per port (inputs + outputs).
build_session_state_class(registry)
¶
Build a Parameterized subclass with one param per declared state key.
Scans the registry for all provides and requires keys and creates
a dynamic class whose parameters represent shared session state.
can_administer(identity, owner, admin_groups)
¶
Whether identity may administer a resource owned by owner.
The owner and members of admin_groups may administer a resource; nobody else may. In an auth-less deployment every session resolves to the same system user, which owns every dashboard it creates, so such a deployment stays fully editable without configuring admin groups.
can_edit(permission, identity, owner, admin_groups)
¶
Whether identity may edit the contents of a dashboard owned by owner.
Everyone who may administer it may edit it. Otherwise the identity must
match an allow_edit_users/allow_edit_groups rule and no deny rule.
Editing covers changing and saving the canvas and the dashboard settings,
not renaming, deleting or sharing it, which stay administration.
check_requirements(state, requires)
¶
Check which required keys are unsatisfied on the given state instance.
Returns a list of dicts describing each unsatisfied requirement. An empty list means all requirements are met.
columns_of(value, port_type=None)
¶
Return the (name, type) columns of value, or None if it is not tabular.
The columns reader of port_type is used when one is registered;
otherwise a DataFrame's columns are listed with their dtypes as type names
(integer, number, boolean, datetime, string).
current_dashboard()
¶
Return the editor that is showing the component calling this.
Call it from a component's __init__ or function body. It gives access
to the editor's settings and its refresh event without importing
anything from the application. Later, for example from a callback, it falls
back to the latest editor created in the current session. Outside a session
and outside component creation there is no editor, and it returns None,
as it does for a component that is rendered on its own.
current_node_id()
¶
Return the id of the node whose component is being created, or None.
Call it from a component's __init__ or function body, e.g. to stamp
the values the component outputs with the node they come from. Later,
use :meth:FlowDash.node_id with the component instead.
dashboard_context()
¶
Return a read-only view of the resources the host gave the editor showing this component.
Hosts hand resources to components through FlowDash(context=...) or
by adding to editor.context, e.g. Lumen keeps its source bindings
under editor.context["lumen.sources"]. Call it where
:func:current_dashboard works: while a component is created and while
one of its outputs runs; without an editor the view is empty. The view
follows later additions to the editor's dict, so code that runs in
threads of its own should take the view when the component is created.
from_holoviews(stream, element=None, *, key=None, source=None)
¶
Return the selection a HoloViews stream reports.
BoundsXY, BoundsX and BoundsY give ranges on the element's
first two dimensions; a box on a categorical axis is unsupported, since
its bounds are screen positions rather than values. Selection1D,
which Bokeh's box, lasso and tap tools fill, gives the selected rows'
values of key: by default the element's first key dimension when it is
categorical and its values are unique, such as the categories of
Bars, and the rows' positions otherwise, which filters refuse. A
Lasso stream's polygon cannot be a filter and is unsupported. For a
DynamicMap, the element it shows last is used, and for an
Overlay its layer, if the layers agree on their dimensions. On
Bars and Histogram the y axis is a measure per group, so a
BoundsXY box keeps only its x range and BoundsY is unsupported.
from_vega(value, kind, spec=None, source=None, timezone=None)
¶
Return the selection a Vega pane reports for one selection parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The value of the parameter on |
required |
kind
|
str | None
|
|
required |
spec
|
Any
|
The Vega-Lite spec, whose encodings give each field's type, time unit and bins. |
None
|
source
|
str | None
|
The node the selection is made on. |
None
|
timezone
|
str | None
|
The browser's IANA timezone, in which Vega cuts local time units; UTC when not given. |
None
|
Temporal
|
|
required | |
covers
|
|
required | |
which
|
|
required | |
A
|
|
required | |
whose
|
|
required | |
brushed
|
|
required | |
not
|
|
required |
is_authorized(permission, identity, *, default_allow=True, owner=None)
¶
Evaluate permission against identity.
Order of precedence:
- A matching
deny_users/deny_groupsrule denies access (deny always wins, even for the owner). - The owner, if given and matching, is allowed.
- An identity granted editing (
allow_edit_users/allow_edit_groups) is allowed, since editing includes viewing. - Any
allow_users/allow_groupsrule present: allowed iff the identity matches at least one of them. - No allow/deny rules at all: fall back to default_allow.
link_selection(component, target, *, output='selection', spec=None, element=None, key=None, debounce=DEBOUNCE, link=None, source=None)
¶
Give component a selection output that follows the selections of target.
target is a pn.pane.Vega or a HoloViews stream (with the element
it selects on). The selection is written to the parameter output of
component, which the component declares, e.g.
selection = param.ClassSelector(class_=Selection, default=EMPTY),
and lists in provides with type SELECTION_TYPE. Its source is
the component's node id. Call it from __init__ or __panel__; the
editor unlinks it when the component is removed.
Pass the link returned before when the component replaces its pane, e.g. after its data changed, so the output keeps one link; the new pane starts with nothing selected. Pass source, the node id or a function returning it, when linking outside the component's creation and outside a served session, where the node cannot be looked up.
normalize_components(components, *, unique=False)
¶
Build a registry from any supported component declaration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components
|
Any
|
One of, or a list mixing any of:
|
required |
unique
|
bool
|
Raise a |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
Registry entries keyed by component id. |
normalize_port_type(name)
¶
Return the canonical name of a port type, or None for an untyped port.
Unregistered names normalize to themselves, lowercased, so two ports with the same custom type name still connect.
placement_context()
¶
Return why the component calling this is being created, or None.
Call it from a component's __init__ or function body:
'new': someone added the node, from the palette,add_componentor the agent, so the component may fill in defaults of its own.'load': a dashboard is being opened, imported or replaced, and its saved configuration is what the component should show.'restore': undo, redo or restoring a version brings the node back as it was.
Outside the creation of a FlowDash node it returns None, as it does
from a thread the component starts, so read it before handing work off.
port_type_color(name, *, dark=False)
¶
Return the handle color for name, using dark-mode adjustments when dark is True.
port_types_compatible(source, target)
¶
Return whether an output of type source may connect to an input of type target.
An untyped port, or one typed any (object, a bare Parameter,
a Selector or ClassSelector whose value type the name does not
tell), connects to anything; otherwise the types must be equal or source
a registered subtype of target.
preview_context()
¶
Return who is asking for the preview or definition, from inside a component's hook.
"card", "popout", "inspector" or "code_panel" (see
PreviewCaller) while FlowDash runs __flowdash_preview__ or
__flowdash_definition__ for one of them, None anywhere else, e.g.
when a host or a test calls the hook itself. The agent never calls these
hooks. To decide whether slow work, such as a query, may run, ask
preview_off_loop instead: the same caller may ask on or off the event
loop.
preview_off_loop()
¶
Whether the current code runs on FlowDash's preview worker, off the event loop.
True inside work FlowDash hands to its preview threads (run_off_loop),
where a preview or definition hook may block for a short query without
freezing the session; False on the event loop and anywhere else.
register(*, page=True, component=False, sidebar=False, title=None, icon=None, description=None, tags=None, extensions=None, default_size=None, min_size=None, max_size=None, framed=None, singleton=False, provides=None, requires=None, placeholder=None, config_schema=None, config=None, config_editor=None, check_config=None, contract=None, config_choices=None, config_completions=None, palette_presets=None, handles_failures=None, aliases=None, port_aliases=None, allow_users=None, allow_groups=None, deny_users=None, deny_groups=None, authorize=None)
¶
Metadata-only decorator for app exports.
Annotates an app object/callable without altering runtime behavior.
The config_schema, config and config_editor arguments declare
design-time configuration options that appear in the node editor. Use
config_schema (a param.Parameterized subclass, a Pydantic model, or
a JSON Schema dict) to define config explicitly, or config to name which
of a Viewer's own params are configuration rather than input ports. Pass
config_editor to supply a custom editor callable instead of the
auto-generated form.
The check_config argument takes a callable, sync or async, that checks
a node's config before it is applied: check(config, inputs) gets the
node's whole config with the change applied and its input values that are
set and not failed ({} before the node is placed). It returns None,
a string or an iterable of strings, each non-empty string a problem, or
raises ValueError with the problem as its message. A
:class:~panel_flowdash.CheckWarning in place of a string is a warning,
shown with the config but not refusing it. Any other result or exception,
or taking longer than 10 seconds, counts as a failed check. The check runs
again when an input of the node is connected or disconnected.
A sync check runs in a worker thread and must not change the editor. A
config with problems is refused in the inspector and by the agent tools,
and reported by validation and previews.
The contract argument takes a
:class:~panel_flowdash.ParameterContract: what the dashboard needs of
a value bound to a parameter on one of the component's config fields,
e.g. the columns its downstream nodes read from a data source. Its
expects(context) writes the parameter's expects and its
check(context, expects) runs whenever the parameter is rebound,
see :mod:panel_flowdash.parameters.
The config_choices argument takes a callable, sync or async, called
like check_config as choices(config, inputs), that returns the
values each config field may take: {field: choices}, where choices are
a list of values, a {label: value} dict or a
:class:~panel_flowdash.Choices. The inspector offers them in a dropdown,
or as suggestions with Choices(restrict=False), and asks again when
the node's inputs or config change. Choices under the name of an input
are offered for the value that input takes while it is not connected. A
config param may also declare that
it names a column of an input, with
metadata={"flowdash": {"choices": "columns", "of": "<input>"}}.
The config_completions argument takes a callable, sync or async,
called like config_choices, that returns the words the code editor
of a code field completes while typing: {field: words}, where words
are a list, a {label: word} dict or a
:class:~panel_flowdash.Choices whose types are shown beside each
word, e.g. the columns of the tables a query reads. Without it a code
field completes the column names of the node's tabular inputs.
The palette_presets argument takes a callable, called with the
editor's context, that returns further entries the component
palette and the command palette offer for the component, each placing
it with a config filled in: dicts with a title and a config, and
optionally a description, a tooltip, tags and an icon,
e.g. one entry per data source the host provides. It is asked again
when the editor's context changes, not on every search; an entry without
a title or config, or whose config is not JSON-serializable, is
skipped, and a failing callable offers none. An entry's optional id
identifies it in the command palette; without one, its title and config
do. Components found by scanning a project directory offer their presets
once imported, which the app does when a dashboard is edited.
The placeholder argument sets the message a dashboard tile shows while a
blocking input of the component is unset, in place of the default
"Waiting for
The handles_failures argument names the inputs that can receive a
failure. With FlowDash(propagate_failures=True) an upstream failure
reaches such an input as a param.ReactiveError instead of leaving the
input on its last value; the parameter behind it must accept one, so use an
untyped param.Parameter.
The aliases argument lists ids the component was registered under
before (e.g. ["Old/section_name"]) and port_aliases maps former
port or config names to current ones (e.g. {"ticker": "symbol"}), so a
saved dashboard that references the old names still loads after a rename.
The framed argument says whether the component's dashboard tile is
drawn as a framed card: False for components that are layout chrome
themselves, e.g. a divider or a section heading, True for ones that
need a frame, and None (the default) to follow the dashboard's "Frame
tiles" setting. A tile's own frame option, set in the Layout tab, takes
precedence over it.
The extensions argument names the Panel extensions (e.g.
["tabulator"]) the app's output needs. Components are imported lazily,
after the page has loaded its JavaScript, so an editor loads every declared
extension up front; an undeclared one fails to render in the browser.
The allow_users, allow_groups, deny_users and deny_groups
arguments declare page-level authorization rules. Users are matched against
either the OAuth login or the system user; groups against the identity's
resolved group membership. Deny rules always win; when only allow rules are
present the identity must match at least one; with no rules the project's
default policy applies. Pass authorize for a custom callable taking the
resolved Identity and returning a bool (resolved on import).
The returned decorator exposes the metadata as its record before it is
applied, so a factory that builds the class can read the registered title
and the rest of the declaration while it builds it::
registration = register(component=True, title=spec["title"])
if not spec.get("columns"):
raise ValueError(f"{registration.record.title}: declares no columns.")
return registration(type(name, (Viewer,), namespace))
Arguments register refuses, and a component class it refuses, are
named by their title when one is given rather than by the Python name.
register_node_action(action)
¶
Offer action in the node menus of every editor, replacing one of the same key.
register_port_type(name, *, aliases=(), subtype_of=(), columns=None, color=None)
¶
Register a port type, its alternative spellings and the types it can feed.
Registering a name again adds to its aliases and supertypes. Aliases and supertypes may be spelled any way that normalizes to a registered type; an unknown supertype is registered on the fly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Canonical name of the type, e.g. |
required |
aliases
|
Iterable[str]
|
Other spellings of the same type, e.g. |
()
|
subtype_of
|
Iterable[str]
|
Types an output of this type may connect to, e.g. |
()
|
columns
|
Callable | None
|
For a tabular type that is not a DataFrame, e.g. a lazy query, a
callable that lists the columns of a value without fetching rows:
|
None
|
color
|
str | None
|
Optional CSS color used for canvas handles of this port type. Subtypes inherit it unless they register their own. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The canonical name ports of this type normalize to. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an alias already names a different type, or the rule would make
|
request_filters(component)
¶
Have the dashboards showing component read its columns again and hand it its filters anew.
A :class:FilterTarget calls this when __flowdash_columns__ would
now answer differently, e.g. once a query arriving at one of its inputs
has run. Returns whether a dashboard shows component.
resolve_identity(auth_config=None)
¶
Resolve the current session's :class:Identity.
Prefers the OAuth login (pn.state.user) when a real provider populated
it; otherwise falls back to the system user, then to "anonymous". The
system user is only part of the identity when there is no OAuth login, so a
signed-in user never inherits the server account's dashboards or groups.
Groups are the union of claim-derived groups, the static user_groups
entry for the resolved user and any dynamic resolve_groups callback.
unregister_node_action(key)
¶
Stop offering the action registered under key.