editor¶
panel_flowdash.editor
¶
The embeddable dataflow editor.
:class:FlowDash is the reusable half of the framework: a ReactFlow wiring
canvas plus a tile-grid layout editor over a set of components. It knows nothing
about routing, pages, navigation or identity, so it can be dropped into any Panel
app, notebook or template. :class:~panel_flowdash.app.FlowDashApp builds the
full multi-page application on top of it.
ABOVE_SHEET_CLASS = 'fd-above-sheet'
module-attribute
¶
ASK_MAX_RATIO = 0.5
module-attribute
¶
ASK_MIN_WIDTH = 320
module-attribute
¶
ASK_WIDTH = 480
module-attribute
¶
BEHIND_SHEET_CLASS = 'fd-behind-sheet'
module-attribute
¶
BUILTIN_COMPONENTS = {'Widgets/Select': Select, 'Widgets/MultiChoice': MultiChoice, 'Widgets/RadioGroup': RadioGroup, 'Widgets/Slider': Slider, 'Widgets/RangeSlider': RangeSlider, 'Widgets/NumberInput': NumberInput, 'Widgets/DateRange': DateRange, 'Widgets/Toggle': Toggle, 'Widgets/TextInput': TextInput, 'Widgets/KPI': KPI, 'Widgets/Image': Image, 'Data/FilterBySelection': SelectionFilter, **TEXT_COMPONENTS}
module-attribute
¶
BURST_SECONDS = 3.0
module-attribute
¶
CARD_WIDTH = 260
module-attribute
¶
CHART_COLOR = '#2a9d8f'
module-attribute
¶
CHAT_KIND = 'chat'
module-attribute
¶
DASHBOARD_FILE_EXTENSIONS = ('.json', '.yaml', '.yml')
module-attribute
¶
DEFINITION_HOOK = '__flowdash_definition__'
module-attribute
¶
FILL_HEIGHT = 360
module-attribute
¶
GRID_DRAG_CSS = '\n.tile-grid:has(.muuri-grid:not(.muuri-no-handles)),\n.muuri-grid:not(.muuri-no-handles) {\n -webkit-user-select: none;\n user-select: none;\n}\n.muuri-grid:not(.muuri-no-handles) .muuri-grid-item > div:not(.muuri-handle) > * {\n -webkit-user-select: text;\n user-select: text;\n}\n.muuri-handle, .muuri-resize-ghost,\n.muuri-item-dragging, .muuri-item-dragging *,\n.muuri-item-releasing, .muuri-item-releasing * {\n -webkit-user-select: none !important;\n user-select: none !important;\n}\n'
module-attribute
¶
GRID_EDIT_CSS = '\n:host {\n --tile-padding: 0px;\n}\n.muuri-grid:not(.muuri-no-handles) .muuri-grid-item {\n outline: 1px dashed var(--mui-palette-divider, rgba(127, 127, 127, 0.5));\n outline-offset: 2px;\n}\n.muuri-grid:not(.muuri-no-handles) .muuri-grid-item:hover {\n outline: 2px solid var(--mui-palette-primary-main, #0072b5);\n}\n.muuri-handle { opacity: 0.7 !important; }\n.muuri-grid-item:hover .muuri-handle, .muuri-handle:focus { opacity: 1 !important; }\n.muuri-handle.drag {\n top: 4px;\n left: calc(50% - 18px);\n width: 36px;\n height: 16px;\n padding: 2px 9px;\n box-sizing: border-box;\n border-radius: 8px;\n -webkit-mask-image: none;\n mask-image: none;\n color: var(--mui-palette-text-secondary, rgba(0, 0, 0, 0.6));\n background: radial-gradient(circle, currentColor 1.2px, transparent 1.6px) center / 6px 6px\n repeat content-box,\n var(--mui-palette-action-selected, rgba(127, 127, 127, 0.16));\n}\n.muuri-handle.resize {\n width: 18px;\n height: 18px;\n bottom: 2px;\n right: 2px;\n background-color: var(--mui-palette-primary-main, #0072b5);\n}\n.muuri-grid:not(.muuri-no-handles) .muuri-grid-item.muuri-selected {\n outline: 2px solid var(--mui-palette-primary-main, #0072b5);\n outline-offset: 5px;\n}\n:host(.fd-unframed-band) .muuri-grid.muuri-constrained { box-shadow: none; }\n:host(.fd-split-preview) .muuri-handle { display: none !important; }\n:host(.fd-split-preview) .muuri-grid .muuri-grid-item:not(:hover):not(.muuri-selected) { outline: none; }\n'
module-attribute
¶
GROUP_HEADER_HEIGHT = 32
module-attribute
¶
GROUP_PORT_ROW_HEIGHT = 22
module-attribute
¶
HEADER_HEIGHT = 48
module-attribute
¶
HISTORY_MAX_BYTES = 16 * 2 ** 20
module-attribute
¶
INSPECTOR_SHEET_HEIGHT = '55dvh'
module-attribute
¶
INSPECTOR_SHEET_TALL_HEIGHT = '85dvh'
module-attribute
¶
MAX_LABEL_LENGTH = 200
module-attribute
¶
MAX_NAME_LENGTH = 64
module-attribute
¶
PHONE_BREAKPOINT = 600
module-attribute
¶
PLACEHOLDER_NODE_TYPE = 'flowdash:placeholder'
module-attribute
¶
PREVIEW_KIND_KEY = '__flowdash_preview_kind__'
module-attribute
¶
PROVENANCE_HOOK = '__flowdash_provenance__'
module-attribute
¶
PlacementReason = t.Literal['new', 'load', 'restore']
module-attribute
¶
REPORT_KIND = 'report'
module-attribute
¶
RESTRICTED_COMPONENT_ID = 'flowdash:restricted'
module-attribute
¶
SURFACES = ('workspace', 'explore', 'report')
module-attribute
¶
TEXT_COMPONENTS = {'Text/Markdown': Markdown, 'Text/Notes': Notes, 'Text/Heading': Heading, 'Text/Divider': Divider}
module-attribute
¶
TILE_KEY_PREFIX = 'flowdash-tile-key-'
module-attribute
¶
TURNED_OFF = 'turned off by an admin'
module-attribute
¶
_CANVAS_MIN_HEIGHT = 600
module-attribute
¶
_CANVAS_MIN_HEIGHT_DOCKED = 160
module-attribute
¶
_CANVAS_MIN_WIDTH = 160
module-attribute
¶
_CANVAS_MIN_ZOOM = 0.2
module-attribute
¶
_CODE_PANEL_HEIGHT = 400
module-attribute
¶
_CODE_PANEL_MIN_WIDTH = 960
module-attribute
¶
_COLLAPSED_GROUP_WIDTH = 260
module-attribute
¶
_DROP_WIRE_OFFSET = 360
module-attribute
¶
_EMPTY_GRID_CONFIG = {'breakpoints': [], 'responsive_layouts': {}, 'reference_width': None}
module-attribute
¶
_FAILED_EDGE_STYLE = {'stroke': 'var(--panel-danger-color, #d32f2f)', 'strokeWidth': 2}
module-attribute
¶
_FAILED_NODE_STYLE = {'borderColor': 'var(--panel-danger-color, #d32f2f)', 'boxShadow': '0 0 0 1px var(--panel-danger-color, #d32f2f)'}
module-attribute
¶
_FILES_DROP_TYPE = 'Files'
module-attribute
¶
_FIT_MAX_ZOOM = 1
module-attribute
¶
_FLOW_PHONE_CSS = f'@media (max-width: {PHONE_BREAKPOINT - 0.05}px) {{ .react-flow__controls-button {{ width: 44px; height: 44px; }} }}'
module-attribute
¶
_FLOW_STYLESHEET = '/* A press on the empty canvas or its panels starts no text selection. */\n.react-flow__pane, .react-flow__panel, .react-flow__background {\n -webkit-user-select: none;\n user-select: none;\n}\n/* The canvas shares its height with the code panel docked under it. */\n:host(.fd-docked) .react-flow { min-height: 0 !important; height: 100% !important; }\n/* React Flow\'s own dark palette draws edges at #3e3e3e on #141414, close to invisible. */\n.react-flow.dark {\n --xy-edge-stroke: var(--mui-palette-text-disabled, #8a8a8a);\n --xy-edge-stroke-selected: var(--mui-palette-text-secondary, #b1b1b1);\n --xy-connectionline-stroke: var(--mui-palette-text-secondary, #b1b1b1);\n}\n.react-flow.dark .react-flow__attribution {\n background: var(--mui-palette-background-paper, var(--panel-background-color));\n border-top-left-radius: 4px;\n}\n.react-flow.dark .react-flow__attribution a {\n color: var(--mui-palette-text-secondary, #999);\n}\n.react-flow__node {\n padding: 0;\n border-radius: 10px;\n border: 1px solid var(--mui-palette-divider, var(--panel-border-color));\n background-color: var(--mui-palette-background-paper, var(--panel-background-color));\n box-shadow: 0 1px 2px var(--panel-shadow-color);\n color: var(--mui-palette-text-primary, var(--panel-on-background-color));\n font-size: 13px;\n min-width: 140px;\n}\n/* Selection is an offset dashed ring, so it reads apart from the solid agent and failure\n outlines that sit on the border and can show at the same time. React Flow removes the\n outline of a focused node, which a clicked node is, so this needs its specificity. */\n.react-flow__node.selected,\n.react-flow__node.selectable.selected:is(:focus, :focus-visible) {\n outline: 2px dashed var(--mui-palette-primary-main, var(--panel-primary-color));\n outline-offset: 3px;\n}\n/* A node reached with the keyboard but not selected gets a quieter solid ring. */\n.react-flow__node.selectable:focus-visible:not(.selected) {\n outline: 2px solid var(--mui-palette-text-secondary, currentColor);\n outline-offset: 3px;\n}\n.react-flow.dark .react-flow__node.selected,\n.react-flow.dark .react-flow__node.selectable.selected:is(:focus, :focus-visible) {\n outline-color: var(--mui-palette-primary-light, var(--mui-palette-primary-main));\n}\n/* Nodes show a compact card (see ui/node_card.py) that fills the node, so the\n card\'s port labels line up with the handles ReactFlow spreads over its height. */\n.rf-node-content {\n padding: 0;\n}\n.rf-node-label {\n display: none;\n}\n/* The card has no controls, so pointer events reach the node to select and drag it. */\n.rf-node-view-wrapper,\n.rf-node-view-wrapper * {\n pointer-events: none;\n}\n.react-flow__handle {\n width: 10px;\n height: 10px;\n border: 2px solid var(--fd-hc, var(--mui-palette-primary-main, var(--panel-primary-color)));\n background: var(--mui-palette-background-paper, var(--panel-background-color));\n}\n.react-flow.dark .react-flow__handle {\n border-color: var(--fd-hc-dark, var(--fd-hc, var(--mui-palette-primary-main, var(--panel-primary-color))));\n}\n.react-flow__handle-right {\n background: var(--fd-hc, var(--mui-palette-primary-main, var(--panel-primary-color)));\n}\n.react-flow.dark .react-flow__handle-right {\n background: var(--fd-hc-dark, var(--fd-hc, var(--mui-palette-primary-main, var(--panel-primary-color))));\n}\n.react-flow__handle.fd-handle-optional {\n border-style: dashed;\n}\n.react-flow__handle.fd-handle-missing {\n border-color: var(--mui-palette-error-main, #d32f2f) !important;\n box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.22);\n}\n.react-flow.dark .react-flow__handle.fd-handle-missing {\n border-color: var(--mui-palette-error-main, #ef5350) !important;\n box-shadow: 0 0 0 3px rgba(239, 83, 80, 0.28);\n}\n.react-flow__handle.fd-handle-hidden {\n opacity: 0;\n pointer-events: none;\n}\n/* The popups stay on the canvas, never over the panels beside it. */\n:host {\n overflow: hidden;\n}\n.rf-value-popup:has(.fd-popup-leftward) {\n transform: translateX(-100%);\n}\n.react-flow__edge-textbg {\n fill: var(--mui-palette-background-paper, var(--panel-background-color, #fff));\n stroke: var(--mui-palette-primary-main, var(--panel-primary-color, #0072b5));\n stroke-width: 1px;\n rx: 9px;\n ry: 9px;\n}\n.react-flow__edge-text {\n fill: var(--mui-palette-text-primary, var(--panel-on-background-color, #222));\n font-size: 12px;\n font-weight: 500;\n}\n/* A failed edge\'s transform chip is filled in the error colour, so it reads as an issue. */\n.react-flow__edge:has(.react-flow__edge-path[style*="danger"]) .react-flow__edge-textbg {\n fill: var(--mui-palette-error-main, #d32f2f);\n stroke: none;\n}\n.react-flow__edge:has(.react-flow__edge-path[style*="danger"]) .react-flow__edge-text {\n fill: var(--mui-palette-error-contrastText, #fff);\n}/* A collapsed group shows each port\'s label and type beside its handle, as\n node cards do, rather than only in the handle\'s tooltip. */\n.rf-group--collapsed {\n min-width: 260px;\n}\n.fd-group-rows-1 > .rf-group--collapsed { min-height: 66px !important; }\n.fd-group-rows-2 > .rf-group--collapsed { min-height: 88px !important; }\n.fd-group-rows-3 > .rf-group--collapsed { min-height: 110px !important; }\n.fd-group-rows-4 > .rf-group--collapsed { min-height: 132px !important; }\n.fd-group-rows-5 > .rf-group--collapsed { min-height: 154px !important; }\n.fd-group-rows-6 > .rf-group--collapsed { min-height: 176px !important; }\n.fd-group-rows-7 > .rf-group--collapsed { min-height: 198px !important; }\n.fd-group-rows-8 > .rf-group--collapsed { min-height: 220px !important; }\n.fd-group-rows-9 > .rf-group--collapsed { min-height: 242px !important; }\n.fd-group-rows-10 > .rf-group--collapsed { min-height: 264px !important; }\n.fd-group-rows-11 > .rf-group--collapsed { min-height: 286px !important; }\n.fd-group-rows-12 > .rf-group--collapsed { min-height: 308px !important; }\n.rf-group--collapsed > .react-flow__handle[data-tooltip]::after {\n opacity: 1;\n background: none;\n padding: 0;\n color: var(--mui-palette-text-secondary, var(--panel-on-background-color));\n font-size: 12px;\n max-width: 180px;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.rf-group--collapsed > .react-flow__handle-left[data-tooltip]::after {\n left: calc(100% + 6px);\n right: auto;\n}\n.rf-group--collapsed > .react-flow__handle-right[data-tooltip]::after {\n right: calc(100% + 6px);\n left: auto;\n}\n'
module-attribute
¶
_GRAPH_FIELDS = ('items', 'edges', 'turns', 'groups', 'tile_layout', 'responsive_layouts')
module-attribute
¶
_GROUP_PADDING = 24
module-attribute
¶
_HEIGHT_SIZING = ('stretch_both', 'stretch_height', 'scale_both', 'scale_height')
module-attribute
¶
_IDENTITY_FIELDS = ('asset_id', 'user_id', 'permission', 'revision')
module-attribute
¶
_INSTANTIATING = contextvars.ContextVar('panel_flowdash_instantiating', default=None)
module-attribute
¶
_INSTANTIATING_NODE = contextvars.ContextVar('panel_flowdash_instantiating_node', default=None)
module-attribute
¶
_MISSING = object()
module-attribute
¶
_NODE_DEFAULTS = {'type': 'panel', 'data': {}, 'position': {'x': 0.0, 'y': 0.0}, 'selected': False, 'draggable': True, 'connectable': True, 'deletable': True}
module-attribute
¶
_PALETTE_DRAG_TYPE = 'application/x-flowdash-component'
module-attribute
¶
_PHONE_REVEAL_TOP = 24
module-attribute
¶
_PHONE_REVEAL_ZOOM = 0.75
module-attribute
¶
_PLACEMENT = contextvars.ContextVar('panel_flowdash_placement', default=None)
module-attribute
¶
_PLACEMENT_CASCADE = 40
module-attribute
¶
_PLACEMENT_MARGIN = 40
module-attribute
¶
_PLACING = contextvars.ContextVar('panel_flowdash_placing', default=None)
module-attribute
¶
_POPOUT_MIN_WIDTH = 560
module-attribute
¶
_POPOUT_TABLE_CSS = '\n.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title-holder {\n display: flex;\n align-items: center;\n gap: 4px;\n}\n.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-sorter {\n position: static !important;\n margin-left: auto;\n}\n.tabulator .tabulator-tableholder {\n overflow: auto !important;\n scrollbar-width: thin;\n scrollbar-gutter: stable;\n}\n'
module-attribute
¶
_PROVENANCE_DEPTH = 64
module-attribute
¶
_REPR_CSS = '\npre {\n margin: 0;\n max-height: 320px;\n overflow: auto;\n font-size: 11.5px;\n line-height: 1.45;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n color: var(--mui-palette-text-secondary, inherit);\n}\n'
module-attribute
¶
_SESSION_EDITORS = weakref.WeakKeyDictionary()
module-attribute
¶
_SIDE_PANEL_CLASS = 'fd-side-panel'
module-attribute
¶
_SIDE_PANEL_WIDTH = 250
module-attribute
¶
_SPLIT_PREVIEW = 'fd-split-preview'
module-attribute
¶
_TILE_DROP_WAIT = 3.0
module-attribute
¶
_TILE_OPTIONS = ('framed', 'area')
module-attribute
¶
_TRANSFORMED_EDGE_STYLE = {'stroke': 'var(--panel-primary-color, #0072b5)', 'strokeDasharray': '6 3', 'strokeWidth': 2}
module-attribute
¶
_UNFRAMED_BAND = 'fd-unframed-band'
module-attribute
¶
accepts_dashboard_id = accepts_old_keyword('dashboard_id', 'asset_id')
module-attribute
¶
logger = logging.getLogger('panel_flowdash')
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.
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.
CardBridge
¶
Bases: JSComponent
Relays clicks on the actions inside card HTML and styles each card's handles.
Handle positions are not set here: they are CSS variables in each node's style, so React Flow re-measures the handles when they move.
CodePanel
¶
Bases: Viewer
Edits the spec of one node beside the node's result, applying the draft on Run.
can_dock_bottom = param.Boolean(default=True, doc='Whether the window is wide enough to offer moving the panel under the canvas.')
class-attribute
instance-attribute
¶
close_button = pmui.IconButton(icon='close', description='Close the code panel', size='small', margin=(0, 8, 0, 2), align='center', css_classes=['fd-code-close'])
instance-attribute
¶
code = CodeEditor(value='', value_input='', language='text', on_keyup=False, keyboard_accessible=True, soft_wrap=True, sizing_mode='stretch_both', min_height=80, margin=0, css_classes=[_EDITOR_CLASS], stylesheets=[ACE_THEME_CSS])
instance-attribute
¶
collapse_button = pmui.IconButton(icon='expand_more', description='Collapse the code panel', size='small', margin=(0, 2), align='center', css_classes=['fd-code-collapse'])
instance-attribute
¶
collapsed = param.Boolean(default=False, doc='Whether only the header is shown.')
class-attribute
instance-attribute
¶
definition = CodeEditor(value='', language='text', readonly=True, sizing_mode='stretch_both', min_height=80, margin=0, visible=False, css_classes=['fd-code-definition'], stylesheets=[ACE_THEME_CSS])
instance-attribute
¶
dirty = param.Boolean(default=False, doc="Whether the draft differs from the node's config.")
class-attribute
instance-attribute
¶
discard_button = pmui.IconButton(icon='undo', description='Discard the draft', size='small', margin=(0, 2), align='center', visible=False, css_classes=['fd-code-discard'])
instance-attribute
¶
discard_stale_button = pmui.Button(label='Discard', variant='text', size='small', margin=(0, 4, 4, 0), sx={'textTransform': 'none'}, css_classes=['fd-code-discard-stale'])
instance-attribute
¶
dock = param.Selector(default='bottom', objects=['bottom', 'sidecar'], doc="\n Where the panel is shown: under the canvas, or in the sidecar's Spec\n tab, where its code and result are stacked.")
class-attribute
instance-attribute
¶
dock_button = pmui.IconButton(icon='view_sidebar', description='Open in sidecar', size='small', margin=(0, 2), align='center', css_classes=['fd-code-dock-toggle'])
instance-attribute
¶
editor = param.Parameter(doc='The FlowDash editor holding the node.')
class-attribute
instance-attribute
¶
expand_button = pmui.IconButton(icon='expand_less', description='Expand the code panel', size='small', margin=(0, 2), align='center', visible=False, css_classes=['fd-code-expand-panel'])
instance-attribute
¶
field = param.String(default=None, allow_None=True, doc='The spec field edited, a code field or a spec dict; None for a node without one.')
class-attribute
instance-attribute
¶
field_toggle = pmui.RadioButtonGroup(options={}, size='small', margin=(0, 12, 0, 0), align='center', visible=False, styles={'min-width': '0', 'overflow-x': 'auto', 'flex': '0 1 auto'}, sx={'flexWrap': 'nowrap', '& .MuiToggleButton-root': {'py': '1px', 'px': '10px', 'fontSize': '0.75rem', 'lineHeight': '20px', 'textTransform': 'none', 'whiteSpace': 'nowrap'}}, css_classes=['fd-code-field-switch'])
instance-attribute
¶
fix_json_button = pmui.Button(label='Fix in YAML', variant='text', size='small', margin=(0, 12, 4, 12), sx={'textTransform': 'none'}, css_classes=['fd-code-fix-json'])
instance-attribute
¶
format_button = pmui.Button(label='Format', icon='format_align_left', variant='text', size='small', margin=(0, 8, 0, 0), align='center', visible=False, description=f'Format the code ({FORMAT_SHORTCUT})', sx={'textTransform': 'none', 'py': '1px', 'fontSize': '0.75rem'}, css_classes=['fd-code-format'])
instance-attribute
¶
has_drafts
property
¶
Whether an edit typed in the panel has not been run, shown or held for later.
instance_id = param.String(default=None, allow_None=True, doc='The node shown.')
class-attribute
instance-attribute
¶
keep_draft_button = pmui.Button(label='Keep draft', variant='text', size='small', margin=(0, 4, 4, 12), sx={'textTransform': 'none'}, css_classes=['fd-code-keep-draft'])
instance-attribute
¶
on_close = param.Callable(default=None, doc="Called when the panel's close button is pressed.")
class-attribute
instance-attribute
¶
outputs = pmui.RadioButtonGroup(options=[], size='small', margin=(0, 12, 0, 0), align='center', sx={'& .MuiToggleButton-root': {'py': '1px', 'px': '10px', 'fontSize': '0.75rem', 'lineHeight': '20px', 'textTransform': 'none'}}, css_classes=['fd-code-outputs'])
instance-attribute
¶
run_button = pmui.Button(label='Run', icon='play_arrow', variant='contained', size='small', margin=(0, 4), align='center', description='Run the draft (Ctrl+Enter)', css_classes=['fd-code-run'], sx={'textTransform': 'none'})
instance-attribute
¶
run_on_change = param.Boolean(default=False, doc='\n Whether an edit runs the draft without pressing Run, for the field\n shown. It starts on for a spec and off for code, see\n :data:`RUN_ON_CHANGE`, and is remembered for each while the panel lives.')
class-attribute
instance-attribute
¶
run_switch = pmui.Switch(label='Run on change', value=self.param.run_on_change, margin=(0, 8), size='small', align='center', stylesheets=['.MuiFormControlLabel-label { font-size: 0.8125rem; white-space: nowrap; }'], css_classes=['fd-code-run-on-change'])
instance-attribute
¶
running = param.Boolean(default=False, doc='Whether a run of the draft is in flight.')
class-attribute
instance-attribute
¶
spec_editor = SpecEditor(mode='form', syntax=self.spec_text, margin=0)
instance-attribute
¶
spec_text = param.Selector(default='yaml', objects=list(TEXT_VIEWS.values()), doc="The syntax of a spec's text, the one last picked; a spec without a form shows it.")
class-attribute
instance-attribute
¶
spec_tools = AceTools(target_class=_SPEC_TEXT_CLASS, on_run=self.run, on_format=self.format, scroll_margin=8, margin=0, align='center')
instance-attribute
¶
spec_view = param.Selector(default='form', objects=list(SPEC_VIEWS.values()), doc='The view of a spec: its form, or its text as YAML or JSON.')
class-attribute
instance-attribute
¶
stale = param.Selector(default=None, objects=[None, 'draft', 'running'], doc='\n Whether the result shown does not match the draft: a ``"draft"`` not\n run, or ``"running"``.')
class-attribute
instance-attribute
¶
stale_run_button = pmui.Button(label='Run', icon='play_arrow', variant='text', size='small', margin=(0, 4, 0, 0), align='center', description='Run the draft (Ctrl+Enter)', sx={'textTransform': 'none', 'py': '1px', 'fontSize': '0.75rem'}, css_classes=['fd-code-stale-run'])
instance-attribute
¶
tools = AceTools(target_class=_EDITOR_CLASS, on_run=self.run, on_format=self.format, scroll_margin=8, margin=0, align='center')
instance-attribute
¶
view_toggle = pmui.RadioButtonGroup(options=SPEC_VIEWS, value=self.spec_view, size='small', margin=(0, 12, 0, 0), align='center', sx={'& .MuiToggleButton-root': {'py': '1px', 'px': '10px', 'fontSize': '0.75rem', 'lineHeight': '20px', 'textTransform': 'none'}}, css_classes=['fd-code-spec-view'])
instance-attribute
¶
can_edit(instance_id, field=None)
¶
Whether the panel can show the node instance_id, editing its spec field field.
Without a field it shows the node's result only.
discard()
¶
Put the node's spec back in the editor, dropping the draft.
discard_stale_draft()
¶
Drop the held draft written against an older version of the field.
drafted_fields(instance_id)
¶
Return the spec fields of the node instance_id holding an edit that was not run.
drop_all_drafts()
¶
Forget every draft, the one shown included.
drop_drafts(instance_id)
¶
Forget the drafts held for the node instance_id, e.g. once it is removed.
format(text=None)
¶
Lay out the text in the editor, as an edit of the draft that Ctrl+Z undoes.
text is the editor's text as sent with Shift+Alt+F, which may be ahead of what the server has. Text that does not parse is left as it is, with the problem said under it.
keep_stale_draft()
¶
Show the held draft written against an older version of the field.
open(instance_id, field=None, focus=True)
¶
Show the node instance_id, editing its spec field field, keeping the draft if it is already shown.
Another node's draft not run yet is held until it is shown again. With focus, as when asked for rather than following the selection, a collapsed panel expands and the editor takes the keyboard.
release()
¶
Stop following the node shown, e.g. before closing the panel, holding an unrun draft.
run(text=None)
¶
Apply the draft to the node, after its check passes if the component has one.
text is the editor's text as sent with Ctrl+Enter, which may be ahead of what the server has. Spec text that is not a valid spec is not run; the problem is shown under it.
stale_states()
¶
Return the nodes whose result does not match their spec: "draft" or "running".
A node has a draft not run while it is shown with one, or holds one for later.
toggle_dock()
¶
Move the panel into the sidecar's Spec tab, or back under the canvas.
ComponentPalette
¶
Bases: Viewer
Search field, grouped component list and usage hint.
header_end is shown above the search field, except in the touch layout.
menu is the MenuList the canvas accepts drops from. Its items come
from the items callable, which reads query and is called again
whenever the query changes or :meth:refresh is called.
menu = pmui.MenuList(draggable=True, drag_type=drag_type, highlight=False, level_indent=0, sizing_mode='stretch_width', margin=0, styles={'max-height': 'none'}, sx=_PALETTE_SX)
instance-attribute
¶
query = param.String(default='', doc='Current search text.')
class-attribute
instance-attribute
¶
search = pmui.TextInput(placeholder='Search components', size='small', sizing_mode='stretch_width', margin=0, sx=_SEARCH_SX)
instance-attribute
¶
touch = param.Boolean(default=False, doc="\n Whether the palette is laid out for a touch screen, as in the phone's\n bottom sheet: entries are 48 px touch targets and the hint about\n dragging is hidden, since an entry is added with a tap there.")
class-attribute
instance-attribute
¶
refresh()
¶
Rebuild the menu items from the items callable.
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.
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.
ControlsBar
¶
Bases: Viewer
The views of the components shown beside the tiles: a top bar and a sidebar.
Components in the top bar sit in one slim row above the tile grid that
wraps on narrow screens; those in the sidebar are stacked in a panel left
of the grid that collapses to a narrow strip. Controls (components
registered with sidebar=True) go where the dashboard's
controls_position says unless they were moved, and controls, KPIs and
text can be moved between the grid and either area (see
:func:panel_flowdash.ui.tile_layout.move_to_area). Either way the
inputs use Material UI's small size and the areas take no room while they
are empty (or the editor's controls_bar is off, except in full screen,
where nothing around the editor is visible). :meth:sync re-reads the
editor, which calls it whenever its components change, and
:meth:layout places the areas around the tile grid.
beside_canvas = param.Boolean(default=False, doc="\n Whether the grid is shown beside the canvas (the editor's Split tab).\n The pane is too narrow for a sidebar there, so its components sit in\n the row above the grid too.")
class-attribute
instance-attribute
¶
collapsed = param.Boolean(default=False, doc='Whether the sidebar is collapsed.')
class-attribute
instance-attribute
¶
controls
property
¶
The component views currently shown beside the grid, top bar first.
editing = param.Boolean(default=False, doc='Whether the tiles are being arranged, which gives each component a drag handle.')
class-attribute
instance-attribute
¶
editor = param.Parameter(doc='The FlowDash editor whose controls are shown.')
class-attribute
instance-attribute
¶
grid_placed
property
¶
Whether the grid is placed as :attr:side says, or :meth:layout must place it again.
keys = {}
instance-attribute
¶
placed = param.Dict(default={}, doc='The area of each component shown beside the grid, by instance id.')
class-attribute
instance-attribute
¶
position = param.Selector(default='top', objects=list(POSITIONS), doc='Where controls that were not moved go: the top bar or the sidebar.')
class-attribute
instance-attribute
¶
side
property
¶
Whether the sidebar (open or collapsed) is shown, which :meth:layout places left of the grid.
uid
property
¶
The suffix of the CSS classes that mark this bar's areas on the page.
visible
property
¶
Whether there are controls to show.
hold()
¶
Keep the grid where it is placed until the block ends, whatever the sidebar holds meanwhile.
Loading a dashboard empties the sidebar and fills it again. When that
moved the grid out of the sidebar's row and back inside one held Bokeh
patch, the patch referenced a TileGrid id the browser had never
received, so it was dropped ("reference ... isn't known") and the
previous dashboard stayed on screen. :meth:layout places the grid for
the sidebar as it is once the last hold ends.
layout(grid)
¶
Return the workspace items placing the areas around grid.
sync()
¶
Re-read the editor's areas and lay them out; return whether the sidebar came or went.
When it did, the caller places the areas around the grid again with :meth:layout.
sync_notes(only=None)
¶
Show each component's provenance and filter notes anew, or those of only, after an edit or a change of mode.
DashboardBar
¶
Bases: Viewer
One row of dashboard controls, with a view and an edit section.
In view mode it shows the dashboard title, an info button opening the
description, the health chip (whose popover holds the pipeline and any
issues) and the view actions: the Dashboard/Report switch, Ask, Edit,
Refresh (its tooltip says when the dashboard was last refreshed) with the
auto-refresh period, the editor's toolbar_extra items, Full screen and
an overflow menu (Download, Settings). In edit mode it shows the title with
the save state, the same Dashboard/Report switch, the Dataflow/Layout/Split
tabs (Dataflow/Layout for the report), Ask when the host has an assistant,
and the edit actions: Settings, an overflow menu (Download, Import file,
Clear canvas), Discard, Save and Done.
layout arranges these parts. With "compact" they form one line:
the description sits behind an info button, and Refresh's tooltip says
when the dashboard was last refreshed. When a host offers its header
(placement="header", FlowDashApp's top bar), the bar then renders
nothing itself: the host places :attr:lead after its breadcrumb, which
stands in for the title, and :attr:actions at its end (see
:attr:in_header). With "full" the bar is always its own row, with a
large title over a line holding the description, the health chip and
when the dashboard was last refreshed.
Each part of a section comes from one method returning a list of
viewables, so a feature adds an item by extending that method:
:meth:_view_meta, :meth:_view_actions, :meth:_edit_status,
:meth:_edit_actions, and :meth:_menu_items for the menu entries
(dispatched by :meth:_on_overflow). Call :meth:sync after changing
anything they read. On phones the menu also stands in for the actions
the top bar hides (:meth:_phone_items).
actions
property
¶
The actions of the current mode.
ask_button = pmui.Toggle(label='Ask', icon='forum', icon_size='18px', value=editor.ask, margin=(0, 4), description='Ask about this dashboard', css_classes=['fd-ask-toggle'], sx=_ASK_SX, stylesheets=[PASSIVE_TOOLTIP_CSS, _ICON_ONLY_WHEN_NARROW, _HIDE_ON_PHONE])
instance-attribute
¶
description = pmui.Typography(variant='body2', margin=0, sx={'color': 'text.secondary'}, styles={'flex-basis': '100%'})
instance-attribute
¶
discard_button = pmui.Button(label='Discard', icon='undo', variant='text', color='default', size='small', margin=(0, 2), description='Discard', sx={'color': 'text.secondary'}, stylesheets=[PASSIVE_TOOLTIP_CSS, _icon_only('Discard'), _HIDE_ON_PHONE])
instance-attribute
¶
done_button = pmui.Button(label='Done', icon='check', variant='text', size='small', margin=(0, 4, 0, 2), description='Done', sx={'fontWeight': 600}, stylesheets=[PASSIVE_TOOLTIP_CSS, _DONE_ICON_ONLY, _HIDE_ON_PHONE])
instance-attribute
¶
download_button = pmui.FileDownload(callback=editor._download_callback, filename='dashboard.json', auto=True, visible=False)
instance-attribute
¶
edit_button = pmui.Button(label='Edit', icon='edit', variant='outlined', size='small', margin=(0, 4), description='Edit', css_classes=['fd-edit-button'], stylesheets=[PASSIVE_TOOLTIP_CSS, ICON_ONLY_WHEN_COMPACT, _HIDE_ON_PHONE])
instance-attribute
¶
editor = param.Parameter(doc='The FlowDash editor the bar controls.')
class-attribute
instance-attribute
¶
fullscreen_button = pmui.IconButton(icon='fullscreen', description='Full screen', size='small', margin=(0, 4), align='center', css_classes=[pmui.Fullscreen.TOGGLE_CLASS], sx=_ICON_BUTTON_SX, stylesheets=[PASSIVE_TOOLTIP_CSS, _HIDE_ON_PHONE])
instance-attribute
¶
health = DashboardHealth(editor)
instance-attribute
¶
health_chip = self.health_popover.chip
instance-attribute
¶
health_popover = HealthPopover(editor=editor, health=self.health)
instance-attribute
¶
in_header
property
¶
Whether a host header shows the lead and actions in place of the bar's own row.
info = pn.Row(self.info_button, self.info_popup, margin=0, align='center', styles={'width': 'fit-content', 'flex': '0 0 auto'})
instance-attribute
¶
info_button = pmui.IconButton(icon='info_outline', size='small', margin=0, color='default', description='About this dashboard', css_classes=['fd-description'], sx={'color': 'text.secondary'})
instance-attribute
¶
info_popup = pmui.Popup(self._about, anchor_origin={'horizontal': 'left', 'vertical': 'bottom'}, transform_origin={'horizontal': 'left', 'vertical': 'top'}, modal=False, label='About this dashboard', css_classes=['fd-description-popover'], sx={'& .MuiPopover-paper': {'p': 2, 'mt': 1, 'maxWidth': 'min(420px, calc(100vw - 32px))', 'borderRadius': '12px'}})
instance-attribute
¶
layout = param.Selector(default='compact', objects=['compact', 'full'], doc='\n "compact" keeps the bar to one line and lets a host header take it,\n "full" shows it as its own row with the title over a meta line.')
class-attribute
instance-attribute
¶
lead
property
¶
The title's companions: the info button and health chip, or the save state.
may_make_standalone_report = param.Callable(default=None, doc='\n Called with the open dashboard; "Make a standalone report" is offered\n only when it returns True. When unset, every dashboard may.')
class-attribute
instance-attribute
¶
mode_tabs = pmui.RadioButtonGroup(options=self.output_switch.tabs(_EDIT_TABS), value=self.output_switch.tab(), size='small', margin=(0, 12, 0, 4), sx=_TOGGLE_SX, stylesheets=[_ICON_ONLY_WHEN_NARROW, _HIDE_ON_PHONE])
instance-attribute
¶
on_mode = param.Callable(default=None, doc='\n Called with "edit" or "view" when the user asks to switch modes. When\n unset the bar switches the editor\'s `editable` itself, asking first\n when leaving edit mode with unsaved changes.')
class-attribute
instance-attribute
¶
on_open_source = param.Callable(default=None, doc="\n Called with no arguments when the user follows a standalone report's\n link back to the dashboard it was made from.")
class-attribute
instance-attribute
¶
on_standalone_report = param.Callable(default=None, doc="\n Called with no arguments when the user asks to make the dashboard's\n report a standalone report. The overflow menu offers it on a\n dashboard's report in view mode, and only when this is set.")
class-attribute
instance-attribute
¶
output_switch = OutputSwitch(editor, margin=(0, 4), sx=_TOGGLE_SX, stylesheets=[_ICON_ONLY_WHEN_NARROW, _HIDE_ON_PHONE])
instance-attribute
¶
output_toggle = self.output_switch.toggle
instance-attribute
¶
overflow = pmui.MenuButton(icon='more_vert', label='', variant='text', size='small', color='default', description='More actions', margin=(0, 4), sx=_OVERFLOW_SX, css_classes=['fd-more-actions'], stylesheets=[PASSIVE_TOOLTIP_CSS, PHONE_TOUCH_CSS])
instance-attribute
¶
placement = param.Selector(default='row', objects=['row', 'header'], doc='\n Whether a host offers its header for the bar ("header"), which then\n takes :attr:`lead` and :attr:`actions` and shows the dashboard\'s title\n while the layout is "compact", or not ("row").')
class-attribute
instance-attribute
¶
refresh_button = pmui.Button(label='Refresh', icon='refresh', variant='outlined', size='small', margin=(0, 0, 0, 4), description='Refresh now', sx={'borderTopRightRadius': 0, 'borderBottomRightRadius': 0}, stylesheets=[PASSIVE_TOOLTIP_CSS, ICON_ONLY_WHEN_COMPACT, _HIDE_ON_PHONE])
instance-attribute
¶
refresh_label = pmui.Typography(variant='caption', sx={'color': 'text.secondary'}, margin=0)
instance-attribute
¶
refresh_period = pmui.MenuButton(label='Off', variant='outlined', size='small', description='Update automatically', margin=(0, 4, 0, 0), sx={'borderTopLeftRadius': 0, 'borderBottomLeftRadius': 0, 'ml': '-1px', 'minWidth': 0, 'whiteSpace': 'nowrap', 'color': 'text.secondary'}, stylesheets=[PASSIVE_TOOLTIP_CSS, _HIDE_ON_PHONE])
instance-attribute
¶
refresh_text = ''
instance-attribute
¶
report_source = param.Callable(default=None, doc='\n Called with an opened standalone report; returns the title of the\n dashboard it was made from, or None to show no link, e.g. when that\n dashboard is gone or the viewer may not open it.')
class-attribute
instance-attribute
¶
save_button = pmui.Button(label='Save', icon='save', variant='text', size='small', margin=(0, 2), description='Save', stylesheets=[PASSIVE_TOOLTIP_CSS, _icon_only('Save'), PHONE_TOUCH_CSS])
instance-attribute
¶
save_state = pmui.Typography(variant='caption', sx={'color': 'text.secondary', 'whiteSpace': 'nowrap'}, margin=0, stylesheets=[_SAVE_STATE_DOT_ONLY])
instance-attribute
¶
settings_button = pmui.IconButton(icon='tune', size='small', margin=(0, 4), color='primary', description='Settings', sx=_ICON_BUTTON_SX, stylesheets=[PASSIVE_TOOLTIP_CSS, _HIDE_ON_PHONE, _SETTINGS_IN_MENU])
instance-attribute
¶
title = pmui.Typography(variant='subtitle1', margin=0, sx={'whiteSpace': 'nowrap', 'overflow': 'hidden', 'textOverflow': 'ellipsis', 'fontWeight': 500})
instance-attribute
¶
visible = param.Boolean(default=True, doc='Whether the bar is shown.')
class-attribute
instance-attribute
¶
discard()
¶
Throw away unsaved changes, reloading the saved dashboard.
download(extension='json')
¶
Send the canvas to the browser as a dashboard file, JSON or YAML.
open_import()
¶
Ask for a dashboard file to replace the canvas with.
request_mode(mode)
¶
Switch to mode ("edit" or "view") through on_mode, or directly.
stamp_refresh()
¶
Record that the dashboard was refreshed now.
sync()
¶
Reflect the editor's mode, dashboard and save state in the bar.
DashboardGroup
dataclass
¶
Nodes framed together on the canvas.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Unique within the dashboard, a name like the dashboard YAML's node names. |
label |
str | None
|
Shown in the group's header; the id is shown when it is None. |
nodes |
list[str]
|
Instance ids of the nodes in the group, in the order they were grouped. |
collapsed |
bool
|
Whether the canvas draws the group as one node. |
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
¶
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.
DockHandle
¶
Bases: JSComponent
A bar dragged to resize the layout holding it, which reports its new :attr:size.
A horizontal bar sits on top of a layout docked under the page and sets
its height; a vertical one sits on the inner edge of a layout docked to
the side and sets its width: on the left of one docked to the right, or
on the right of one docked to the left (edge="end"). While dragging, the layout follows the pointer
in the page; :attr:size is set once the pointer is released. Arrow keys
resize it by 24 pixels when the bar has focus. A width it sets stays
within max_ratio of the window as the window narrows, and comes back
as the window widens again.
The bar is a separator reporting the layout's size, and with
:attr:region it names the layout as a region it controls.
css_classes = [*self.css_classes, 'fd-dock-vertical']
instance-attribute
¶
edge = param.Selector(default='start', objects=['start', 'end'], doc='\n Which edge of its layout a vertical bar sits on: the left ("start"),\n for a layout docked to the right, or the right ("end"), for one\n docked to the left, which grows as the bar is dragged right.')
class-attribute
instance-attribute
¶
label = param.String(default='Resize the code panel', doc="The bar's accessible name.")
class-attribute
instance-attribute
¶
max_ratio = param.Number(default=0.8, doc="The largest share of the parent's height or width it may take.")
class-attribute
instance-attribute
¶
max_size = param.Integer(default=None, allow_None=True, doc='The largest size, if any.')
class-attribute
instance-attribute
¶
min_size = param.Integer(default=160)
class-attribute
instance-attribute
¶
orientation = param.Selector(default='horizontal', objects=['horizontal', 'vertical'], doc='A horizontal bar resizes the height, a vertical one the width.')
class-attribute
instance-attribute
¶
region = param.String(default=None, allow_None=True, doc='The accessible name of the layout it resizes, which is then a region the bar controls.')
class-attribute
instance-attribute
¶
size = param.Integer(default=None, allow_None=True, doc='The height or width the bar resized its layout to.')
class-attribute
instance-attribute
¶
DragGuard
¶
Bases: JSComponent
Turns off text selection on the page while something in the editor is dragged.
From a press on one of :data:HANDLES, or a native dragstart of one, until
the pointer is released or the native drag ends, the body's
user-select is none; afterwards its own inline value is put back.
A selection the browser makes during the drag all the same, as WebKit
does, is cleared, while one made before the drag is kept through it (WebKit
itself collapses it on the press); a click there, moving less than a drag,
clears it as a click elsewhere does. Presses in text fields, and on parts
of a node marked nodrag, are left alone.
It takes no space on the page.
EditHistory
¶
The versions of the dashboards an editor has open, and undo and redo over them.
Created by :class:~panel_flowdash.editor.FlowDash, which calls
:meth:record after every edit and :meth:opened whenever another
dashboard (or a new one) is shown. Use the editor's
:meth:~panel_flowdash.editor.FlowDash.undo and
:meth:~panel_flowdash.editor.FlowDash.redo rather than this object;
:attr:state is the RunState holding the versions, to show them in
a panel-agents ArtifactView or to share with an AgentRunner.
active
property
¶
Whether edits are recorded: history is on and the user may edit the dashboard.
artifact
property
¶
The open dashboard's document artifact, once it has a version.
artifact_id
property
¶
The id of the open dashboard's document artifact in :attr:state.
busy
property
¶
Whether a request to an agent is running, during which undo and redo wait.
can_redo
property
¶
Whether :meth:redo would redo something now.
can_undo
property
¶
Whether :meth:undo would undo something now.
editor = editor
instance-attribute
¶
on_load = None
instance-attribute
¶
redo_label
property
¶
What :meth:redo would bring back, for menus.
refused
property
¶
Why the open dashboard's stored history is not shown, if it was loaded and is not.
requests_pending
property
¶
Whether an agent request has edits not yet published as its version.
shown = False
instance-attribute
¶
state = RunState(max_events=MAX_EVENTS)
instance-attribute
¶
undo_label
property
¶
What :meth:undo would take back, e.g. "Added kpi", for menus.
versions
property
¶
The open dashboard's versions, oldest first, including the edit in progress.
batched()
¶
Take the canvas once for the agent's edits made inside, rather than after each of them.
Each agent edit otherwise writes the whole dashboard as YAML, which on a large dashboard is the bulk of an edit's time. Only for edits made without yielding to the event loop, such as Explore's Add: a person's edit cannot land between them, so the canvas at the end is the one the agent's last edit left.
close()
¶
Publish the edit in progress and stop writing to the store.
drop_requests(run_id)
¶
Forget the edits request run_id made so far without a version, e.g. once taken back.
end_requests(run_id=None)
¶
Publish the version of each agent request that ended: all of them, or those of run_id.
The editor calls it when the agent's turns end, and the history when a run in its state finishes or fails, so a request is one version whether it finished, failed or was cancelled. The tiles the request added are laid out first, as part of its version.
flush()
¶
Publish the edit in progress, if any, as a version.
follow(state)
¶
Treat the runs of another agent's state like those in :attr:state.
For an agent whose runs are shown apart from the history's, such as the Explore view's: undo and redo wait while one of its runs is going, and each request's edits become a version when its run ends.
grouped(*, atomic=False)
¶
Make the person's edits inside the block one version, which one undo reverts.
The edit in progress before the block is published first, so undo never takes it along with the block's. With atomic, a block that raises puts the dashboard back as it was before the block, also while the history is off, and its edits never become a version, so neither undo nor redo brings them back.
load()
¶
Load the open dashboard's stored history now, to show it before any edit.
Loading writes nothing to the store: the dashboard as opened becomes a version at the first edit, undo or restore, as without loading. In view mode retention is applied to what is shown, not to the store.
opened()
¶
Start recording the dashboard now in the editor, as it is now.
The stored history is loaded at the first edit, undo or look at the versions, so opening a dashboard to view it costs one YAML dump. The dashboard as opened becomes a version just before the first edit or undo, unless the stored history ends with it.
record(op, args, label, turn)
¶
Record an edit the editor just made, as a new version or as part of the gesture in progress.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
op
|
str
|
The operation, e.g. |
required |
args
|
dict[str, Any]
|
What it was applied to, e.g. |
required |
label
|
str | None
|
A sentence for people, e.g. |
required |
turn
|
AssetTurn | None
|
The turn the edit belongs to. |
required |
redo()
¶
Redo what the last undo undid, in one step. See :meth:FlowDash.redo.
request_run()
¶
Return the run of the open dashboard's one agent request still open, or None.
restore(artifact, version)
¶
Make the canvas match version, for an ArtifactView's on_apply.
The view records the step itself. Raises PermissionError if the
version holds nodes the user may not bring back.
saved()
¶
Note that the canvas as it is now was saved, under the editor's dashboard id.
When the canvas had no dashboard before, its versions so far move to the saved dashboard's history, so they are stored and undo keeps them.
snapshot()
¶
Return the dashboard YAML as the editor's user sees it, and its revision.
The text starts with the # revision: line DashboardOps.get_dashboard writes.
step_value(action)
¶
Return the version :meth:undo (action "undo") or :meth:redo would apply, if any.
undo(*, whole_runs=True)
¶
Undo the last change, or the agent's whole last request. See :meth:FlowDash.undo.
FailureMessage
dataclass
¶
What a failure overlay says about the failed inputs of one tile.
sources names the upstream components whose failure stopped the tile,
in the words the user sees; details holds the technical explanation
shown behind the Details disclosure.
FailureOverlay
¶
Bases: Column
A view with a message that covers it while any of its inputs is failed.
objects stays [view, overlay]; the overlay is a sibling that is
only visible while the failures are non-empty. actions is a row of
extra buttons shown next to the Details toggle, e.g. a way to the editor.
A failure that :func:is_restricted turns the message into a neutral
"Restricted" one, without the names of the failed components or details,
over an opaque scrim, whatever describe says. One refused input is
enough: a genuine failure of another input then stays behind the neutral
message, which fails closed.
actions = pn.Row(margin=0, align='center', visible=restricted.rx.not_())
instance-attribute
¶
details = pmui.Typography(message.rx.pipe(lambda m: escape_markdown(m.details)), css_classes=['flowdash-failure-details'], variant='caption', align='center', margin=(4, 16, 0, 16), max_width=560, visible=False, sx={'color': 'text.secondary', 'fontFamily': 'monospace', 'overflowWrap': 'anywhere', 'textAlign': 'left', 'whiteSpace': 'pre-line'})
instance-attribute
¶
details_toggle = pmui.Button(label='Details', icon='expand_more', size='small', variant='text', margin=(0, 4), visible=restricted.rx.not_())
instance-attribute
¶
summary = pmui.Typography(message.rx.pipe(lambda m: RESTRICTED_TEXT if m.restricted else _sentence(m.sources)), variant='body2', align='center', margin=(0, 16), max_width=560, sx={'color': 'text.secondary', 'textAlign': 'center'})
instance-attribute
¶
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.
GlobalFilters
¶
Bases: Parameterized
The global filters of a :class:~panel_flowdash.editor.FlowDash editor and the views they reach.
editor
property
¶
filters = param.List(default=[], doc="The dashboard's filters, views they exclude by instance id.")
class-attribute
instance-attribute
¶
revision = param.Integer(default=0, doc='Bumped when the data of a view changes, so filter choices are read again.')
class-attribute
instance-attribute
¶
shared = param.List(default=[], doc='\n The Filter nodes feeding every view, as (instance id, title). The\n filter bar shows them once instead of a chip on each tile.')
class-attribute
instance-attribute
¶
values = param.Dict(default={}, doc='The current value of each filter, by column.')
class-attribute
instance-attribute
¶
active()
¶
Return the predicates of the filters with a value, by column.
apply()
¶
Hand every view the predicates that reach it now, and update the notes on its tile.
available_columns()
¶
Return the columns of the views' data that have no filter yet, for adding one.
columns(instance_id)
¶
Return the columns a view can be filtered on, None while it does not know them.
entry(column)
¶
filter_inputs(instance_id, values)
¶
Return the input values of a view with its global filters applied to its DataFrames.
A filter a column cannot be compared with, e.g. a range of numbers on text, is left out for that view, whose tile then says so.
forget(instance_id)
¶
Drop what is kept about a node that went away.
frames()
¶
Return the DataFrames arriving at the views, unfiltered, to offer filter choices from.
inputs_changed(instance_id, names)
¶
Note that new values arrived at a view's inputs, which may change its columns and notes.
A view applying filters itself is asked for its columns again, since any input, e.g. a query, can change them.
load(filters)
¶
Show filters, keeping the current value of each filter whose starting value is the same.
local_filters(instance_id, sources=None)
¶
Return the instance ids of the Filter nodes upstream of a view, nearest first.
A Filter node is a transform tagged filter, such as the built-in filter by selection.
mismatched(instance_id)
¶
Return why the filters a view's data cannot be compared with were not applied, by column.
notes(instance_id)
¶
Return the chips of a view's own Filter nodes (id, title), its hint and the hint's detail.
Filter nodes every view shares are left out, see :attr:shared.
Reuses what :meth:apply last worked out, so a tile costs no more than its own view.
options(column)
¶
Return the values a select filter on column offers.
predicates_for(instance_id)
¶
Return the predicates a view gets now: the active filters it has not opted out of.
refresh(instance_id)
¶
Read a view's columns again and hand it the filters that reach it, even if unchanged.
request(component)
classmethod
¶
Read the columns of component again and hand it its filters anew, wherever it is shown.
See :func:panel_flowdash.global_filters.request_filters.
set_value(column, value)
¶
Change the current value of the filter on column, e.g. as the viewer chose it.
Raises:
| Type | Description |
|---|---|
KeyError
|
If the dashboard has no filter on column. |
FilterError
|
If value is not one the filter's widget takes. |
shown_notes(instance_id)
¶
Return the notes a view shows now, as :meth:notes last worked them out; empty without any.
span(column)
¶
Return the smallest and largest value a range filter on column spans.
Views whose column cannot be compared with the others', e.g. text where most hold numbers, are left out.
summarizes(instance_id)
¶
Return whether a view shows numbers worked out upstream, e.g. a KPI, rather than rows.
Such a view has a number arriving along an edge at one of its inputs, and no DataFrame at any: a global filter cannot reach the rows the number came from. A number set on the view itself is not worked out from rows.
targets()
¶
Return the instance ids of the views the dashboard shows, which global filters reach.
widget(entry)
¶
Return the widget of entry: its own, or the one the type of its column gives.
InputFailure
dataclass
¶
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.
Inspector
¶
Bases: Viewer
The sidecar: a panel beside the canvas or the tile grid showing what is selected.
It is shown in the Dataflow, Split and Layout tabs, follows the editor's
one selection, and for a component shows the tabs Settings, Spec (where it
has a spec, or a definition to show), Data, Tile and, when the assistant
made it, History. The Spec tab holds the editor's code panel wherever it
is not under the canvas, see :meth:sync_spec_tab. Whether it is open or
folded is decided by the editor's :class:~panel_flowdash.ui.sidecar.SidecarFold.
collapse_button = pmui.IconButton(icon='keyboard_double_arrow_right', description='Hide inspector', size='small', margin=(8, 4, 0, 0), align='end')
instance-attribute
¶
collapsed = param.Boolean(default=False, doc='Whether the panel is folded to a narrow strip.')
class-attribute
instance-attribute
¶
current_width
property
¶
The width the panel takes beside the canvas: open, folded or 0 when hidden.
editing_spec = param.Boolean(default=False, doc="Whether a component's Spec tab is shown, which wants more room.")
class-attribute
instance-attribute
¶
editor = param.Parameter(doc='The FlowDash editor whose canvas selection is inspected.')
class-attribute
instance-attribute
¶
expand_button = pmui.IconButton(icon='keyboard_double_arrow_left', description='Show inspector', size='small', margin=(8, 4))
instance-attribute
¶
handle = DockHandle(orientation='vertical', min_size=SIDECAR_MIN_WIDTH + HANDLE_WIDTH, max_size=SIDECAR_MAX_WIDTH + HANDLE_WIDTH, max_ratio=0.5, label='Resize the side panel', sizing_mode='stretch_height', width=HANDLE_WIDTH, margin=0)
instance-attribute
¶
sheet = param.Boolean(default=False, doc='\n Whether the panel fills a bottom sheet, as on a phone, rather than a\n column beside the canvas. Folding it then closes the sheet.')
class-attribute
instance-attribute
¶
tile_options = None
instance-attribute
¶
visible = param.Boolean(default=True, doc='Whether the panel is shown.')
class-attribute
instance-attribute
¶
width = param.Integer(default=SIDECAR_WIDTH, bounds=(SIDECAR_MIN_WIDTH, SIDECAR_MAX_WIDTH), doc='The width of the open panel, set by dragging its left edge.')
class-attribute
instance-attribute
¶
fold(folded)
¶
Fold the panel to its strip or open it, as the person chose.
has_unsent_text()
¶
Whether a code field shown holds typed text it has not applied yet.
open_tab(instance_id, tab, turn_id=None)
¶
Show tab of the component instance_id, now if it is shown or else once selected.
turn_id names the later turn the History tab shows, None for the request that made it.
refresh(force=False)
¶
Show the selected component or connection, or the dashboard summary.
refresh_node()
¶
Rebuild a node's view if it is shown, e.g. once its spec moves to or from the code panel.
refresh_summary()
¶
Rebuild the dashboard summary if it is shown, e.g. after the issues changed.
settle()
async
¶
Wait for the config check of an edit in the form shown, so a save includes it.
sync_spec_tab()
¶
Fill the shown component's Spec tab: the code panel, or where it is.
The editor has one code panel, shown in one place at a time. Unless it is under the canvas, this tab holds it, opened on the component when the tab is shown.
LayoutPanel
¶
Bases: Viewer
The bands the tiles are arranged for, and the components off the grid.
arrange_section
property
¶
The band picker, shown only when the grid has more than one band.
band = param.String(default=None, allow_None=True, doc='Label of the breakpoint band the tiles are arranged for, or None for the base band.')
class-attribute
instance-attribute
¶
band_select = pmui.RadioButtonGroup(options={}, size='small', sizing_mode='stretch_width', margin=(0, 0, 8, 0))
instance-attribute
¶
band_summary = _caption('', margin=0)
instance-attribute
¶
editor = param.Parameter(doc='The FlowDash editor whose tile grid is arranged.')
class-attribute
instance-attribute
¶
off_grid_section = pn.Column(_heading('Not on the dashboard'), _caption('Placed components without a tile: those shown beside the dashboard and hidden tiles, such as the data sources the assistant left off. Show a hidden one to put it back.', margin=(0, 0, 8, 0)), self._off_grid, margin=0, sizing_mode='stretch_width', css_classes=['fd-off-grid'])
instance-attribute
¶
reset_band_button = pmui.Button(label='Reset to automatic', icon='restart_alt', variant='text', size='small', margin=(4, 0, 0, 0), sx={'textTransform': 'none'})
instance-attribute
¶
visible = param.Boolean(default=True, doc='Whether the Layout tab, which arranges the tiles, is shown.')
class-attribute
instance-attribute
¶
band_hint()
¶
Say which band's layout a tile's width and height apply to, if not the one shown.
refresh()
¶
Re-read the components off the grid, listing the first :data:MAX_OFF_GRID.
show_tile(instance_id)
¶
Put a hidden tile back on the dashboard.
sync_bands()
¶
Show the bands of the grid's breakpoints, the one arranged for and how each is arranged.
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.
NodeCard
¶
Bases: Viewer
The compact view of a placed component on the wiring canvas.
The card's parameters follow the component straight away, while its HTML
is rebuilt at most once per burst of changes in a served session (see
:class:~panel_flowdash.ui.node_preview.Coalescer) and only sent when it
differs from what the page shows.
active_output = param.String(default=None, allow_None=True, doc='Effective output port currently previewed, used to mark the eye icon.')
class-attribute
instance-attribute
¶
base_height
property
¶
The card's height without a preview, set by its collapsed state and visible ports.
collapsed = param.Boolean(default=False, doc='Whether the card is collapsed to a single 44 px header row.')
class-attribute
instance-attribute
¶
edit = param.Selector(default=None, objects=[None, 'spec', 'definition'], doc='\n What the header\'s edit button opens in the code panel: the\n component\'s ``"spec"``, its read-only ``"definition"``, or None for\n no button.')
class-attribute
instance-attribute
¶
height
property
¶
The card's current height, including the preview shown.
icon = param.String(default='widgets', doc='Material icon name.')
class-attribute
instance-attribute
¶
inputs = param.List(default=[], doc='Input ports as dicts with ``name``, ``label``, ``type``, ``required``, ``connected``, ``missing``, ``source``.')
class-attribute
instance-attribute
¶
outputs = param.List(default=[], doc='Output ports as dicts with ``name``, ``label``, ``type``.')
class-attribute
instance-attribute
¶
preview
property
¶
The preview the card shows, if any.
preview_output = param.String(default=None, allow_None=True, doc='User-selected output port to preview, or None for automatic selection.')
class-attribute
instance-attribute
¶
preview_source = param.Callable(default=None, doc="\n Returns the card's current preview, or None to show the summary. Only\n called while ``show_preview`` is on and the card is expanded.")
class-attribute
instance-attribute
¶
show_optional = param.Boolean(default=False, doc='Whether folded unconnected optional inputs are temporarily expanded.')
class-attribute
instance-attribute
¶
show_preview = param.Boolean(default=False, doc='Whether to preview the current value below the ports.')
class-attribute
instance-attribute
¶
stale = param.Selector(default=None, objects=[None, *STALE_TEXT], doc='\n Whether the result does not match the spec in the code panel: a\n ``"draft"`` not run, or ``"running"``.')
class-attribute
instance-attribute
¶
status = param.Selector(default='ok', objects=list(STATUS_TEXT))
class-attribute
instance-attribute
¶
status_detail = param.String(default='', doc='Why the component has its status.')
class-attribute
instance-attribute
¶
subtitle = param.String(default='', doc='Secondary component type label under the title.')
class-attribute
instance-attribute
¶
summary = param.String(default='', doc='One line describing the current value.')
class-attribute
instance-attribute
¶
title = param.String(default='')
class-attribute
instance-attribute
¶
handle_layout()
¶
Return handle metadata (for JS sync) and CSS variable overrides (for node['style']).
refresh(*_events)
¶
Rebuild the card, e.g. once the value it previews changed.
release()
¶
Stop updating the card, e.g. once its component has been removed.
OutputPort
dataclass
¶
PaletteDrawer
¶
Bases: Parameterized
The component palette in its column beside the canvas, open or folded to a strip.
:attr:panel is the column. fold_button, made by :func:fold_button,
sits in the palette's header. On a phone the palette moves to a bottom
sheet (see :meth:detach), where it does not fold.
bridge = PaletteFoldBridge(uid=uid, on_open=lambda: self.toggle(True, focus=True))
instance-attribute
¶
fold_button = fold_button
instance-attribute
¶
open = param.Boolean(default=True, doc='Whether the palette is open rather than folded.')
class-attribute
instance-attribute
¶
palette = palette
instance-attribute
¶
panel = pn.Column(region, self.unfold_button, self.bridge, width=width, sizing_mode='stretch_height', margin=0, styles={'border-right': '1px solid var(--mui-palette-divider, #e0e0e0)'}, stylesheets=[f':host(.{FOLDED_CLASS}) .fd-palette-region-{uid} {{ display: none !important; }}'])
instance-attribute
¶
unfold_button = pmui.IconButton(icon='keyboard_double_arrow_right', description=UNFOLD_LABEL, size='small', margin=(8, 4), visible=False, css_classes=[f'fd-palette-unfold-{uid}'])
instance-attribute
¶
width = width
instance-attribute
¶
attach()
¶
Put the palette back in the column after the phone layout.
detach()
¶
Take the palette out of the column, to show it in the phone's sheet.
toggle(open_, focus=False)
¶
Open or fold the palette; with focus, move the focus to what is shown in its place.
ParameterError
¶
PendingOutputs
¶
Track the async outputs of a dashboard that are running.
An output is running from the moment its dependencies change until it
publishes, skips, fails or is superseded, as Param's rx.updating()
reports it. A node is pending while one of its own outputs runs, or one
of a node upstream of it does, since its inputs are then stale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
links
|
Callable[[], Iterable[tuple[str, str]]]
|
Returns the dataflow's edges as |
required |
busy(node_ids=None, sources=None)
¶
Return the nodes with a running output, among node_ids and their upstream, or all.
sources are the edges by target, when already worked out.
downstream(node_ids)
¶
Return node_ids and every node downstream of them.
message(node_id, sources=None)
¶
Say why node_id is pending, or return None when it is not.
node(node_id)
¶
Return the object whose message follows whether node_id is pending.
refresh()
¶
Work out again which nodes are pending, once the edges changed.
running(node_id=None)
¶
Return the running outputs by node, of node_id only when given.
set_namer(names)
¶
Name nodes in the messages with names, e.g. by their YAML name.
settled(timeout=10.0, node_ids=None)
async
¶
Wait until no output of node_ids or their upstream (by default any) is running.
Returns True once settled and False when timeout seconds pass first. A settled output can start a consumer's async output in the same step, so it checks again after yielding to the event loop once.
track(node_id, port, outlet)
¶
Follow whether the async output port of node_id, held on outlet, is running.
Returns the function that stops following it.
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.
Placeholder
dataclass
¶
Why a saved item is shown as a placeholder, and what the placeholder says.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reason
|
str
|
A short machine-readable cause, e.g. |
required |
title
|
str
|
Label of the placeholder node and heading of its tile. |
required |
message
|
str
|
Text shown on the node and the tile. |
required |
private
|
bool
|
Whether the saved item must not be described at all. Its id, config and port names are then kept out of the page; edges touching it are only counted, never listed. |
False
|
PlacementRefused
¶
Bases: PermissionError, ValueError
An imported dashboard adds components refuse_placement keeps this session from adding.
Project
dataclass
¶
A loaded project file.
It holds the raw data, where each key and value is written, by path
(e.g. ("metrics", "capacity", "table")), the value each registered
loader made of its section, the warnings found while loading and the
context the loaders were given.
context = field(default_factory=dict)
class-attribute
instance-attribute
¶
data = field(default_factory=dict)
class-attribute
instance-attribute
¶
directory
property
¶
Return the directory the file is in, against which paths it names resolve.
path = None
class-attribute
instance-attribute
¶
positions = field(default_factory=dict)
class-attribute
instance-attribute
¶
warnings = field(default_factory=list)
class-attribute
instance-attribute
¶
get(name, default=None)
¶
Return the value of section name, or default if the file has none.
The value is what the section's loader returned. A section whose loader
was registered after the file was loaded is loaded now (raising
ProjectError); a section no loader is registered for gives its
raw data.
load_all()
¶
Load every section a loader is registered for, warning about the others.
Raises ProjectError with every problem the loaders found.
position(path)
¶
Return the 1-based line and column of the value at path.
A path that is not in the file gives the position of its nearest enclosing value.
problem(path, message, key=False)
¶
Return a problem at the value at path (with key, at the key naming it).
raw(name, default=None)
¶
Return the raw YAML data of section name.
set(name, value)
¶
Set section name to value and write it to the project's file.
The value goes through the section's dump and the result through
its loader, so a value the loader rejects raises ProjectError,
positioned where it would be written, and the file is left alone.
Only the lines of this section change in the file; comments inside it
are not kept. Text a YAML 1.1 reader would take for something else,
such as no or 1:20, is quoted.
update(name, change)
¶
Change section name from its raw data as the file has it now, and write it.
change is called with a copy of the section's raw YAML data, read
again from the file (None when the file has no such section), and
returns the new value, which is written as set writes it. The read,
change and the write happen under FILE_LOCK, so no other write
from this process comes in between. An exception from change
leaves the file alone. Returns the value written.
Provenance
dataclass
¶
Where a node's numbers come from, e.g. a named metric or a query of its own.
detail = ''
class-attribute
instance-attribute
¶
A sentence shown on hover, e.g. the metric's description or how the number was computed.
icon = None
class-attribute
instance-attribute
¶
A Material icon name for the chip, "warning" by default for a warning.
kind = ''
class-attribute
instance-attribute
¶
What kind of provenance it is, e.g. "metric" or "ad hoc", for styling and tests.
label
instance-attribute
¶
A short label, e.g. "Metric: capacity" or "Ad hoc".
level = 'info'
class-attribute
instance-attribute
¶
"warning" if it warns about the numbers, e.g. that a row limit cut them, which every viewer is shown.
note
property
¶
The label and detail as one line of text, e.g. for a caption in an export.
warning
property
¶
Whether it warns about the numbers, see :attr:level.
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.
ReportView
¶
Bases: Viewer
The Report view of a :class:~panel_flowdash.editor.FlowDash editor.
editor = param.Parameter(doc='The FlowDash editor whose dashboard the report shows.')
class-attribute
instance-attribute
¶
shown = param.Boolean(default=False, doc='\n Whether the view is on screen. While hidden it neither follows the\n outputs its text shows nor rebuilds, and catches up when shown.')
class-attribute
instance-attribute
¶
schedule(*_events)
¶
Rebuild the report soon, once for a burst of changes, while it is on screen.
sync()
¶
Build the report from the dashboard as it is now.
SettingsDialog
¶
Bases: Parameterized
One dialog for a dashboard's settings, its refresh schedule and its sharing.
The editor owns it and mounts dialog. Settings are edited on a copy and
applied to the editor's settings on Save settings. An application
supplies the sharing, rename and delete callbacks; without them the dialog
only offers the dashboard settings.
delete = param.Callable(default=None, doc='\n Called with the dashboard id and title to ask for deleting the\n dashboard. Without it the dialog offers no Delete.')
class-attribute
instance-attribute
¶
dialog = pmui.Dialog(objects=[self._subtitle, body], actions=[self._footer_note, pn.layout.HSpacer(), self._cancel_button, self._save_button], title='Dashboard settings', open=False, show_close_button=True, width_option='md', sx={'& .MuiDialog-paper': {'minWidth': 'min(760px, 100%)'}})
instance-attribute
¶
rename = param.Callable(default=None, doc='\n Called with the dashboard id and the new title. Returns None once\n renamed, or the reason it was not. Without it the title is read-only.')
class-attribute
instance-attribute
¶
save_sharing = param.Callable(default=None, doc='\n Called with the dashboard id and the new Permission when the sharing\n changed. Returns whether it was stored.')
class-attribute
instance-attribute
¶
section = param.Selector(default='general', objects=list(SECTIONS), doc='The section shown.')
class-attribute
instance-attribute
¶
sharing = param.Callable(default=None, doc="\n Called with a dashboard id when the dialog opens. Returns the\n SharingAccess to show, or None when the current identity may not\n change the dashboard's sharing.")
class-attribute
instance-attribute
¶
set_role(name, kind, role)
¶
Give a listed person or group another role, or remove them.
show(section='general', asset_id=None, title='')
¶
Open the dialog on section for a dashboard, by default the editor's.
SheetLabel
¶
Bases: JSComponent
Names the sheet it is placed in for assistive technology.
The Drawer's paper takes no attributes, and an aria-labelledby cannot
reach the title in another shadow root, so the label is set on the paper
(or its dialog) from inside. A temporary sheet renders a new paper each
time it opens, which resizes this element, so the label is set again then.
label = param.String(doc="The sheet's accessible name, its visible title.")
class-attribute
instance-attribute
¶
SidecarFold
¶
Bases: Parameterized
The one owner of the sidecar's collapsed state, see the module docstring.
drawer_open = param.Boolean(default=False, doc="Whether the assistant's drawer is open.")
class-attribute
instance-attribute
¶
drawer_width = param.Integer(default=0, doc='The width the open drawer takes from the page; 0 while it overlays the page.')
class-attribute
instance-attribute
¶
editor = editor
instance-attribute
¶
on_close_drawer = param.Callable(default=None, allow_None=True, doc="Closes the assistant's drawer, to free the shared slot.")
class-attribute
instance-attribute
¶
user_open = param.Boolean(default=True, doc='Whether the person last opened rather than folded it.')
class-attribute
instance-attribute
¶
drawer_changed(open_, width=0)
¶
Record the assistant's drawer opening or closing; width is what it takes from the page.
fits()
¶
folded()
¶
Whether the sidecar is folded, from the person's choice, the drawer and the budget.
On a phone it is a bottom sheet over the page, which the person or the drawer opening over it closes.
left_phone()
¶
Open the column again after the phone layout, whose sheet the person may have closed.
Beside an open drawer in a window where they share a slot, the drawer keeps it.
on_collapsed(collapsed)
¶
Follow the sidecar folded or opened by anyone but this owner, e.g. a test or a phone sheet.
room()
¶
Return the width left to the canvas or the grid beside the open sidecar, or None if unknown.
selection_made()
¶
Open the sidecar the budget folded, as the person selected something to see in it.
sync()
¶
Fold or open the sidecar as :meth:folded decides.
user_toggle(open_)
¶
Record the person opening or folding the sidecar, and apply it.
window_resized()
¶
SplitView
¶
Bases: Viewer
The canvas and the tile grid in two resizable panes.
on_collapse is called with the pane that was collapsed (0 for the canvas, 1 for the grid), on_load once the preferences stored in the browser were read and any usable ones applied, and on_resize when the canvas pane was shown or changed width.
events = SplitEvents(on_resize=on_resize)
instance-attribute
¶
left = pn.Column(margin=0, sizing_mode='stretch_both')
instance-attribute
¶
loaded = False
instance-attribute
¶
on_collapse = on_collapse
instance-attribute
¶
on_load = on_load
instance-attribute
¶
on_resize = on_resize
instance-attribute
¶
preferences = param.ClassSelector(class_=SplitPreferences, doc='The remembered state.')
class-attribute
instance-attribute
¶
right = pn.Column(margin=0, sizing_mode='stretch_both', scroll='both-auto')
instance-attribute
¶
split = HSplit(self.left, self.right, sizes=sizes, expanded_sizes=sizes, collapse_threshold=5, show_buttons=True, snap_size=80, gutter_size=8, sizing_mode='stretch_both', stylesheets=[GUTTER_CSS], margin=0)
instance-attribute
¶
storage = LocalPreference(on_load=self._on_stored, key=key, legacy_key=None if key == STORAGE_KEY else STORAGE_KEY)
instance-attribute
¶
restore()
¶
Open both panes at the remembered sizes, e.g. after one was collapsed.
show(left, right)
¶
Put left (the canvas) and right (the grid and its controls) in the panes.
StartCard
¶
Bases: Viewer
The empty canvas's guide: three steps to a first dashboard and one-click starts.
add_button = pmui.Button(icon='add', variant='contained', size='small', margin=0, visible=False)
instance-attribute
¶
editor = param.Parameter(doc='The FlowDash editor whose canvas is empty.')
class-attribute
instance-attribute
¶
import_button = pmui.Button(label='Import a .json file', icon='upload_file', variant='text', size='small', margin=0)
instance-attribute
¶
refresh(*_events)
¶
Pick the data source to offer and reflect whether the canvas may be edited.
StatusBar
¶
Bases: Viewer
A one-line bar under the canvas summarizing the dashboard's state.
It says whether every output is up to date or how many issues there are (clicking the count selects the first component or connection with an issue), counts the components and connections, lists key hints and shows the zoom. In the Layout tab it describes the tile grid instead: its columns, the tiles on it and the components without a tile. The canvas follows the page's light or dark theme through it, since it is a Material component shown alongside the canvas in every edit session.
collapse_toggle = pmui.Toggle(label='Collapse all', icon='unfold_less', icon_size='18px', value=False, description='Collapse all nodes (C)', size='small', margin=0, align='center', styles={'flex': 'none'}, stylesheets=[_VIEW_TOGGLE_CSS, PHONE_TOUCH_CSS], sx=_VIEW_TOGGLE_SX)
instance-attribute
¶
counts = pmui.Typography(variant='caption', margin=(0, 12), styles={'flex': 'none'}, sx=_NOWRAP, stylesheets=[f'@container fd-status-bar (max-width: {_COUNTS_MIN_WIDTH - 2 * _BAR_PADDING}px) {{ :host {{ display: none !important; }} }}'])
instance-attribute
¶
editor = param.Parameter(doc='The FlowDash editor whose canvas the bar describes.')
class-attribute
instance-attribute
¶
grid_label = pmui.Typography(f'{GRID_COLUMNS}-column grid', variant='caption', margin=(0, 12, 0, 0), styles={'flex': 'none'}, sx=_NOWRAP)
instance-attribute
¶
issues_button = pmui.Button(label='All outputs up to date', icon='check_circle', icon_size='16px', variant='text', size='small', color='success', margin=0, styles={'flex': 'none'}, sx={**_TEXT, 'textTransform': 'none', 'fontWeight': 400, 'whiteSpace': 'nowrap', 'py': '2px', 'minHeight': 0, '& .MuiButton-startIcon': {'ml': 0, 'mr': '4px'}}, stylesheets=[PHONE_TOUCH_CSS])
instance-attribute
¶
keys = pn.pane.HTML('<div class="fd-keys"><span><kbd>Space</kbd>drag to pan</span><span><kbd>Del</kbd>remove</span></div>', margin=(0, 12), styles={'flex': 'none'}, stylesheets=[_KEYS_CSS, f'@container fd-status-bar (max-width: {_KEYS_MIN_WIDTH - 2 * _BAR_PADDING}px) {{ :host {{ display: none !important; }} }}'])
instance-attribute
¶
minimap_toggle = pmui.ToggleIcon(icon='map', active_icon='map', value=flow.show_minimap, description='Show minimap', color='default', icon_size='18px', sx={'color': 'text.secondary', '&.Mui-checked': {'color': 'primary.text'}, '& .MuiIcon-root': {'color': 'inherit'}}, size='small', margin=0, align='center', styles={'flex': 'none'}, stylesheets=[PHONE_TOUCH_CSS])
instance-attribute
¶
preview_toggle = pmui.Toggle(label='Previews', icon='preview', icon_size='18px', value=settings.node_previews, size='small', margin=0, align='center', styles={'flex': 'none'}, stylesheets=[_VIEW_TOGGLE_CSS, PHONE_TOUCH_CSS], sx=_VIEW_TOGGLE_SX)
instance-attribute
¶
view_controls = pn.Row(self.preview_toggle, self.collapse_toggle, self.minimap_toggle, self.zoom, margin=(0, 0, 0, 4), styles={'flex': 'none', 'gap': '2px', 'padding-left': '8px', 'border-left': '1px solid var(--mui-palette-divider)'})
instance-attribute
¶
visible = param.Boolean(default=True, doc='Whether the bar is shown.')
class-attribute
instance-attribute
¶
zoom = pmui.Typography(variant='caption', margin=(0, 4, 0, 6), align='center', styles={'flex': 'none'}, sx=_NOWRAP)
instance-attribute
¶
sync()
¶
Recount the components, connections and issues.
sync_collapse_toggle()
¶
Reflect whether every card on the canvas is collapsed, without toggling them.
toggle_collapse_all()
¶
Collapse every node on the canvas, or expand them all when they all are.
toggle_previews()
¶
Show the values on the canvas's nodes if they are hidden, else hide them.
Tile
¶
Bases: Column
A component's view in a frame with a title bar.
The title bar holds an optional title and subtitle (FlowDash's own
tiles set no subtitle), a status chip and
the tile actions: Inspect, Expand (a full-screen dialog of the tile) and
a More menu with what has no button of its own (Show in editor, How was
this made?), which
is left out when it would be empty. :meth:set_style chooses whether
the tile is a framed card and whether it shows its title. Only a titled
card gives the title bar a row; otherwise the bar floats over the
tile's top-right corner on hover or keyboard focus and takes no space.
Callers choose which actions apply with :meth:set_actions and react to
them through on_inspect, on_show_in_editor and on_how_made.
title may be a reactive expression; label is the plain name the
actions' accessible names and the expand dialog use. view is the
wrapped view; the tile only moves it into the expand dialog and back, so
it is never re-created. An untitled tile keeps room above its view for
the notes floating in its corner, unless it is compact, like a KPI,
whose short centred view they do not cover.
body = pn.Column(view, margin=(0, 8, 8, 8), sizing_mode='stretch_both')
instance-attribute
¶
compact = compact
instance-attribute
¶
expand_button = pmui.IconButton(icon='open_in_full', description=f'Expand {label}', size='small', margin=0, align='center', sx=_ACTION_SX)
instance-attribute
¶
expand_dialog = pmui.Dialog(title=label, full_screen=True, show_close_button=True, close_on_click=True, open=False)
instance-attribute
¶
expanded
property
¶
filter_notes = pn.FlexBox(margin=0, gap=f'{_NOTE_GAP}px', flex_wrap='nowrap', align_items='center', align='center', visible=False, styles={'flex': 'none'}, stylesheets=[_NOTES_CSS], css_classes=['flowdash-tile-filters'])
instance-attribute
¶
framed
property
¶
header = pn.Row(self.titles, self.status, self.inspect_button, self.expand_button, self.more_menu, css_classes=['flowdash-tile-header'], margin=(10, 8, 6, 16), sizing_mode='stretch_width')
instance-attribute
¶
inspect_button = pmui.IconButton(icon='data_object', description=f'Inspect data for {label}', size='small', margin=0, align='center', visible=False, sx=_ACTION_SX)
instance-attribute
¶
more_menu = pmui.MenuButton(label='', icon='more_vert', description=f'More for {label}', items=[], size='small', variant='text', margin=0, align='center', visible=False, sx=_MORE_SX)
instance-attribute
¶
on_how_made = on_how_made
instance-attribute
¶
on_inspect = on_inspect
instance-attribute
¶
on_node_action = on_node_action
instance-attribute
¶
on_show_in_editor = on_show_in_editor
instance-attribute
¶
shown
property
¶
Whether the tile wraps its view rather than the stand-in of a hidden tile.
stale_mark = pmui.Typography('', variant='caption', margin=0, visible=False, sx={**status_chip_sx('warning'), 'bgcolor': 'color-mix(in srgb, var(--mui-palette-warning-main) 16%, var(--mui-palette-background-paper, #fff))'}, css_classes=['flowdash-tile-stale-mark'])
instance-attribute
¶
status = pmui.Typography('', variant='caption', margin=(0, 4), align='center', visible=False, css_classes=['flowdash-tile-status'])
instance-attribute
¶
subtitle = text_typography(subtitle or '', variant='caption', margin=0, visible=False, sx={'color': 'text.secondary', 'display': 'block', **_ELLIPSIS})
instance-attribute
¶
title = text_typography(title, variant='subtitle1', margin=0, visible=False, sx={'fontWeight': 500, 'lineHeight': 1.4, **_ELLIPSIS})
instance-attribute
¶
titles = pn.Column(self.title, self.subtitle, margin=0, sizing_mode='stretch_width')
instance-attribute
¶
view = view
instance-attribute
¶
expand(_event=None)
¶
Show the tile's view in a full-screen dialog until the dialog closes.
set_actions(*, inspect, show_in_editor, how_made=False, node_actions=())
¶
Offer Inspect, Show in editor and How was this made? only where they apply to the current viewer.
node_actions are the registered node actions offered, as (key,
label, icon), which go to the More menu and call on_node_action
with their key.
set_chrome(shown)
¶
Show the frame and actions (view mode), or leave both to the grid (arranging).
set_filters(chips=(), hint='', detail='')
¶
Note the Filter nodes feeding the view, (instance_id, title), and hint.
The filters share one filter icon, which names them on hover.
hint says which active global filters do not reach the view, e.g. "Not filtered by State", and detail why, as its tooltip.
set_provenance(provenance, warning=None)
¶
Show where the view's numbers come from as a quiet chip, and a warning about them, before its filter notes.
provenance is the :class:~panel_flowdash.node_actions.Provenance
label shown now (in edit mode, or as the editor's
provenance_labels says) or None, and warning the warning about
the numbers, which is always shown, as a :class:WarningNote, or None.
set_stale(stale)
¶
Mark the tile while its result does not match its spec: a "draft" not run, or "running".
set_status(status)
¶
Show the 'failed', 'waiting' or 'pending' chip, or none.
set_style(*, framed, titled)
¶
Draw the tile as a framed card or unframed, with or without its title.
set_view(view)
¶
Wrap view in place of the current view, e.g. a hidden tile's once it is shown.
TileDrag
¶
Bases: JSComponent
Watches drags of tiles and of the components beside the grid, and reports drops.
tiles and controls map the keys the dragged elements carry on the
page to {"id": instance id, "fits": bool}, fits saying whether the
component may leave the grid. A drop calls on_move(instance_id, area,
before), before being the instance id the component goes in front of
or None for last; a drop refused because the component does not fit
calls on_refuse(instance_id, area). A tile dropped beside the grid
calls on_release(instance_id) first, as the pointer is released and
before the grid sends the layout the drag ended with.
areas = param.List(default=[], doc='The areas beside the grid a component can be dropped in.')
class-attribute
instance-attribute
¶
controls = param.Dict(default={}, doc="The components beside the grid, by their handle's key.")
class-attribute
instance-attribute
¶
enabled = param.Boolean(default=False, doc='Whether drags are watched.')
class-attribute
instance-attribute
¶
grid = param.String(default='', doc="The CSS class of the editor's tile grid.")
class-attribute
instance-attribute
¶
labels = param.Dict(default={'top': 'Top bar', 'sidebar': 'Sidebar', 'grid': 'Grid'}, doc='The names drop targets are labelled with.')
class-attribute
instance-attribute
¶
refusal = param.String(default=REFUSAL, doc='The hint on targets a component may not go to.')
class-attribute
instance-attribute
¶
tiles = param.Dict(default={}, doc='The tiles on the grid, by the key class they carry.')
class-attribute
instance-attribute
¶
uid = param.String(default='', doc='The suffix of the CSS classes of the areas beside the grid.')
class-attribute
instance-attribute
¶
TransformEditor
¶
Bases: Viewer
Edit the transform steps of one edge, showing the shape of the value between steps.
Checking the steps runs the whole transform on the source value, so a change
of that value is only rendered while the editor is shown (see show).
Hidden, it catches up when shown again, but still re-checks the issue
the canvas and status bar report while it holds a draft or an issue.
has_draft
property
¶
Whether the steps shown were edited away from the transform they started from.
issue = param.String(default=None, allow_None=True, doc="What keeps the edited steps from being applied, e.g. 'Sort step', or None.")
class-attribute
instance-attribute
¶
message = param.String(default=None, allow_None=True, doc='Why, in a sentence.')
class-attribute
instance-attribute
¶
dispose()
¶
Stop following the source port, once the edge is gone.
hide()
¶
Stop rendering source changes until shown again.
reset()
¶
Show the transform applied to the edge, dropping any draft.
show()
¶
Follow the source value, rendering a change missed while hidden.
sync()
¶
Reload the applied transform if it changed, unless a draft is being edited.
TransformOffer
¶
Bases: Viewer
A dialog connecting a table or series output to a number input through steps.
dialog = pmui.Dialog(objects=[self._message, self._column, self._column_text, self._how, self._result], actions=[self._cancel, self._confirm], title='Connect with a transform', open=False, css_classes=['fd-transform-offer'])
instance-attribute
¶
mapping
property
¶
The connection offered, while the dialog is open.
close()
¶
Close the dialog without connecting.
confirm()
¶
Create the connection with the chosen steps and close, or show why it failed.
offer(mapping, kind)
¶
Open the dialog for connecting mapping through steps of kind, see :func:bridge_kind.
steps()
¶
Return the transform steps the dialog's choices make.
TurnLog
¶
The turns of the dashboard in an editor, and those still open to more edits.
A person's turn stays open until :meth:end_user_turn or an edit of the
agent; an agent's turn stays open for the rest of its run, so an edit the
person makes while the agent works becomes a turn of its own between two
edits of the agent's turn.
turns = []
instance-attribute
¶
add_pending(question)
¶
Add a planned turn asking question, not run yet, and return it.
claim_pending(turn_id, run)
¶
Make the pending turn turn_id the turn of request run's next edits, and return it.
The request's turn so far is closed. The pending turn stays pending until the request's first edit, which makes it the request's turn: the nodes it creates get it as their origin, so its question in the report shows them as its answer.
Raises:
| Type | Description |
|---|---|
TurnError
|
If no pending turn has the id turn_id. |
current()
¶
Return the turn an edit made now belongs to, opening it if needed.
discard(run)
¶
Drop the open turn of request run, e.g. once its edits were all taken back.
A pending turn the request took over is pending again, as it was.
drop_pending(ids)
¶
Drop the pending turns ids; turns that ran are kept.
end_agent_turns(run=None)
¶
Close the agent's open turns, or only request run's, so the next request's edits open a new one.
A pending turn the request claimed but made no edit for stays pending.
end_user_turn()
¶
Close the person's open turn, so their next edit opens a new one.
prune(keep)
¶
Drop the oldest closed turns not in keep until at most MAX_TURNS are left.
record(*labels)
¶
Note an edit, described by labels, in the turn it belongs to, and return that turn.
reset(turns, *, keep_open=False)
¶
Replace the turns, e.g. with a loaded dashboard's; keep_open keeps the open ones open.
snapshot()
¶
Return copies of the turns, for a model to keep.
UnresolvedEdge
dataclass
¶
UnshownView
¶
Bases: Spacer
The stand-in for the view of a hidden tile until it is shown, see FlowDash._unshown_view.
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.
_AskRow
¶
Bases: Row
The row holding the open surface, with the Ask dock on its left.
Panel adds every child's width to a row's minimum width, hidden or not, so the dock's would keep the canvas wider than the window in edit mode, where Ask is never docked, and lay a phone's canvas out wider than the screen until the server knows it is a phone. Where the dock shows, in view mode, the row narrows to the window anyway, so only the surface sets its minimum.
_EditorCall
¶
Call a method of an editor without keeping the editor alive.
Cards and other views that live as long as the node state hold these instead of bound methods, so a closed session's editor can be freed.
_FailureLog
¶
Bases: dict
The exception of each output of a node whose latest run failed, telling changed when that starts or ends.
pop(name, *default)
¶
_Outlet
¶
Bases: Parameterized
Holds a single async output reference of a component, apart from its node state.
value = param.Parameter(allow_refs=True)
class-attribute
instance-attribute
¶
_ReadOnlyEditorError
¶
Bases: AssetStoreError, RuntimeError
_ViewRuns
¶
The steps of the runs of an async __panel__, keeping the latest run's subscriptions.
A __panel__ that declares param.depends runs again whenever its
dependencies change, and its new view replaces the old one. Starting a run
releases what the previous run subscribed to, and a run that was superseded
while still awaiting releases its later subscriptions right away.
_add_all(add_many, add_one, items)
¶
Add items in one call, or one by one, skipping the invalid ones, if that fails.
_agent_source()
¶
Return the agent request the calling code edits for, or None for the person's own edits.
_align_layout(keyed, instance_ids)
¶
Build the positional TileGrid layout for tiles instance_ids from keyed entries.
Tiles without an entry get an empty one, and the visual index values are
renumbered so that entries of removed tiles leave no gaps in the order.
_apply_each(instance, values)
¶
Set values on instance one by one after a joint update failed, yielding each error.
The joint update stops dispatching at the first error, and may already have set the values that come before it, so setting those again would not notify their watchers. Those are triggered instead.
_bounded(value, low, high)
¶
_config_snapshot(config)
¶
Return a copy of a node's config to tell a later change by, or a value never equal to another if it cannot be copied.
_copy_graph(source, target)
¶
Give target the nodes, edges, turns, groups and tiles of source.
_creating(editor_ref, instance_id, wiring, reason=None)
¶
Run one step of an async component body as part of creating instance_id.
Like synchronous creation, current_dashboard returns the editor and every
subscription the step makes is released with the component.
_current(editor_ref)
¶
Make current_dashboard return the editor while one of its components' outputs runs.
_display_rank(entries, item, position)
¶
Order a placed item by its layout index, then those without one by placement.
_dispose_on_session_end(editor_ref, session_context)
¶
_drop_repeated_ids(model)
¶
Keep only the first item of model with each instance id, returning how many were dropped.
_fills_tile(view, lazy=None)
¶
Whether view takes its height from its tile rather than giving the tile one.
The grid sizes a tile without a height to its content, so such a view, e.g.
a Vega-Lite chart sized to its container, would leave the tile a header
tall and draw nothing. A layout fills its tile if one of its views does,
and a pane that renders another object, e.g. a ParamMethod, if what it
rendered does. Those panes are appended to lazy, since what they render
can change, as is a HoloViews pane whose plot has not said it is
responsive, e.g. a rasterized image that has drawn nothing yet, or any
plot that leaves responsive unset. Text and spacers have a height of
their own.
_flowdash_metadata(p)
¶
Return the "flowdash" namespace of a Parameter's metadata, or an empty dict.
_has_selection(selection)
¶
_hidden_everywhere(instance_id, entries, config)
¶
Whether a tile is hidden in the base layout and in every band's own layout.
TileGrid shows a band's layout in place of the base one, and a tile without an entry there is shown.
_is_table(value)
¶
_is_title(item)
¶
Whether a placed item is a heading of the dashboard's title size.
_key_layout(layout, instance_ids)
¶
Tag the entries of a TileGrid layout with the instance id of their tile.
_key_saved_layout(layout, legacy_ids)
¶
Key a persisted layout, mapping untagged entries saved by older versions by position.
_next_tick(callback)
¶
Call callback once the session's current event is handled; outside a session, never.
_no_editor(data, schema, *, id, type, on_patch)
¶
_output_failure_changed(editor_ref, node_id, port, failed)
¶
Tell the components fed by output port of node_id that it started or stopped failing.
A component opts in with __flowdash_input_failed__(input, failed); without
propagate_failures its input otherwise keeps the last value unannounced.
_placing(reason)
¶
Create the nodes placed inside the block for reason, unless an enclosing block set one.
_plain_integer_formatters(df)
¶
Show integer columns below 10,000 without thousands separators, as cards do (years, ids).
_popout_chart(payload)
¶
Render a chart preview payload in full, from its Vega-Lite spec and rows.
_release_refs(state)
¶
Replace every reference a state follows with the value it currently resolves to.
_same_signature(before, after)
¶
Whether two node signatures are equal; a config value that cannot be compared, e.g. a DataFrame, differs.
_size_layout(layout, specs, reference_width, fills=())
¶
Apply the size hints of the tiles' specs to a positional TileGrid layout.
A tile without an entry starts at its default_size, and every tile's size
is kept within its min_size and max_size. Hints are pixels; layout
widths are percentages of reference_width, heights are pixels. A tile
whose view fills it and that has no height yet starts at :data:FILL_HEIGHT.
_unset(config_state, key)
¶
Whether the config field key still holds its declared default.
_warn_validation_unavailable()
cached
¶
_without_graph(model)
¶
Return a copy of model with no nodes, edges, turns, groups or tiles.
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
|
band_labels(breakpoints)
¶
Return the labels TileGrid gives the bands of breakpoints, narrowest first.
base_band(breakpoints, width)
¶
Return the band whose layout is layout itself, given the grid's reference_width.
bind_document(doc, values)
¶
Return a copy of the YAML document doc with values written into their parameters' fields.
Each value is read as its parameter's type first (see :func:coerce),
so values given as text, e.g. on a command line, can be passed as is.
Nothing is computed and no contract is checked; see :func:check_contracts.
Raises:
| Type | Description |
|---|---|
ParameterError
|
If a name is not a parameter of doc, a value is not of its
parameter's type, or a parameter's node or field does not exist. The
key is |
bottom_sheet(title, css_class, height)
¶
Return a modal bottom sheet with title and a close button, and the column it holds.
bridge_kind(source_type, target_type)
¶
Return how transform steps can turn an output of source_type into target_type.
"column" for a DataFrame, or a type registered as one of its subtypes,
feeding a number (pick a column, then aggregate it), "aggregate" for a
Series feeding a number, or None if no steps bridge the two.
broken_edges_panel(lines, hidden, on_discard)
¶
Build the listing of saved edges that could not be wired, with a discard action.
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
|
call_provenance_hook(instance, via=())
¶
Return what instance.__flowdash_provenance__ reports, or None if it has no hook or it fails.
via is passed on to a hook that takes it, see :mod:panel_flowdash.node_actions.
card_height(n_inputs, n_outputs, *, extra_rows=0)
¶
Return the height of an expanded card without a preview.
change_labels(old, new)
¶
Describe the change between two dashboard YAML documents as turn summary labels.
Unlike the diff shown to the person, the labels name what changed but not the values, so a summary never repeats a config value such as a query, and edges by their nodes alone, so it never names the hidden port of a node someone may not use.
changes_node(turn, name)
¶
Whether turn's summary says it changed the node called name, beyond adding it.
A summary names at most a few changes, so a turn that changed many nodes may leave this one out.
check_contracts(doc, names, lookup, context=None)
¶
Check the parameters names of the YAML document doc, values bound, against their contracts.
lookup returns the :class:ParameterContract of a component id, or
None. A parameter without a recorded expects or without a contract
is not checked. A contract that raises fails its parameter with the
error as the problem. Returns the problems, warnings included, of the
parameters that have any.
check_filters(value)
¶
Return a checked copy of a dashboard's filters, raising :class:FilterError if malformed.
check_group_id(group_id)
¶
Raise :class:GroupError unless group_id can name a group.
check_literal(port, value)
¶
Return why value cannot be the literal of port, or None if it can.
check_name(name)
¶
check_report(value)
¶
Return a checked copy of a report, raising :class:ReportError if malformed.
close_dialog()
¶
Close the session's page dialog. Does nothing when it is not open.
component_role(entry, inputs, outputs, *, ports_known=True)
¶
Return the role of a component, one of :data:ROLES.
A source, transform, view or widget tag decides it.
Otherwise built-in widgets are widgets, a component without outputs is a
view, one with outputs but no inputs a data source, and the rest are
transforms. A component whose ports are not known yet is other.
compute_expects(doc, names, lookup, context=None)
¶
Return what the contracts of the parameters names of doc record now.
Parameters whose contract returns None, or raises, are left out, so they keep what they recorded before.
config_json_schema(cls)
¶
Return the JSON schema of the config of a node of a component, for the canvas.
The canvas validates the data of every node placed against it, so every
field maps to a valid property, see :func:_field_schema.
config_value(parameter, value)
¶
Return value in the form parameter takes, e.g. a list read from JSON as a tuple.
connection_type(port)
¶
Return the type one edge into port must carry.
Each edge into a list input delivers one item, so the item type applies:
the declared type of a multiple input that is not itself a list, or
the item_type of a List Parameter when it names a registered port
type. A plain List input says nothing about its items and accepts
anything, as does an item_type of a class with no registered port
type, whose subclasses only the check of each value can tell apart.
copy_context(context)
¶
Copy an editor's context one level down, so dicts, lists and sets in it are not shared.
copy_groups(groups)
¶
Return groups as copies, so changing them changes no group of an editor.
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.
dataframe_preview(frame, filename)
¶
Columns with their dtypes, the first rows and export actions; never the whole frame.
declared_outputs(obj)
¶
Return param.outputs() of a Viewer or Viewable class or instance.
A Viewable only declares outputs on its own classes. Those are read from
the class dicts, since param.outputs() reads every attribute of the
Panel classes too, and some of those (an ESM component's bundle paths)
raise when read off a component defined outside a module file.
describe_value(value)
¶
Return the type name and a short shape of value, without walking its contents.
editor_presets(editor, entry)
¶
Return the presets of entry for editor, asking its hook again only when the context changes.
A hook that failed is asked again after PRESET_RETRY seconds.
error_text(exc)
¶
Return an exception's message with its credentials masked, to show a user or an agent.
escape_markdown(text)
¶
Escape text so a Markdown pane shows it verbatim, without HTML, formatting or math.
exception_text(exc)
¶
Describe an exception as Type: message, or a refusal (see is_restricted) neutrally.
The neutral text names nothing the viewer may not see; the server log keeps the error.
export_filename(title, extension='json')
¶
File name a downloaded dashboard titled title is saved under, as JSON or YAML.
export_model(model, restricted=(), *, questions=True)
¶
Serialize model as a dashboard file, without its identity fields.
The file keeps the dashboard's turns and each item's origin, so a dashboard that is imported elsewhere still shows how it was built.
The items whose instance ids are in restricted keep only their id and position, and the edges touching them are left out, so the file reveals neither their component, config nor ports.
With questions False the turns leave out what was asked of the agent, for a file shared beyond the people who asked.
export_text(data, extension='json', restricted_edges=())
¶
Return a dashboard export as the text of a JSON or YAML file.
failure_text(error)
¶
Describe a failure as Type: message.
failures(problems)
¶
Return the problems that refuse a value, leaving out warnings.
field_path(path)
¶
Split a parameter's field into its keys, numbers for list items.
Raises :class:ParameterError unless it is a dotted path of names and
numbers that starts with a name, e.g. spec.layers.0.mark.
fold_button()
¶
Return the button folding the palette, for the palette's header.
fullscreen_toolbar(health_chip)
¶
Return the items shown over a dashboard in full screen: its health and an exit button.
The chip follows the text and style of the bar's health_chip. The dashboard's title is not shown; it names the toolbar for screen readers.
gate_view(view, state, inputs, message=None)
¶
Show a placeholder instead of view while a blocking input of state is None.
Blocking follows :func:~panel_flowdash.session_state.check_requirements.
Returns the view to display and a callable that stops it following
state, or view itself and None when no input can block. Otherwise
view is built once and only its container is hidden, so toggling neither
re-renders the view nor recreates its models.
get_field(config, path)
¶
Return the value at path in config, or raise :class:ParameterError.
group_class(inputs, outputs)
¶
Return the CSS class that sizes a collapsed group's frame for its port rows.
group_id_of(node_id)
¶
Return the group a canvas node id draws, or None for a component's node.
group_node_data(group, inputs, outputs)
¶
Return the canvas node data that draws group with its ports.
handle_map ties each inner port to the group handle that stands in for
it while the group is collapsed, so connections are drawn to it and a
connection made to it reaches every inner port it maps.
group_node_id(group_id)
¶
Return the id of the canvas node that draws group group_id.
group_ports(members, edges, port_info=None)
¶
Return the inputs and outputs of a group from the connections crossing its border.
edges are (source, source_port, target, target_port) tuples by
instance id. port_info(instance_id, port, direction) returns the label
and type of an inner port, which the group's port takes over.
heading(text)
¶
Return a section heading for the sheet.
held_table_names(value)
¶
Return the table names a source already holds, never calling get_tables(), which may query it.
hide_on_phone(css_class)
¶
Return a layout's stylesheet hiding its children with css_class on a phone.
For the editor's side panels, which the phone's bottom sheets replace. CSS,
so a phone never shows them before the server knows the window's width. The
rule belongs to the layout holding them, not to their own shadow roots:
WebKit can leave a host hidden by an @media :host rule after the
window widens again, once the styles in its shadow root change.
holoviews_pane(value, **params)
¶
Return a new pane drawing a HoloViews object, or None for any other value.
A HoloViews element can be drawn again wherever it is shown, unlike a
Panel or Bokeh object, which is shown in one place at a time. A
stream-driven DynamicMap is drawn as a static copy of its last frame.
insert_block(report, index, block)
¶
Return a copy of report with block inserted before the block at index, or last for None.
inspector_sheet()
¶
Return the inspector's sheet.
Persistent, without a backdrop, so the canvas above it still takes a tap on another node, which the sheet then shows.
is_async(obj)
¶
Whether obj is a coroutine or async generator function.
is_async_gen(obj)
¶
Whether obj is an async generator function, seen through decorators.
param.output and functools.wraps return sync wrappers around async
functions, which the plain :mod:inspect predicates report as sync, so
unwrap before asking.
is_dataframe(value)
¶
Whether value is a pandas DataFrame, without importing pandas for others.
is_failure(value)
¶
Whether value is a failure carried along an edge as a param.ReactiveError.
is_group_node(node)
¶
Whether a canvas node draws a group rather than a component.
is_plain(value)
¶
Whether value is plain data whose text is the data itself, not an object's internals.
is_view_class(app)
¶
Whether app is a Panel Viewer or Viewable class, whose params are its ports.
label_for(labels)
¶
Return the history label for an edit's turn labels.
make_inspect_sheet()
¶
Create the persistent right sheet: beside the tiles on wide screens, full screen on phones.
map_filters(filters, nodes)
¶
Return filters with the views they exclude renamed by nodes, dropping views not in it.
map_report(report, nodes, groups, turns)
¶
Return report with its node references renamed by nodes, dropping what it cannot keep.
Blocks showing a node not in nodes, a group not in groups or a turn
not in turns are left out, and so is an origin naming no turn in
turns. Passing an identity mapping prunes a report to what a dashboard holds.
markdown_pane(object='', **params)
¶
Return a Markdown pane for FlowDash's own markup, with MathJax turned off in the browser.
Interpolate user or data text into object only through :func:escape_markdown.
missing_inputs(state, inputs)
¶
Return the labels of the blocking inputs of state that are still None.
node_actions()
¶
Return the registered actions, in the order they were registered.
node_card(spec, state, failures, wiring, instance=None, show_preview=False, *, instance_id=None, preview_output=None, collapsed=False, on_layout=None, pending=None)
¶
Build the card of a placed component, following its state until wiring is released.
pending says while the node's value is being computed.
node_preview_value(spec, state, instance=None, output=None)
¶
Return (port_name, raw_value) for the node's currently previewed output (for pop-out).
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. |
notify(severity, message, *, duration=3000, enabled=True)
¶
Emit a Panel notification, falling back to the logger.
pn.state.notifications is None outside a served session (a plain
script, a test, or a notebook without the notifications extension), so
calling it unguarded raises. Embedders can also opt out entirely by passing
enabled=False.
object_label(value)
¶
Name value by its type, and a Parameterized by its own name too, e.g. FileSource ยท turbines.
open_dialog(title, content, *, width='sm', full_width=False)
¶
Show content in the session's page dialog, replacing whatever it shows.
The user can dismiss the dialog with its close button, the Escape key or a
click outside it. Use :func:close_dialog to dismiss it from code.
Outside a served session there is nowhere to show a dialog, so a warning is
logged and nothing happens, as with :func:notify.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Heading of the dialog. |
required |
content
|
Any
|
Anything Panel can render. |
required |
width
|
str | bool
|
Maximum width of the dialog, one of |
'sm'
|
full_width
|
bool
|
Whether the dialog takes its whole maximum width rather than its content's. |
False
|
output_section(*, status, rows, preview, extra=None)
¶
Describe one output: its status, facts about it and a preview of the value.
page_dialog()
¶
Return the dialog shared by every component of the current session.
The dialog is created on first use and released with the session. It must
be laid out once to be visible: FlowDashApp places it in every page
layout and FlowDash in its workspace, so only code that builds its own page
around a FlowDash(include_page_dialog=False) needs to call this.
Returns None outside a served session, where there is no document to
own it.
palette_entry(entry, spec=None, *, placed=False)
¶
Describe entry for the palette.
Components are imported lazily, so until spec exists the ports come from
the provides/requires declared on @register.
palette_items(entries, query='')
¶
MenuList items for the entries matching query, one group per role.
panel_call(app, /, **kwargs)
¶
Call a component callable and return a renderable view of the result.
Sync callables are called immediately. Async ones must not be: calling them
here would only produce an un-awaited coroutine, which pn.panel wraps as
a string. Instead they are deferred to a zero-argument closure that Panel's
ParamFunction awaits (or iterates, for async generators) on the event
loop when the view is rendered.
panel_viewer(instance, step=None, *, runs=None)
¶
Return a renderable view of a Viewer, awaiting an async __panel__.
A Viewable is its own view and is returned as it is.
pn.panel calls __panel__ synchronously, so an async def __panel__
would be wrapped un-awaited. ParamMethod handles both, and additionally
re-renders when the method declares param.depends. With step, every
run of an async __panel__ executes inside step(), as stepped
does for async function components. runs instead is called as each run
starts and returns the step for that run.
parameters_schema(parameters, values=None)
¶
Return the JSON Schema of a form that binds parameters, e.g. for panel-agents' SchemaForm.
Each parameter is a property titled by its name, described by its description, with the value it holds in values as its default.
parse_transform(steps)
¶
Build the steps of a stored transform, raising ValueError if one is invalid.
placeholder_card(placeholder)
¶
Build the card of a saved item that could not be placed.
placeholder_view(placeholder)
¶
Build what a placeholder node and tile display.
A component the viewer may not use reads as data they may not access does, without the warning a missing component gets.
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_label(port)
¶
Return the name a port is shown under.
port_tops(n_inputs, n_outputs, *, extra_rows=0)
¶
Return the vertical centres of stacked input and output rows, in px from the card top.
preset_entries(base, presets)
¶
Return palette entries for presets of the component base describes, with its ports.
provenance_line(provenance)
¶
Return the provenance of a node's numbers as a chip with its detail, for "How was this made?".
provenance_objects(turn, state, *, redacted, later=(), on_open=None, more=False)
¶
Show the agent request turn records and the turns that changed the node since.
The request is its span when state holds the run's steps, and what the turn says otherwise, e.g. after a reload, when a stored history holds the run's versions but none of its model or tool calls. redacted hides the request's content (the question, summary, arguments, results and messages) and keeps its shape. later lists the turns that changed the node after it was made, and more says more may have, since a summary names at most eight changes; on_open is offered for those whose steps state holds. Returns the objects and the span view among them, to release once closed.
reference_width(width, breakpoints)
¶
Return the grid width a layout's percentage widths are relative to, as TileGrid does.
release_links(component)
¶
Unlink every link :func:link_selection made for component.
report_blocks(editor)
¶
Return the report editor's dashboard reads as, authored or derived.
A dashboard with a report gives its blocks, without those referring to nodes, groups or turns it no longer has. One without derives them from the dashboard: a group block for each group with a shown node, where its first tile is, and a node block for every other shown tile, heading and Markdown tiles included, in the order of the top bar, the sidebar and the grid. Controls are not blocks; they are the report's filters.
report_turns(report)
¶
Return the ids of the turns a report refers to, by turn blocks and origins.
reserve_space(layout, sheet_open)
¶
Pad layout by the sheet's width on wide screens, so no tile sits under the sheet.
resolve_framed(tile, component, dashboard)
¶
Return whether a tile is framed: its own option, else its component's hint, else the dashboard's.
restricted_failures(failed)
¶
Return whether any of the failed inputs failed was refused access, see :func:is_restricted.
run_off_loop(work, then, doc)
¶
Call work on a worker thread, then pass its result to then on doc's event loop.
work should catch its own errors; one it raises is logged and then is
not called. Nothing is delivered once the session has ended. While work
runs, preview_off_loop returns True.
safe_frame(frame)
¶
Return a pandas frame whose objects that are not plain data show their text.
That covers object cells, index values, column labels and level names. The frame is copied only when one of them needs to change, so pass only the rows to show.
safe_repr(value)
¶
Return repr(value) for plain data and containers of it, labelling any other object.
sanitize_svg(raw_svg)
¶
Sanitize an SVG snippet to an allowlist of geometric SVG tags and attributes.
select_on_canvas(flow, node_id=None, edge_id=None)
¶
Select one node or edge on the canvas, or clear the selection.
sheet_button(icon, label, css_class)
¶
Return a floating button opening a bottom sheet, shown on phones only.
sheet_header(title, on_close, caption='Inspect data')
¶
Title the sheet with what is inspected, and offer to close it.
spec_fields(spec)
¶
Return the names of the config fields of spec edited in the code panel, in order.
These are its code fields and the dicts declaring a spec form, see
:func:~panel_flowdash.spec_settings.declared_settings: what the node
does, e.g. a query or a chart spec, rather than a setting of it.
stepped(app, step)
¶
Wrap a component callable so its asynchronous body runs step by step inside step().
Both the coroutine and the async generator forms are supported and the
wrapper keeps the form, so panel_call still defers it to render time.
A sync callable is called as is, but an awaitable or async generator it
returns runs inside step() too, wherever it is awaited.
stored_literal(value)
¶
Return value as a dashboard file stores it: tuples become lists.
strip_questions(turns)
¶
Return copies of exported turns without the questions asked in them.
suggest_name(name, names)
¶
summarize_transform(steps, max_length=40)
¶
Describe steps in a few words, or return None for an empty transform.
summarize_value(value, limit=60)
¶
Describe a port value in a few words, e.g. "72,357 rows, 29 columns".
summary_cut_short(turn)
¶
Whether turn's summary left changes out ("And 3 more changes"), so it may not name every node it changed.
text_alert(text, **params)
¶
Return a pmui.Alert whose message is text shown as literal text.
The message goes to the alert's own object: passed positionally a string
becomes a child pane chosen by pn.panel, which renders a string ending in
.png as a remote image and other strings as Markdown with math.
text_typography(text, **params)
¶
Return a pmui.Typography showing text, a string or a reactive one, as literal text.
unique_group_id(base, taken)
¶
Return a group id made from base that is not in taken.
unresolved_summary(items, edges)
¶
Phrase how many saved items and edges were kept unresolved, or None if none were.
value_status(value, failed)
¶
Return the status label of an output value.
with_failure_overlay(view, failures, describe)
¶
Wrap view so that it is covered by a message while any of its inputs is failed.
The wrapper takes over the view's sizing so that it lays out the same way in a tile or on the canvas. The message says in plain language that the tile could not update and which upstream components stopped it; the technical explanation from describe sits behind a Details disclosure.
without_filtered_nodes(filters, instance_ids)
¶
Return filters no longer excluding the nodes instance_ids.
without_nodes(report, instance_ids)
¶
Return report without the blocks showing the nodes instance_ids, or report if none do.