App Builder¶
panel_flowdash.app
¶
Application builder: scans a project directory and constructs the Panel app.
ACCESS_DENIED_ROUTE = '/access-denied'
module-attribute
¶
ADMIN_ROUTE = '/admin'
module-attribute
¶
AGENT_EXTRA_MISSING = "The FlowDash agent needs the agent extra: pip install 'panel-flowdash[agent]', plus the client of your model provider, e.g. 'pydantic-ai-slim[openai]'"
module-attribute
¶
AI_SECTION = 'ai'
module-attribute
¶
ASSET_ROUTE_PREFIX = '/asset/'
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
¶
CHATS_ROUTE = 'chats'
module-attribute
¶
CHATS_SECTION_ID = 'chats'
module-attribute
¶
CHAT_KIND = 'chat'
module-attribute
¶
COMPACT_BREAKPOINT = 1024
module-attribute
¶
COMPONENTS_ROUTE = '/components'
module-attribute
¶
DASHBOARD_EDIT_HEADER_SX = _hide_brand_below(_EDIT_BRAND_BREAKPOINT)
module-attribute
¶
DASHBOARD_HEADER_SX = _hide_brand_below(_BRAND_BREAKPOINT)
module-attribute
¶
DASHBOARD_KIND = 'dashboard'
module-attribute
¶
DASH_ROUTE_PREFIX = '/dash/'
module-attribute
¶
EDIT_COMPACT_BREAKPOINT = _WIDE_BREAKPOINT
module-attribute
¶
HEADER_SX = {'& .MuiToolbar-root': {'minHeight': '56px'}, '--fd-header-height': '61px', '& .header .MuiToolbar-root': {'gap': '4px'}, '& .header .title': {'fontSize': '1.25rem', 'fontWeight': 600}, '& .header .MuiToolbar-root > .MuiBox-root': {'minWidth': 0}, '& .header .MuiToolbar-root > .MuiBox-root:has(.title)': {'flexShrink': 0}, f'@media (max-width: {NARROW_BREAKPOINT - 0.05}px)': {'& .header .title': {'display': 'none'}}}
module-attribute
¶
HOME_ASK = 'ask'
module-attribute
¶
HOME_BROWSE = 'browse'
module-attribute
¶
HOME_PREFERENCE = 'home'
module-attribute
¶
ICON_ONLY_WHEN_COMPACT = icon_only_below(COMPACT_BREAKPOINT)
module-attribute
¶
KIOSK_QUERY = 'kiosk=1'
module-attribute
¶
LABEL_LINE_HEIGHT = 'calc(0.8125rem * 1.75)'
module-attribute
¶
LAUNCHER_ALIASES = ('/dashboards',)
module-attribute
¶
LAUNCHER_ROUTE = '/browse'
module-attribute
¶
LAUNCHER_ROUTES = (LAUNCHER_ROUTE, *LAUNCHER_ALIASES)
module-attribute
¶
OLD_SECTION_NAMES = {'dashboards': 'assets'}
module-attribute
¶
PASSIVE_TOOLTIP_CSS = '.MuiTooltip-popper { pointer-events: none !important; }'
module-attribute
¶
PROJECT_FILE = 'flowdash.yaml'
module-attribute
¶
REPORTS_ROUTE = 'reports'
module-attribute
¶
REPORTS_SECTION_ID = 'reports'
module-attribute
¶
REPORT_KIND = 'report'
module-attribute
¶
SCOPE_SETTING = 'data_scope'
module-attribute
¶
SETUP_SECTION = 'setup'
module-attribute
¶
TOOLTIP_KEYFRAMES = '@keyframes fd-tooltip-in { from { opacity: 0; } to { opacity: 1; } }'
module-attribute
¶
_COMPONENT_PALETTE_CARD_CSS = '\n:host {\n cursor: pointer;\n border-radius: 6px;\n transition: background-color 0.15s;\n}\n:host(:hover) {\n background-color: rgba(0, 114, 181, 0.08);\n}\n'
module-attribute
¶
_EDIT_HEADER_CLASS = 'fd-edit-header'
module-attribute
¶
_SETTINGS_PROJECTS = {}
module-attribute
¶
_TOGGLE_ICON_ONLY = f"\n .pa-toggle > span:not(.pa-badge) {{ display: none; }}\n .pa-toggle {{ padding: 6px; min-height: calc({LABEL_LINE_HEIGHT} + 12px); }}\n {tooltip_css('.pa-toggle{state}', 'attr(aria-label)', placement='left')}\n"
module-attribute
¶
_TOGGLE_ICON_ONLY_WHEN_COMPACT = f'\n{TOOLTIP_KEYFRAMES}\n@media (max-width: {COMPACT_BREAKPOINT - 0.05}px) {{ {_TOGGLE_ICON_ONLY} }}\n@media (max-width: {EDIT_COMPACT_BREAKPOINT - 0.05}px) {{\n :host(.{_EDIT_HEADER_CLASS}) {{ {_TOGGLE_ICON_ONLY} }}\n}}\n'
module-attribute
¶
logger = logging.getLogger('panel_flowdash')
module-attribute
¶
AdminPage
¶
Bases: Viewer
The admin view of a FlowDash app.
It lists every registered project file section that has a
settings_view and shows the selected one. A section whose view is a
SettingsForm gets the page's Save and Discard and the unsaved-changes
dot; any other view is shown as it is and saves on its own.
dirty = param.Boolean(default=False, doc='Whether a section has unsaved changes.')
class-attribute
instance-attribute
¶
project = project
instance-attribute
¶
section = param.String(default=None, allow_None=True, doc='The section shown.')
class-attribute
instance-attribute
¶
sections
property
¶
Return the sections listed, by name.
dirty_sections()
¶
Return the titles of the sections with unsaved changes.
discard(name=None)
¶
Put section name (the one shown by default) back to what is saved.
discard_all()
¶
Put every section back to what is saved.
save(name=None)
¶
Save section name (the one shown by default); False if it was rejected.
save_all()
¶
Save every section with unsaved changes; False if one was rejected.
select(name)
¶
Show section name, through the app's routing when it has one.
show(name)
¶
Show section name, or the first one when it is not listed.
view(name)
¶
Return the settings view of section name, building it the first time.
AdminTokenExchange
¶
Bases: JSComponent
Hands the admin token in the page's URL fragment to the server.
The fragment is removed from the address bar as soon as it is read, and the token is left out of Panel's log of the values the page sends.
token = param.String(default='', doc="The token the page's URL fragment carried.")
class-attribute
instance-attribute
¶
AgentSession
¶
Connects an agent to one user's FlowDashApp session.
The agent works through :class:~panel_flowdash.agent.live.LiveDashboardOps
with the signed-in user's rights, can run what the command palette offers,
and needs the user's approval to save, delete or share. Its chat, the
versions it publishes and the pending approvals are in a drawer docked to
the right of the page, opened from a button in the header.
With the editor's edit history on (FlowDash.history), the runner
shares the history's RunState, so the drawer's artifact view lists
every version of the dashboard, the person's edits and the agent's,
grouped by request, and its Undo, Redo and Revert buttons restore them
as the editor's undo does. With it off, each edit tool publishes a
version of the dashboard YAML, and applying an earlier or later version
loads it into the editor as an import.
actions = palette_actions(app, deps=deps)
instance-attribute
¶
app = app
instance-attribute
¶
chrome = SessionChrome(self)
instance-attribute
¶
drawer = AgentDrawer(self.runner, title='Assistant', variant='persistent', width=preferences.assistant_width, **bounds, on_apply=self.apply_version, redact_runs=editor.run_redacted, chat_params=chat_params)
instance-attribute
¶
edit_lock = AgentEditLock() if explore_agent is not None else None
instance-attribute
¶
entries = {entry.id: entry for entry in entries}
instance-attribute
¶
explorations = None
instance-attribute
¶
explore_runner = None
instance-attribute
¶
handover = AddHandover(self)
instance-attribute
¶
highlighter = ChangeHighlighter(self)
instance-attribute
¶
history_notice = pmui.Alert(text_typography('', variant='body2', margin=0), severity='warning', variant='outlined', visible=False, margin=(8, 12, 0, 12))
instance-attribute
¶
ledger = ledger
instance-attribute
¶
ops = LiveDashboardOps(app)
instance-attribute
¶
runner = _SessionRunner(self, agent, editor.edit_history.state if editor.history else RunState(), deps=deps, approval_policy=self.approval_policy(), run_kwargs={'toolsets': [ActionToolset(self.actions)] if app.agent_palette else [], **settings})
instance-attribute
¶
runners
property
¶
The session's runners: the drawer's, then the Explore view's if it has an agent.
starters = StarterQuestions(self)
instance-attribute
¶
wait_notice = pmui.Alert(text_typography('', variant='body2', margin=0), severity='info', variant='outlined', visible=False, margin=(8, 12, 0, 12), css_classes=['flowdash-agent-waiting'])
instance-attribute
¶
add_answer(run, node)
async
¶
Add the answer node of Explore run run to the dashboard and return its name there.
It waits for a request of the assistant that is editing the dashboard, and is one turn of run and one version of the history.
apply_version(artifact, version)
async
¶
Make the open dashboard match a published version of it, as an import.
When the canvas has changes the agent did not publish, typically the user's own edits, the user confirms that applying the version drops them.
approval_policy()
¶
Return a new approval policy for the session's runners, from the app's rules as they are now.
It holds back the calls the app's settings, permissions and MCP
servers ask approval for, e.g. placing a sensitive component. A host
that changes those rules sets it on each of runners again.
dock(content)
¶
Return the page content with the agent's drawer docked to its right.
hand_over(name, surface='workspace', saved=None)
¶
Hand the dashboard node name, just added from Ask in view mode, to the assistant; see AddHandover.hand_over.
model_id(target)
¶
Return the id of the offered model a runner's model is, or None.
open_dashboard(dashboard_id)
¶
Open the dashboard dashboard_id, e.g. one a chat's answer was copied onto.
pending_done(turn_id)
¶
Note that the request asking the pending turn turn_id's question ended, or never started.
plan_request(target)
¶
Return the model id a request picked as target runs with, its run arguments and a note.
A model over its monthly limit, or over the person's own limit on it, gives way to its fallback, noted for the person; the id is None when the request is refused.
publish_agent_layout(run_id)
¶
Publish the tiles laid out when the agent's request run_id ended as its version.
The editor lays out the tiles a request adds once it ends (see
FlowDashDeps.start_request), after its last tool published the
dashboard. With the edit history on, that layout is part of the
request's own version instead.
publish_user_edits()
¶
Publish the open dashboard as a version if it changed since the agent last saw it.
Runs before every request to the agent, so the versions include the user's own edits and the agent is told about them. With the edit history on, the edit in progress is published instead, since every other edit already is.
record_spend(model_id, runner, run_id)
¶
Count the cost of run run_id against model_id's monthly spend and the person's.
run_pending(turn_id)
¶
Ask the assistant the question of the pending turn turn_id, as the turn's request.
The request is an ordinary one, shown in the drawer's chat, and its edits answer the turn, so the question's block in the report shows the nodes it builds. Only editors may run a question; one asked while the assistant is busy is sent once it is done. A question already asked and not yet answered is not asked again.
show_answer(name)
¶
Show the tiles, leaving the Explore view or the report, and mark the dashboard node name, e.g. an answer just added.
A standalone report has no tiles, so it stays on its document.
AppShell
¶
The chrome around a FlowDashApp page in the rail navigation variant.
It provides the top bar content placed in the page header (the breadcrumb
with a dashboard switcher, and :attr:search_slot) and the navigation
placed in the page's rail (:attr:rail_content): the rail buttons, and on
narrow screens, where the page moves its rail into the sidebar drawer, a
navigation list. The menu, theme and contextbar toggles are the page's own.
Call :meth:sync with the route after every navigation and
:meth:refresh when the dashboards or pages the user can see change.
breadcrumb = pn.Row(margin=0, align='center', min_width=0, stylesheets=[_SHRINK])
instance-attribute
¶
dashboard_actions = pn.Row(margin=0, align='center')
instance-attribute
¶
dashboard_lead = pn.Row(margin=(0, 0, 0, 4), align='center', min_width=0)
instance-attribute
¶
dashboard_switcher = pmui.MenuButton(label='', variant='text', size='small', margin=0, sx=_SWITCHER_SX, stylesheets=[_SHRINK_SWITCHER])
instance-attribute
¶
header
property
¶
Items for the page header, left to right.
nav_list = pn.Column(pmui.Typography(app.title, variant='h6', margin=(8, 16, 8, 16)), self._nav_list, sizing_mode='stretch_width', margin=0, stylesheets=[_HIDE_WHEN_WIDE])
instance-attribute
¶
rail = pmui.NavigationRail(items=[], stylesheets=[_HIDE_WHEN_NARROW, _RAIL_MENU_ALIGN_CSS], on_click=self._on_rail_click)
instance-attribute
¶
rail_content
property
¶
Items for the page rail: the rail buttons and, for narrow screens, the list.
search_slot = pn.Row(margin=0, align='center')
instance-attribute
¶
crumbs()
¶
Return the breadcrumb trail for the current route, the current page last.
rail_items()
¶
Return the rail destinations: a path to open, items for a menu or an href.
refresh(section_id=None)
¶
Rebuild the rail and switcher after sections, dashboards or pages changed.
sync(path, search=None)
¶
Point the breadcrumb and the active rail item at the route path (and optional search).
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()
¶
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.
AuthConfig
dataclass
¶
Project-level authorization configuration.
Loaded from the project's __init__.py by the serve command. All fields
are optional; the defaults reproduce the pre-auth behavior (allow by
default, groups read from the standard claim keys, no admin groups).
admin_groups = field(default_factory=frozenset)
class-attribute
instance-attribute
¶
default_allow = True
class-attribute
instance-attribute
¶
group_claims = DEFAULT_GROUP_CLAIMS
class-attribute
instance-attribute
¶
resolve_groups = None
class-attribute
instance-attribute
¶
user_groups = field(default_factory=dict)
class-attribute
instance-attribute
¶
from_module(module)
classmethod
¶
Build an :class:AuthConfig from names on a project __init__.
Reads group_claims, user_groups, resolve_groups,
admin_groups and default_allow if present, falling back to the
defaults otherwise. Missing module or names yield a default config.
BaseAssetStore
¶
Bases: ABC
The persistence interface the editor and app shell depend on.
Subclasses implement the six storage primitives below; the access-control and lookup helpers are backend-independent and inherited. Implement this to back dashboards with something other than SQLite.
To refuse a create, save, rename, delete or permission change, raise
:class:AssetStoreError with a message for the user.
Stores that detect concurrent edits keep a revision per dashboard: every
save stores dashboard.revision + 1 (see :func:check_revision), and a
save based on an older revision than the stored one raises
:class:AssetConflictError. A store that does not support revisions
simply ignores the field and saves last-writer-wins.
Models returned by listings may be shared with a backend cache, so callers treat them as read-only; single-dashboard lookups return private copies.
Set :attr:random_ids to False in a store whose ids can be guessed.
random_ids = True
class-attribute
instance-attribute
¶
Whether dashboard ids are random, so only someone given a link knows one.
The default :meth:create_asset makes random ids. A store whose ids
can be guessed (derived from titles, say) sets this to False, and the app
then answers a dashboard someone may not open exactly like a missing one,
rather than saying it exists and who owns it. Even with random ids, an id
a caller chose when saving (see :meth:guessable_id) is treated so.
all_assets(kind=None)
¶
Every stored dashboard regardless of owner, most recently updated first.
kind keeps only assets of that kind ("dashboard", "report"
or "chat"); None keeps every kind. No access check is applied: use
:meth:list_accessible for what a user may open. Some stores hand out
shared, cached models, so copy one (or load it with
:meth:load_asset) before changing it. Custom stores implement
:meth:_all_assets, not this method.
append_history(asset_id, record)
¶
Add a record to the end of a dashboard's edit history.
Does nothing when the dashboard is not stored, e.g. because it was deleted while an editor still had it open.
can_administer(identity, asset_id, admin_groups=frozenset())
¶
Whether identity may administer (rename/delete/share) the dashboard.
Administering includes editing, see :meth:can_edit.
can_administer_model(identity, dashboard, admin_groups=frozenset())
¶
Like :meth:can_administer, for a dashboard that is already loaded.
Listings use it to avoid loading every dashboard a second time.
Override this method, not :meth:can_administer, to change who may
administer a dashboard.
can_edit(identity, asset_id, admin_groups=frozenset())
¶
Whether identity may edit and save the dashboard's contents and settings.
can_edit_model(identity, dashboard, admin_groups=frozenset())
¶
Like :meth:can_edit, for a dashboard that is already loaded.
Administrators (see :meth:can_administer_model) may always edit;
anyone else needs an allow_edit_users/allow_edit_groups grant
on the dashboard's permission. Override this method, not
:meth:can_edit, to change who may edit a dashboard. A chat is
edited only by its owner, administrators included.
create_asset(user_id, title, kind=DASHBOARD_KIND)
¶
Create, persist and return a new empty dashboard (or chat or report, with kind).
A report starts with an empty document, so it never reads as the report a dashboard derives from its tiles.
delete_asset(user_id, asset_id)
abstractmethod
¶
Delete a dashboard owned by user_id. Returns whether one was removed.
delete_history(asset_id)
¶
Drop a dashboard's edit history.
find_by_id_or_title(ref, identity=None, *, default_allow=True)
¶
Resolve a dashboard by its id first, then by title.
Titles are only unique per user, so a title can match several
dashboards. Without identity (trusted code, such as
:meth:FlowDash.load) the most recently updated match is returned.
With identity, as when resolving the operator-configured home
dashboard, a dashboard the identity may not open is never returned.
The identity's own dashboard with that title wins. Otherwise a title
owned by a single user resolves to that user's most recently updated
dashboard, while a title owned by several users is ambiguous and
resolves to None (the app then shows the launcher) with an error
logged asking for the dashboard id. Picking one of them instead would
let any user take over everyone's home page by creating a dashboard
with the same title.
get_owner(asset_id)
¶
Return the owner (user_id) of a dashboard, or None if missing.
guessable_id(asset_id)
¶
Whether asset_id could be guessed rather than only learned from a link.
Only ids of the form :meth:create_asset makes count as random in
a store with :attr:random_ids. Any store saves whatever id a model
carries, so one chosen by the caller, like the slug an example seeds
its dashboards under, can be guessed. A store whose own ids look
different overrides this.
list_accessible(identity, *, default_allow=True, kind=DASHBOARD_KIND)
¶
List dashboards of kind the identity owns or has been granted access to.
Chats are left out unless kind is "chat" or None, and only
the identity's own chats are ever listed. Owned dashboards sort first
(both groups by recency), so a user's own dashboards stay visually
grouped ahead of ones shared with them.
list_assets(user_id, kind=DASHBOARD_KIND)
¶
Dashboards of kind owned by user_id, most recently updated first.
Pass kind="chat" for the user's chats, kind="report" for their
reports, or None for every kind.
load_asset(user_id, asset_id)
¶
Load a dashboard, but only if user_id owns it.
load_for_access(identity, asset_id, *, default_allow=True)
¶
Load a dashboard if identity is authorized, else None.
Returns None both when the dashboard does not exist and when access
is denied, so callers render a single "not found / denied" view.
load_history(asset_id)
¶
Return the edit history records of a dashboard, oldest first.
rename_asset(user_id, asset_id, new_title)
abstractmethod
¶
Retitle a dashboard owned by user_id. Returns whether one was updated.
replace_history(asset_id, records)
¶
Replace a dashboard's edit history, e.g. with what retention keeps of it.
rewrite_history(asset_id, rewrite)
¶
Replace a dashboard's history with what rewrite returns for it, and return that.
rewrite returns its argument itself when nothing changes, which writes nothing. Stores used by several sessions at once override this to read and write in one transaction, so no record appended meanwhile is lost.
save_asset(dashboard)
abstractmethod
¶
Insert or update a dashboard.
Stores that support revisions refuse a dashboard whose revision
is not the stored one with :class:AssetConflictError, as one
atomic check and write, and on success set dashboard.revision to
the stored revision. Renaming a dashboard or changing its permission
does not change its revision.
set_owner(asset_id, owner)
¶
Give a dashboard to owner. Returns whether one was updated.
Only the admin view calls it, after checking that the caller is an
admin. Like renaming, it does not change the dashboard's revision. A
store that cannot change owners raises :class:AssetStoreError,
as this default does.
set_permission(asset_id, permission)
abstractmethod
¶
Persist a new permission set on a dashboard. Returns success.
title_exists(user_id, title, exclude_id=None, kind=DASHBOARD_KIND)
¶
Check if a dashboard of kind with the given title already exists for this user.
ChatList
¶
ColorSchemeFollower
¶
Bases: JSComponent
Keeps a page's dark_theme on the browser's prefers-color-scheme.
Once the user toggles the theme, their pick wins: it is remembered in the browser's localStorage and used on later visits, and changes of the system scheme are ignored from then on.
choice = param.Selector(default=None, objects=[None, 'light', 'dark'], doc="The scheme the user picked, which wins over the system's.")
class-attribute
instance-attribute
¶
following
property
writable
¶
Whether the page's scheme is kept on the system's or the user's pick.
system_dark = param.Boolean(default=None, allow_None=True, doc='Whether the browser prefers a dark scheme.')
class-attribute
instance-attribute
¶
CommandPaletteController
¶
Builds the palette's items from an app's state and runs the chosen ones.
Every action goes through the same methods as the matching button, so permissions and the unsaved-changes dialog apply as they do there.
ask
property
writable
¶
Called with the query when the user asks the assistant from the palette.
palette = CommandPalette(on_open=self.items, on_command=self.run, margin=(0, 8), align='center')
instance-attribute
¶
install(app)
classmethod
¶
Place a palette in the app shell's search slot; None without a shell.
items()
¶
Return every entry the palette offers now, in group order.
run(command)
¶
Run the item or shortcut with id command, if it applies now.
ComponentGallery
¶
Bases: Viewer
Cards for every component the user may place, with filters and a detail panel.
Restricted components are left out, as in the editor palette. Usage counts
come from one listing of the dashboards the user can access, without
importing anything; :meth:load imports the components that do not
declare their ports, off the event loop, so their ports and roles can be
shown.
accepts = param.String(default=None, allow_None=True, doc='Only components taking this type.')
class-attribute
instance-attribute
¶
accepts_menu = pmui.MenuButton(label='Accepts', icon='input', variant='outlined', color='default', margin=0, sx={'textTransform': 'none', 'borderRadius': 4, 'color': 'text.primary'})
instance-attribute
¶
add_menu = pmui.MenuButton(label='Add to…', icon='add', variant='contained', margin=0, sx={'textTransform': 'none', 'borderRadius': 5})
instance-attribute
¶
close_button = pmui.IconButton(icon='close', description='Close details', size='small', margin=0)
instance-attribute
¶
detail = pmui.Paper(self._detail_body, elevation=0, margin=0, visible=False, sizing_mode='stretch_both', sx={'borderRadius': 0, 'borderLeft': 1, 'borderColor': 'divider'}, stylesheets=[_DETAIL_CSS], css_classes=['flowdash-gallery-detail'])
instance-attribute
¶
entries
property
¶
The listed components, in display order.
page_button = pmui.Button(label='Open as page', icon='open_in_new', variant='outlined', margin=0, sx={'textTransform': 'none', 'borderRadius': 5})
instance-attribute
¶
query = param.String(default='', doc='Search text.')
class-attribute
instance-attribute
¶
role = param.Selector(default='all', objects=list(ROLE_FILTERS), doc='Role filter.')
class-attribute
instance-attribute
¶
role_chips = {role: pmui.Chip(label=label, size='medium', margin=0, sx=_CHIP_SX, css_classes=[f'role-{role}']) for role, label in ROLE_FILTERS.items()}
instance-attribute
¶
search = pmui.TextInput(placeholder='Search by name, description, tag or port', variant='outlined', size='small', sizing_mode='stretch_width', min_width=200, max_width=340, margin=0, stylesheets=[':host { flex: 1 1 240px; }'], sx={'& .MuiOutlinedInput-root': {'borderRadius': 2, 'bgcolor': 'action.hover'}})
instance-attribute
¶
selected = param.String(default=None, allow_None=True, doc='Component shown in the details.')
class-attribute
instance-attribute
¶
used_in = pmui.MenuList(items=[], dense=True, margin=0, on_click=self._on_used_in)
instance-attribute
¶
add_to_dashboard(component_id, asset_id=None, *, kind=DASHBOARD_KIND)
async
¶
Open a dashboard or report in the editor with component_id placed on it.
Without asset_id a new dashboard, or report with kind, named after the component is created first. On a report the component is shown as a block at its end. The placement is left unsaved, like any edit. Returns the new instance id, or None if nothing was placed.
input_types()
¶
Map the input types of the listed components from canonical to display name.
load()
async
¶
Import the components whose ports are not declared, then show their ports.
Imports run off the event loop; components declaring provides or
requires on @register are listed without being imported.
refresh()
¶
Rebuild the entries and cards from the registry and one dashboard listing.
role_counts()
¶
Count matches per role for the current search and type filter, as the chips do.
visible_entries()
¶
Return the components passing the search, role and type filters.
ComponentSettingsUnavailable
¶
Bases: RuntimeError
The project file's component settings cannot be read and none were read from it before.
DashboardSettings
¶
Bases: Parameterized
Values that apply to a whole dashboard rather than to one component.
The editor keeps one instance in FlowDash.settings, fills it from the
loaded dashboard and writes its current values back on save. Subclass it to
add application-specific parameters and pass the subclass as
FlowDash(settings_class=...). Every parameter must hold a JSON
serializable value, since the stores persist settings as JSON.
controls_position = param.Selector(default='top', objects=['top', 'left'], label='Controls position', doc='\n Where the dashboard\'s controls (components registered with\n ``sidebar=True``) go: "top" in a slim row above the tiles, "left" in\n a collapsible panel beside them. Defaults to the editor\'s\n ``controls_position``.')
class-attribute
instance-attribute
¶
description = param.String(default='', label='Description', doc='\n A sentence or two on what the dashboard shows. Empty by default.')
class-attribute
instance-attribute
¶
header_layout = param.Selector(default='compact', objects=['compact', 'full'], label='Header layout', doc='\n How the dashboard\'s title, health and actions are laid out: "compact"\n on one line (in a FlowDashApp\'s top bar with the default navigation),\n "full" in a row of their own with a large title over the description,\n the health chip and when the dashboard was last refreshed. Defaults to\n the editor\'s ``header_layout``.')
class-attribute
instance-attribute
¶
node_previews = param.Boolean(default=False, label='Preview values on the canvas', doc="\n Whether each card on the wiring canvas previews its component's\n current value below its ports: the first rows of a table, a sparkline\n of numbers, a few items of a list. Without it a card summarizes the\n value in one line. Defaults to the editor's ``node_previews``.")
class-attribute
instance-attribute
¶
refresh_period = param.Number(default=0.0, bounds=(0, 86400), step=1, label='Refresh period (s)', doc='\n Seconds between automatic refreshes of the dashboard, which the editor\n announces by triggering its ``refresh`` event. 0 turns automatic\n refreshing off.')
class-attribute
instance-attribute
¶
tile_cards = param.Boolean(default=True, label='Show tiles as cards', doc="\n Whether each tile is drawn as a framed card with a bar for its status\n and actions. Without the card the tile renders as the component's own\n view, and its actions appear over its top-right corner on hover or\n keyboard focus.")
class-attribute
instance-attribute
¶
tile_titles = param.Boolean(default=False, label='Show tile titles', doc="\n Whether a card's bar also shows the tile's title and the component's\n description. Off by default, since most components show their own\n heading. Only applies while ``tile_cards`` is on.")
class-attribute
instance-attribute
¶
viewers_can_inspect = param.Boolean(default=False, label='Viewers can inspect outputs', doc='\n Whether people who may only view the dashboard get the inspect button\n on its tiles, when the editor has ``inspect_outputs`` on. Editors and\n administrators always get it. Leave it off when an output carries\n data a tile deliberately hides.')
class-attribute
instance-attribute
¶
DataAction
dataclass
¶
The Ask home's "add data" action, shown after the data chips.
Attributes:
| Name | Type | Description |
|---|---|---|
label |
str
|
What the action reads, e.g. |
action |
Callable[[FlowDashApp], Any] | str
|
A route or URL to open, or a callable given the session's
:class: |
icon |
str
|
Material icon name shown beside the label. |
DataChip
dataclass
¶
A piece of the project's data the Ask home offers to scope a question to.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
What the host knows the data by, e.g. |
label |
str
|
What the chip reads, e.g. |
group |
str | None
|
Chips of the same group are shown together under it, e.g. the source. |
detail |
str | None
|
A short note shown after the label, e.g. |
detail = None
class-attribute
instance-attribute
¶
group = None
class-attribute
instance-attribute
¶
id
instance-attribute
¶
label
instance-attribute
¶
coerce(value)
classmethod
¶
Return value, a chip or a mapping with id, label and group, as a chip.
to_dict()
¶
Return the chip as stored on a chat, without an empty group.
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.
FlowDashApp
¶
Bases: Viewer
FlowDash application: scans a project directory and serves its pages and components.
add_data = param.ClassSelector(class_=DataAction, default=None, doc='\n An "add data" action shown after the Ask home\'s data chips, e.g.\n uploading a file or connecting a source.')
class-attribute
instance-attribute
¶
admin_hidden_sections = param.List(default=[], item_type=str, doc="\n Project file section names hidden from the ``/admin`` navigation,\n e.g. when a host app places a section's settings view in its own page.")
class-attribute
instance-attribute
¶
admin_link = param.Boolean(default=True, doc="\n Whether the admin link can claim the admin view: ``/admin#token=...``\n with the server's admin token, which `flowdash serve` prints at\n startup while the project has no admin (see\n `panel_flowdash.admin.admin_path`). Whoever opens it is added to the\n project file's ``general.admins`` and is admin from then on: the\n signed-in user, or without sign-in the account that runs the server.\n Members of the `auth_config`'s ``admin_groups`` are admins either way.\n Without sign-in, admin rights (and the link) apply only to a browser\n on the machine that runs the server, see `trusted_proxies`.")
class-attribute
instance-attribute
¶
admin_section_redirects = param.Dict(default={}, doc='\n Map of ``/admin/<section>`` names to routes they moved to, e.g.\n ``{"mcp": "/data/integrations"}``. Listed sections are also hidden\n from the ``/admin`` sidebar, and opening ``/admin/<section>``\n redirects to the target route.')
class-attribute
instance-attribute
¶
agent = param.Parameter(default=None, doc='\n The AI agent that helps the signed-in user build and change\n dashboards, with that user\'s rights (needs ``panel-flowdash[agent]``).\n None gives the default agent when `agent_model` (or the\n ``FLOWDASH_AGENT_MODEL`` environment variable) names a model and no\n agent otherwise; True requires a model; a string is the default\n agent\'s model, e.g. ``"openai:gpt-5"``; False turns the agent off; a\n ``pydantic_ai.Agent`` built with `panel_flowdash.agent.create_agent`\n (or taking ``FlowDashDeps``) is used as is.')
class-attribute
instance-attribute
¶
agent_approval_rules = param.List(default=[], doc='\n More calls the agent needs the user\'s approval for, on top of saving,\n deleting, sharing and the sensitive components: tool names, or\n ``panel_agents.ApprovalRule`` objects for calls with particular\n arguments, e.g. ``ApprovalRule("run_command", when=lambda args:\n args["command"] == "action:refresh")``.')
class-attribute
instance-attribute
¶
agent_authorize = param.Callable(default=None, doc='\n Called with the signed-in `Identity` to decide whether this session\n gets the agent, e.g. to roll it out to some groups first. None offers\n it to everyone when an agent is configured.')
class-attribute
instance-attribute
¶
agent_model = param.String(default=None, allow_None=True, doc='\n The model of the default agent, e.g. ``"anthropic:<model>"`` or\n ``"openai:<model>"``. Defaults to the ``FLOWDASH_AGENT_MODEL``\n environment variable.')
class-attribute
instance-attribute
¶
agent_model_settings = param.Dict(default=None, allow_None=True, doc='\n pydantic-ai model settings for every request to the agent, e.g.\n ``{"temperature": 0}``, merged over the agent\'s own.')
class-attribute
instance-attribute
¶
agent_models = param.List(default=[], doc='\n Models the person using the assistant may pick from, in a small\n select below the chat\'s input that shows when there are two or\n more: pydantic-ai model strings such as ``"openai:<model>"``, dicts\n with an ``id`` and optional ``label`` and ``description`` (e.g. a\n cost hint), or ``panel_agents.ModelChoice`` objects. `agent_model`\n is the default and is offered first if it is not listed; without\n it the first model is the default. Defaults to the\n ``FLOWDASH_AGENT_MODELS`` environment variable, a comma-separated\n list of ``id`` or ``id=label``. Each id is offered once. A model\n whose provider package or API key is missing is listed disabled\n with the reason under its label. The pick applies from the next\n request and the browser remembers it.')
class-attribute
instance-attribute
¶
agent_palette = param.Boolean(default=True, doc='\n Whether the agent gets the command palette as tools (list_commands\n and run_command), e.g. to open a dashboard or refresh it. Turn it off\n for an agent with a narrow job, whose requests then do not carry\n their schemas.')
class-attribute
instance-attribute
¶
agent_placeholder_hint = param.Callable(default=None, doc="\n Called with a node's component id and its instance (None before it\n is built) for a `panel_flowdash.report.PlaceholderHint`: the input\n a node's data arrives on, followed first when the agent is pointed\n at the data a view shows, and a note for the agent. Consulted for\n components that do not declare one with\n ``__flowdash_placeholder_hint__``.")
class-attribute
instance-attribute
¶
agent_report_context = param.Callable(default=None, doc="\n Called with the session's `DashboardOps` for text the agent's\n get_report tool adds after FlowDash's own catalogue of the data\n placeholders can read, fenced as data, e.g. what the columns mean.\n Return None to add nothing.")
class-attribute
instance-attribute
¶
agent_sensitive_components = param.List(default=[], item_type=str, doc='\n Ids or glob patterns (``"Sources/*"``) of components whose config can\n reach outside the dashboard, such as a SQL source or one fetching a\n URL; former ids of a renamed component count too. The agent needs the\n user\'s approval to place one, preview or load YAML that places one,\n change its config or connect an edge into it.')
class-attribute
instance-attribute
¶
agent_session
property
¶
The session's assistant: its runners, drawer and approval policy; None without an agent.
agent_starters = param.Callable(default=None, doc="\n The questions the assistant offers when a new dashboard opens, with\n Ask on, until its first request. Called with a read-only\n `panel_flowdash.agent.StarterContext` (the person's identity, the\n dashboard, whether it is blank or from a template, and the tables\n they may place), it returns a list of question strings, or an\n awaitable of one, e.g. from a data catalogue's tables; at most three\n are shown. Returning None offers the default questions, and an empty\n list none. Without a hook the defaults ask about the data sources the\n person may place, by title (`panel_flowdash.agent.default_starter_questions`).")
class-attribute
instance-attribute
¶
auth_config = param.ClassSelector(class_=AuthConfig, doc='\n Project-level authorization configuration controlling group discovery,\n the admin groups and the default access policy.')
class-attribute
instance-attribute
¶
breakpoints = param.List(default=[768, 1200], doc='Responsive breakpoints for the tile grid.')
class-attribute
instance-attribute
¶
chats = param.Boolean(default=False, doc='\n Whether people\'s chats are listed: a Chats section in the rail lists\n the signed-in person\'s chats, newest first, and ``/chats`` lists them\n with Rename and Delete. A chat is a dashboard of kind ``"chat"``,\n private to its owner and left out of every dashboard listing; it\n opens on the Explore view.')
class-attribute
instance-attribute
¶
component_libraries = param.List(default=[], item_type=str, doc='\n Installed libraries whose components the editor offers next to the\n project\'s own: module names, e.g. ``"my_library"``, or\n ``"module:attribute"`` naming a mapping of component id to\n component, a list of components or a single one. A module offers\n its ``__flowdash_components__``, or else every object it exports\n that ``@register`` marks as a component. Their permissions and\n `authorize_component` apply as for the project\'s components. An id\n that the project, the built-in components or another library\n already uses raises a ``ComponentLibraryError``.')
class-attribute
instance-attribute
¶
configure_layout = param.Callable(default=None, doc='\n Optional callback invoked on every navigation with\n (app, content, route). Use it to set `app.sidebar` and\n `app.contextbar` for the page currently being served.')
class-attribute
instance-attribute
¶
contextbar = Children(default=[], doc='Items prepended to the contextbar.')
class-attribute
instance-attribute
¶
contextbar_open = param.Boolean(default=False, doc='Whether the contextbar is open.')
class-attribute
instance-attribute
¶
controls_position = param.Selector(default='top', objects=['top', 'left'], doc='\n Where a dashboard\'s controls (components registered with\n ``sidebar=True``) go unless the dashboard\'s settings say otherwise:\n "top" in a slim row above the tiles, "left" in a collapsible panel\n beside them. Passed to the editor, see `FlowDash.controls_position`.')
class-attribute
instance-attribute
¶
data_chips = param.Callable(default=None, doc="\n Lists the data the Ask home offers to ask about, as chips: called with\n the session's :class:`~panel_flowdash.auth.Identity`, it returns\n :class:`~panel_flowdash.home.DataChip` objects or mappings with\n ``id``, ``label`` and an optional ``group``. The chips picked when\n asking are stored on the chat as its scope, which the Explore agent\n is told (``FlowDashDeps.scope``); keeping to it is up to the host's\n tools. None offers no chips.")
class-attribute
instance-attribute
¶
data_overview = param.Callable(default=None, doc='\n Describes the project\'s data in the Ask home\'s "Your data" card:\n called with the session\'s :class:`~panel_flowdash.auth.Identity`, it\n returns anything Panel can show, e.g. the sources, their tables and\n columns, or an awaitable of it. It is called like\n ``suggest_questions``: a coroutine function is awaited on the\n session\'s event loop and a plain function runs on a worker thread,\n so a slow hook never holds up the page, and the card appears once it\n answers. None, a hook returning None or a hook that fails leaves the\n card out. The card is left out at phone width.')
class-attribute
instance-attribute
¶
default_allow
property
¶
Whether pages, components and data without access rules are open to everyone.
editor
property
¶
The session's dashboard editor, None until the app has built it.
editor_class = param.ClassSelector(class_=FlowDash, default=FlowDash, is_instance=False, doc="\n The `FlowDash` subclass instantiated as the app's editor. Read once at\n construction; the same editor is reused for every dashboard.")
class-attribute
instance-attribute
¶
editor_options = param.Dict(default={}, doc="\n Extra keyword arguments passed through to the `editor_class`\n constructor, e.g. `value_repr` or `popup_trigger`. Entries override\n the defaults the app derives from its own parameters (such as\n `breakpoints` and `notifications`), and `toolbar_extra` items are\n placed after the app's Share button. `authorize_component`,\n `authorize_dashboard`, `authorize_rename`, `components`, `store`, `user` and\n `include_page_dialog` are supplied\n by the app and raise a ValueError if given here.\n `dashboard`, `editable` and `read_only` are accepted but then managed\n by the app's routing and authorization. Read once at construction;\n the same editor is reused for every dashboard, so later changes have\n no effect.")
class-attribute
instance-attribute
¶
explore_agent = param.Parameter(default=None, doc="\n The AI agent the Explore view asks, which answers questions about\n the data behind the open dashboard, separately from the assistant\n in the drawer, which edits it. Each has its own runs, and the\n picked model is shared. None gives the default Explore agent on the\n assistant's model (see `panel_flowdash.agent.create_explore_agent`)\n whenever there is an assistant; False turns asking in the Explore\n view off, leaving it a read-only record of the dashboard's turns; a\n ``pydantic_ai.Agent`` taking ``FlowDashDeps`` is used as is.")
class-attribute
instance-attribute
¶
header_layout = param.Selector(default='compact', objects=['compact', 'full'], doc='\n How a dashboard\'s title, health and actions are laid out unless the\n dashboard\'s settings say otherwise. "compact" puts them in the top bar\n next to the breadcrumb (with the default "rail" navigation) and\n shrinks the search field to an icon; "full" shows them in a row of\n their own under the top bar, with a large title, the description and\n when the dashboard was last refreshed. Passed to the editor, see\n `FlowDash.header_layout`.')
class-attribute
instance-attribute
¶
home = param.Selector(default='launcher', objects=['launcher', 'explore'], doc='\n What ``/`` shows. ``"launcher"`` shows the launcher, Browse, which is\n also at ``/browse``. ``"explore"`` shows a switch between Ask, a\n composer that starts a chat about the project\'s data, and Browse; the\n choice each person made last is the one they land on. ``"explore"``\n turns `chats` on. A `home_dashboard` is shown on ``/`` instead of either.')
class-attribute
instance-attribute
¶
home_dashboard = param.String(default=None, doc="\n Dashboard shown on the homepage ('/'). Accepts a dashboard id or\n title. When unset, the homepage shows the dashboard grid launcher.")
class-attribute
instance-attribute
¶
identity
property
¶
Who the session is signed in as (see auth_config), None until the app has resolved it.
include_builtin_components = param.Boolean(default=True, doc='Include built-in widget components in the dashboard editor.')
class-attribute
instance-attribute
¶
is_admin
property
¶
Whether this session administers the project (cached per session).
Use this for showing or hiding UI. Before performing a privileged write
or admin action, re-check with :meth:still_admin, which re-reads the
project file and permissions.
mcp_secret_env_vars = param.List(default=None, allow_None=True, item_type=str, doc='\n Allowlist of glob patterns or variable names permitted in ``${VAR}``\n secret references inside ``flowdash.yaml``\'s ``mcp:`` section. When\n None, reads ``FLOWDASH_MCP_SECRET_ENV_VARS`` (comma-separated) or\n defaults to ``["FLOWDASH_MCP_*"]``.')
class-attribute
instance-attribute
¶
mcp_servers = param.Dict(default={}, doc='\n Programmatic MCP servers keyed by server id: each value is a\n `panel_flowdash.mcp.MCPServerConfig`, a config mapping or a ready-made\n pydantic-ai toolset / FastMCP server. Code-defined servers take\n precedence over identically named entries in ``flowdash.yaml`` and\n appear locked in the admin UI.')
class-attribute
instance-attribute
¶
mcp_stdio_commands = param.List(default=None, allow_None=True, doc='\n Allowlist of full argv prefixes that ``stdio`` MCP servers configured in\n ``flowdash.yaml`` or the admin UI may launch. Each entry is a command\n string (e.g. ``"/opt/mcp/docs-server --readonly"``) or an argv sequence\n (e.g. ``["/usr/local/bin/my-mcp", "--mode", "read"]``); path entries must\n be absolute. A configured server must match the whole prefix and only\n trailing arguments beyond it are free. Allowlisting a package launcher\n or interpreter without a pinned subcommand/script prefix grants arbitrary\n code execution to anyone who can edit ``flowdash.yaml`` or is an app\n admin. When None, reads the comma-separated ``FLOWDASH_MCP_STDIO_COMMANDS``\n environment variable; when empty, file/UI ``stdio`` servers are denied.')
class-attribute
instance-attribute
¶
mcp_stdio_env = param.List(default=None, allow_None=True, item_type=str, doc='\n Allowlist of subprocess environment variable names that file/UI ``stdio``\n MCP servers may set in ``env:``. When None, reads the comma-separated\n ``FLOWDASH_MCP_STDIO_ENV`` environment variable; when empty, file/UI\n ``stdio`` servers cannot inject environment variables.')
class-attribute
instance-attribute
¶
nav_variant = param.Selector(default='rail', objects=['left', 'menubar', 'rail', 'right'], doc="\n How navigation is rendered. 'rail' shows a navigation rail on the left\n (Home, Dashboards, Components, Pages, Help) and a breadcrumb with a\n dashboard switcher in the top bar; on narrow screens the rail moves\n behind a menu button. 'left' and 'right' dock a MenuList in a drawer\n on that side of the page; 'menubar' places a MenuBar in the page\n header with quick-action icons alongside it.")
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
¶
overlay
property
¶
A layout for overlays an embedder adds, such as their own dialogs.
Laid out beside the main content of every page, in the page's palette
rather than the header's, so a pmui.Dialog appended here opens over
the page and follows the light and dark theme. Unlike page_dialog(),
whose content components replace, what is appended here stays across
navigation and keeps its own state. Content that is not modal, such as
a banner, appears at the bottom of the page's main area.
package = param.String(default=None, doc='\n Importable package that `project_dir` is, if any. Modules are then named\n `<package>.<Section>.<name>` instead of relative to `project_dir`.')
class-attribute
instance-attribute
¶
page_options = param.Dict(default={}, doc="\n Extra keyword arguments passed through to the underlying\n `panel_material_ui.Page`, overriding the app's own defaults.\n ``favicon`` and ``apple_touch_icon`` set the page's icons; without\n them both are generated from ``logo``, if there is one.")
class-attribute
instance-attribute
¶
project = param.ClassSelector(class_=(Project, str, os.PathLike), default=None, doc="\n The project file (``flowdash.yaml``) whose sections configure the\n app, as a path or a loaded `panel_flowdash.project.Project`. A path\n is loaded when the app is created, with the project directory and\n the component registry as the loaders' context, raising\n `ProjectError` with the file, line and column of each problem. See\n the project file reference.")
class-attribute
instance-attribute
¶
project_dir = param.Path(doc='Path to the project directory.')
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. Passed to the embedded\n editor, see `FlowDash.propagate_failures`.')
class-attribute
instance-attribute
¶
sections = param.List(default=[], item_type=SidebarSection, doc='\n Navigation sections shown in the rail and narrow-screen drawer (when\n ``nav_variant="rail"``), each a :class:`~panel_flowdash.SidebarSection`.\n The built-in Dashboards section (``id="dashboards"``, ``order=0``) is\n registered automatically unless a section with ``id="dashboards"`` is\n supplied here. Assigning ``app.sections = [...]`` keeps the built-in\n Dashboards section, deduplicates by ``id`` and sorts in ascending\n ``order`` (custom sections default to ``100``). Use :meth:`add_section`,\n :meth:`remove_section` and :meth:`refresh_sections` to manage sections\n at runtime.')
class-attribute
instance-attribute
¶
settings_class = param.ClassSelector(class_=DashboardSettings, default=DashboardSettings, is_instance=False, doc='\n The dashboard-wide settings class handed to the editor. Subclass\n `DashboardSettings` to persist application-specific values with each\n dashboard.')
class-attribute
instance-attribute
¶
settings_sources = param.Dict(default={}, doc='\n Where parameters given in code come from, by name, e.g.\n ``{"home_dashboard": "__init__.py", "title": "--title"}``. The admin\n view names it on each setting the parameter locks. `flowdash serve`\n fills it in.')
class-attribute
instance-attribute
¶
sidebar = Children(default=[], doc='Items prepended to the sidebar.')
class-attribute
instance-attribute
¶
store = param.ClassSelector(class_=BaseAssetStore, doc='Dashboard store instance for persistence.')
class-attribute
instance-attribute
¶
suggest_questions = param.Callable(default=None, doc="\n Suggests questions on the Ask home: called with the list of\n :class:`~panel_flowdash.home.DataChip` picked (empty when none is),\n it returns a few questions, or an awaitable of them. A question is a\n string, or a mapping with its ``text``, the ``columns`` it uses\n (shown below it) and an optional Material ``icon``. Called again\n whenever the chips picked change. A coroutine function is awaited\n on the session's event loop and a plain function runs on a worker\n thread, so neither blocks the page; only the newest call's\n questions are shown, and a call that fails keeps the last ones.\n A plain function may run while an older call is still running and\n alongside the session's own work, so it must be thread-safe (make\n it ``async`` to run on the event loop instead), and the awaitable\n it returns must be a coroutine, not a future bound to a loop.\n None suggests nothing.")
class-attribute
instance-attribute
¶
templates = param.Boolean(default=True, doc="\n Offer dashboard templates when someone creates a dashboard: the ones\n panel-flowdash ships with and those in the project's ``templates/``\n folder, see :mod:`panel_flowdash.templates`.")
class-attribute
instance-attribute
¶
title = param.String(default='FlowDash', doc='Application title shown in the browser tab.')
class-attribute
instance-attribute
¶
tool_authorize = param.Callable(default=None, doc='\n Called with ``(identity, tool_name)`` to decide whether the agent may\n offer and call *tool_name* in this session. MCP tools are named\n ``mcp_<server>__<tool>`` (see `panel_flowdash.mcp.parse_mcp_tool_name`).\n Returning False hides the tool from the model and refuses execution;\n exceptions fail closed (False). Read dynamically before each run so\n host apps may attach or wrap it after construction.')
class-attribute
instance-attribute
¶
trusted_proxies = param.List(default=[], item_type=str, doc="\n IP addresses of reverse proxies whose ``X-Forwarded-For`` header\n names the client. Without sign-in only a client on the server's own\n machine (a loopback address) gets admin rights, and by default that\n is decided by the socket's peer alone: a request that came through\n a proxy, i.e. has forwarding headers, is never local. List the proxy\n here to have the address it forwards checked instead; it must set\n or append ``X-Forwarded-For``, e.g. nginx's\n ``$proxy_add_x_forwarded_for``.")
class-attribute
instance-attribute
¶
add_section(section)
¶
Register a :class:~panel_flowdash.SidebarSection on this app.
If a section with the same id is already registered, it is
replaced. Sections are ordered by their order key and the
navigation rail and narrow-screen drawer (when nav_variant="rail")
refresh immediately. Note that a routed section added after startup
works for in-session navigation only; pass routed sections to
:meth:build_routes so direct loads and browser reloads resolve.
assistant_allowed()
¶
Whether the person still gets the assistant, with the permissions read again.
build_routes(project_dir=None, registry=None, **params)
classmethod
¶
Generate route mapping for pn.serve.
Registers HTTP routes for the built-in views, every registered page,
and every routed :class:~panel_flowdash.SidebarSection supplied via
sections (as a sequence or a zero-argument callable returning one)
or defined on cls.param.sections.default. Routed sections added
later inside a session with :meth:add_section work for in-session
navigation only and return 404 on direct load or reload.
navigate(url)
¶
Go to url: a route of the app in place, an http(s):// link in the browser.
notify(severity, message, duration=3000)
¶
Show message to the person, e.g. notify("success", "Saved."), or log it.
severity is "success", "info", "warning" or "error".
Without a notification area, e.g. in a session that has none, the
message is logged; with notifications off it is dropped.
refresh_sections(section_id=None)
¶
Re-fetch cached sidebar items and update the navigation rail and drawer.
Pass section_id to refresh a single section, or None to refresh
every registered section. No-op when nav_variant != "rail" or when
section_id is not registered.
remove_section(section_id)
¶
Remove the section with id section_id, returning it or None if absent.
settings_project()
¶
Return the project the admin view writes: project, or the project directory's file.
Without a project file it is flowdash.yaml in the project
directory, or the working directory without one, created on the
first save.
still_admin()
¶
Whether this session is still an admin, with the project file read again.
A settings view a project section adds (settings_view) that
saves on its own asks this before every save.
FontLoader
¶
Bases: JSComponent
Adds a font's stylesheet to the document head, where its font faces apply page-wide.
href = param.String(default=None, allow_None=True)
class-attribute
instance-attribute
¶
HomePage
¶
Bases: Viewer
Home with home="explore": the Ask | Browse switch over the Ask landing or the launcher.
Without a model Home opens on Browse, and the switch is shown only when Ask has something for the person: earlier chats to reread, or for an admin, a way to set up a model.
ask = None
instance-attribute
¶
ask_offered
property
¶
Whether Ask is offered: with a model, or without one to an admin or someone with chats.
choice = param.Selector(default=HOME_ASK, objects=[HOME_ASK, HOME_BROWSE])
class-attribute
instance-attribute
¶
reread = None
instance-attribute
¶
switch = pmui.RadioButtonGroup(options=_SWITCH_OPTIONS, value=self.choice, variant='outlined', align='center', sx=_SWITCH_SX, margin=(20, 0, 4, 0), css_classes=['flowdash-home-switch'])
instance-attribute
¶
refresh()
¶
Bring the page shown up to date with the store, and with whether there is a model.
IconLoader
¶
Bases: JSComponent
Points the page's icon links at new icons, so a changed theme shows without a reload.
The page renders its icons once; this updates the <link> tags when
favicon or apple_touch_icon changes, and leaves them alone before.
Identity
dataclass
¶
The resolved principal for a session.
groups = field(default_factory=frozenset)
class-attribute
instance-attribute
¶
oauth_user = None
class-attribute
instance-attribute
¶
system_user = None
class-attribute
instance-attribute
¶
user
instance-attribute
¶
user_info = field(default_factory=dict)
class-attribute
instance-attribute
¶
user_names
property
¶
All names this identity may be referenced by in a rule.
in_groups(groups)
¶
Whether the identity belongs to any of groups.
is_user(users)
¶
Whether the identity matches any of users (OAuth or system name).
Launcher
¶
Bases: Viewer
Browse: the person's dashboards, reports and chats, with filters, sorting and New.
The kind chips pick which assets are listed, with how many there are of each. The owner menu keeps those of anyone, the person's own or those shared with them, and a search keeps those whose title has the text. Cards draw each kind as it looks: a dashboard's tiles, a report's page and a chat's question over its answer. New makes a dashboard, a report or a dashboard from a template, or imports a file.
Card actions are dispatched through :meth:FlowDashApp._on_dashboard_action,
so actions a subclass adds to the app's action tuples appear here as well.
assets
property
¶
The assets listed now, in order.
filter = param.Selector(default='all', objects=['all', 'owned', 'shared'], doc="Whose assets are listed: anyone's, the person's own or those shared with them.")
class-attribute
instance-attribute
¶
fixed_kind = param.Boolean(default=False, doc='Whether `kind` is fixed, as on the Reports page, so the kind chips are hidden.')
class-attribute
instance-attribute
¶
kind = param.Selector(default='all', objects=['all', DASHBOARD_KIND, REPORT_KIND, CHAT_KIND], doc='Which kind of asset is listed, or all of them.')
class-attribute
instance-attribute
¶
search = param.String(default='', doc='Only assets whose title contains this text are listed.')
class-attribute
instance-attribute
¶
sort = param.Selector(default='edited', objects=['edited', 'name'], doc='Order of the asset cards.')
class-attribute
instance-attribute
¶
view_mode = param.Selector(default='grid', objects=['grid', 'list'], doc='Show assets as cards or rows.')
class-attribute
instance-attribute
¶
new(what, template=None)
¶
Start a new asset: a "dashboard", a "report", one from a "template", or "import" a file.
refresh()
¶
Reload the assets from the store and rebuild the page.
LeavePageGuard
¶
Bases: JSComponent
Has the browser ask before the page is reloaded, closed or left while active.
Navigation inside the app goes through :class:UnsavedChangesDialog; this
covers leaving the page itself, where the browser shows its own prompt.
active = param.Boolean(default=False, doc='Whether leaving the page asks first.')
class-attribute
instance-attribute
¶
LoadingSkeleton
¶
Bases: Viewer
Placeholder of a dashboard while it loads: a header line and tile blocks.
tiles = param.Integer(default=4, bounds=(1, None), doc='Number of tile placeholders.')
class-attribute
instance-attribute
¶
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.
PermissionsUnavailable
¶
Bases: RuntimeError
The project file's permissions cannot be read and none were read from it before.
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.
ProjectError
¶
Bases: ValueError
The problems of a project file, each with the file, line and column it concerns.
problems = list(problems)
instance-attribute
¶
RegistryEntry
dataclass
¶
A registered component/page with its metadata.
app = None
class-attribute
instance-attribute
¶
app_id
instance-attribute
¶
load_error = field(default=None, repr=False, compare=False)
class-attribute
instance-attribute
¶
metadata
instance-attribute
¶
module_name
instance-attribute
¶
module_path = None
class-attribute
instance-attribute
¶
name
instance-attribute
¶
page_path
instance-attribute
¶
section
instance-attribute
¶
spec = field(default=None, repr=False, compare=False)
class-attribute
instance-attribute
¶
title
property
¶
Human-readable title.
from_app(app, *, app_id=None, section=None, name=None)
classmethod
¶
Build an entry from an already-imported app object.
Unlike :func:build_registry, which discovers modules on disk and defers
importing them, this wraps a live object so load() is a no-op. Used
by the programmatic API where components are passed in directly.
Objects without @register metadata are treated as components, since
a bare Viewer subclass handed to the editor is only ever meant to be
one.
load()
¶
Import the module and return the app object.
Caches the result on self.app. Raises on import failure.
SetupWizard
¶
Bases: Viewer
The setup wizard: its steps, then Review, which writes them with Finish.
on_close(finished) is called when Finish wrote the reviewed sections (True) or the wizard was cancelled (False).
plan = {}
instance-attribute
¶
problems = []
instance-attribute
¶
project = project
instance-attribute
¶
review_index
property
¶
Return the index of Review, the last step.
skipped = set()
instance-attribute
¶
step = param.Integer(default=0, doc='The index of the step shown; the last is Review.')
class-attribute
instance-attribute
¶
steps = wizard_steps(project, app)
instance-attribute
¶
titles
property
¶
Return the steps' labels, Review included.
written = []
instance-attribute
¶
back()
¶
Go back a step.
cancel()
¶
Leave the wizard without writing anything.
diff()
¶
Return the reviewed sections' YAML lines, old and new, as (kind, text).
finish()
¶
Write the reviewed sections with Project.set; False, writing nothing, on a problem.
next()
¶
Go on to the next step, or finish on Review.
review()
¶
Collect what each step not skipped writes, by section, and check it.
The result is what Finish writes. Sections the file already has as they would be written are left out.
show(index)
¶
Show step index; Review when it is the last.
skip()
¶
Leave this step's settings out and go on; on Welcome, leave the wizard.
SharingAccess
dataclass
¶
What the sharing section shows for one dashboard.
The application builds it for identities that may administer the dashboard; the dialog has no sharing section without one.
default_allow = True
class-attribute
instance-attribute
¶
group_sizes = field(default_factory=dict)
class-attribute
instance-attribute
¶
groups = ()
class-attribute
instance-attribute
¶
link = ''
class-attribute
instance-attribute
¶
owner
instance-attribute
¶
permission
instance-attribute
¶
shareable = True
class-attribute
instance-attribute
¶
users = ()
class-attribute
instance-attribute
¶
you = frozenset()
class-attribute
instance-attribute
¶
SidebarContext
dataclass
¶
Session context passed to :class:SidebarSection and :class:SidebarAction callables.
Attributes:
| Name | Type | Description |
|---|---|---|
app |
FlowDashApp
|
The session's :class: |
user |
Identity
|
The session's resolved :class: |
section |
SidebarSection
|
The :class: |
app
instance-attribute
¶
is_admin
property
¶
Whether this session administers the project (cached per session).
Use this for showing or hiding UI. Before performing a privileged write
or admin action, re-check with :meth:still_admin.
section
instance-attribute
¶
user
instance-attribute
¶
navigate(url)
¶
Navigate this session to url.
Internal routes open through the app's router; external http:// and
https:// URLs open in a new browser tab.
refresh(section_id=None)
¶
Refresh cached section items; defaults to this section's id.
still_admin()
¶
Whether this session is still an admin, with the project file read again.
SidebarItem
dataclass
¶
One destination listed inside a :class:SidebarSection.
Attributes:
| Name | Type | Description |
|---|---|---|
title |
str
|
Display label shown in the rail menu and narrow-screen drawer. |
url |
str
|
App route (e.g. |
subtitle |
str | None
|
Optional secondary text such as the owner or last updated time. Shown
under the item title in the narrow-screen drawer; desktop rail menus
show titles only ( |
icon |
str | None
|
Optional Material icon name for the item. |
SidebarSection
dataclass
¶
Specification for a navigation section in the FlowDash rail and drawer.
Sidebar sections render only with nav_variant="rail" (the default).
A section may either:
- list destinations via
itemsand/ornew_action(rendered as a menu in the desktop rail and an expanded group in the narrow drawer), - link directly to a landing route via
path(rendered as a single button), or - pass a callable
path(ctx)returning a route string orNoneto switch dynamically between direct-link mode and menu mode (as the built-in Dashboards section does forhome_dashboard).
Setting both route and view lets the section serve its own routes
at /<route> and /<route>/<subpath> through view(ctx, subpath)
without appearing in Pages. When route and view are set without
items, new_action or path, the section links directly to
/<route>.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Unique section identifier (e.g. |
label |
str
|
Heading displayed in the rail button, narrow-screen drawer and breadcrumbs. |
icon |
str
|
Material icon name for the section (e.g. |
items |
Callable[[SidebarContext], Sequence[SidebarItem]] | None
|
Optional callable |
order |
float
|
Sort key controlling section order (ascending). Ties preserve
registration order. The built-in Dashboards section uses |
new_action |
SidebarAction | None
|
Optional :class: |
visible |
Callable[[SidebarContext], bool] | None
|
Optional predicate |
path |
str | Callable[[SidebarContext], str | None] | None
|
Optional landing route (or callable |
route |
str | None
|
Optional URL prefix served by this section, e.g. |
view |
Callable[[SidebarContext, str], Any] | None
|
Optional callable |
icon
instance-attribute
¶
id
instance-attribute
¶
items = None
class-attribute
instance-attribute
¶
label
instance-attribute
¶
new_action = None
class-attribute
instance-attribute
¶
order = 100
class-attribute
instance-attribute
¶
path = None
class-attribute
instance-attribute
¶
route = None
class-attribute
instance-attribute
¶
view = None
class-attribute
instance-attribute
¶
visible = None
class-attribute
instance-attribute
¶
TemplatePicker
¶
Bases: Viewer
Choose what a new dashboard starts from and bind the chosen template's slots.
step is choose (the list of Blank and the templates, with a
preview) or bind (one field per slot of the chosen template).
selected = param.String(default=BLANK, doc="The id of the chosen template, '' for Blank.")
class-attribute
instance-attribute
¶
step = param.Selector(default='choose', objects=['choose', 'bind'])
class-attribute
instance-attribute
¶
template
property
¶
The chosen template, None for Blank.
valid = param.Boolean(default=True, doc='Whether every required slot is bound.')
class-attribute
instance-attribute
¶
visible = param.Boolean(default=True, doc='Whether the picker is shown.')
class-attribute
instance-attribute
¶
back()
¶
Return to the list of templates.
bindings()
¶
Return the bindings for :func:~panel_flowdash.templates.fill_template, checked.
Raises:
| Type | Description |
|---|---|
TemplateError
|
If a choice is no longer offered or a column is not the data's. |
filled()
¶
Return the dashboard document the chosen template gives with the choices made.
pick(template_id)
¶
Choose the template template_id, as clicking it in the list does.
raw_bindings()
¶
Return the choices made so far, by slot: choice keys, column names and text.
reset(templates=None)
¶
Start over at Blank, with templates if given.
start_binding()
async
¶
Show the chosen template's slots, offering what the user may bind them to.
UnsavedChangesDialog
¶
Bases: Viewer
Asks what to do with unsaved changes before leaving the editor, listing them.
The answers call on_leave (discard and go), on_save (save, then
go) or on_stay; each closes the dialog first. Dismissing the dialog
with Escape or a click outside it answers on_stay.
changes = []
instance-attribute
¶
dialog = pmui.Dialog(objects=[self._changes], actions=[self.leave_button, pn.layout.HSpacer(), self.stay_button, self.save_button], title='Save changes before leaving?', open=False)
instance-attribute
¶
leave_button = pmui.Button(label='Leave without saving', color='error', variant='text', margin=0)
instance-attribute
¶
on_leave = param.Callable(doc='Called when the user leaves without saving.')
class-attribute
instance-attribute
¶
on_save = param.Callable(doc='Called when the user saves and leaves.')
class-attribute
instance-attribute
¶
on_stay = param.Callable(doc='Called when the user keeps editing.')
class-attribute
instance-attribute
¶
save_button = pmui.Button(label='Save and leave', variant='contained', margin=0)
instance-attribute
¶
stay_button = pmui.Button(label='Keep editing', variant='text', margin=0)
instance-attribute
¶
show(changes)
¶
Open the dialog listing changes, at most :data:CHANGES_LIMIT of them.
UsageLedger
¶
What models cost, who opened the app and its dashboards, and what admins did, by the project.
It is a JSON file. Without a path everything is kept in memory for the process. Every
process serving the project adds to the same file: each change is a
read-modify-write under an OS file lock (usage.json.lock), so
several workers, or people sharing the project on a network drive, do
not lose each other's spend.
path = Path(path) if path is not None else None
instance-attribute
¶
add(model_id, cost, when=None, user=None)
¶
Count a request by user to model_id that cost cost US dollars (None: unknown).
admin_log()
¶
Return the admin log, oldest first.
dashboards()
¶
Return when each dashboard was last opened, by id, including opens not written yet.
flush_opens()
¶
Write the opens noted since the last write.
forget_dashboards(asset_ids)
¶
Drop what is noted about the dashboards asset_ids, e.g. once deleted.
month(model_id, when=None)
¶
Return the US dollars spent on model_id this month and the number of requests.
opened(asset_id, when=None)
¶
Note that someone opened the dashboard asset_id.
Opens are kept in memory and written together at most every
OPENS_FLUSH_SECONDS (and when the process exits), so opening a
dashboard does not take the file lock each time.
people()
¶
Return who opened the app, with when they were last seen and their groups then.
people_spent(model_id, when=None)
¶
Return the US dollars each person spent on model_id this month, by user name.
person_spent(model_id, user)
¶
Return the US dollars user spent on model_id this month (0 without a user).
preference(user, key, default=None)
¶
Return what user last chose for key, e.g. "home", else default.
record(user, action, dashboards=(), when=None, **details)
¶
Add an admin's action on dashboards (each an id and title) to the admin log.
see(user, groups=(), when=None)
¶
Note that user, a member of groups, opened the app.
set_preference(user, key, value)
¶
Remember value as what user chose for key, kept with their record of visits.
spent(model_id)
¶
Return the US dollars spent on model_id this month.
_is_kiosk(search)
¶
_merged(base, update)
¶
Return base with update merged into it, nested dicts merged key by key.
_unloaded_project(path, context)
¶
Read the project file at path without loading its sections.
Each section is loaded when it is first asked for, so one the file gets wrong is reported where it is used rather than stopping the app.
_without_query(search, *names)
¶
search without the parameters names, keeping every other one in order.
_working_settings_dir()
¶
Return where an app without a project directory keeps flowdash.yaml.
access_denied(*, user, subject=None, owner=None, on_home=None)
¶
Build the page for a dashboard or page that exists but the user may not open.
subject names what was refused (a page title; dashboards pass None
so their title is not revealed). owner is who to ask for access.
admin_entry(identity)
¶
Return how general.admins names identity, or None for an anonymous one.
admin_needs_this_machine(*, on_home=None)
¶
Build the page refusing Admin to a session without sign-in from another machine.
alert_pane(object='', **params)
¶
Return a Panel Alert pane with MathJax turned off in the browser, like :func:markdown_pane.
approval_ids(settings)
¶
Return the ids of the components the agent needs approval to place or change.
auth_code_fields(auth_config, sources, explicit)
¶
Return the AuthConfig fields set in code, each with where.
flowdash serve names the fields the project's __init__.py sets
in settings_sources as auth_config.<field> (and the config
itself as auth_config); an auth_config given otherwise sets
every field that differs from the default.
build_downloader()
¶
Build a hidden file download that :func:send_download drives from the server.
build_registry(project_dir, *, package=None)
¶
Scan project_dir for page/component modules without importing them.
Reads each .py file with the AST to extract @register metadata.
Modules are not imported at this stage; each RegistryEntry.app is
None until RegistryEntry.load() is called.
By default modules are named relative to project_dir
(<Section>.<name>), so the directory itself must be on sys.path.
Pass package when project_dir is an importable package: modules are
then named <package>.<Section>.<name>, so the project's own imports and
flowdash's lazy imports share one module object. Raises
PackageResolutionError (a ValueError) if package does not
resolve to project_dir.
build_session_state_class(registry)
¶
Build a Parameterized subclass with one param per declared state key.
Scans the registry for all provides and requires keys and creates
a dynamic class whose parameters represent shared session state.
chat_title(question, limit=CHAT_TITLE_LENGTH)
¶
Return a chat's title from its first question: its first line, cut at a word.
chats_section()
¶
Build the built-in Chats section, listed when FlowDashApp.chats is on.
check_requirements(state, requires)
¶
Check which required keys are unsatisfied on the given state instance.
Returns a list of dicts describing each unsatisfied requirement. An empty list means all requirements are met.
claim_admin(project, user, token, admin_groups=())
¶
Make user, a general.admins entry, an admin with the admin token; return how it went.
"claimed" when the token was valid and user is now recorded (or,
for no user, admin for the session only), "invalid" for a wrong or
already used token, and "taken" when the project already has admins
or admin groups and the server was not started to add one
(--admin-link). Checking, using the token and recording the user
happen under one lock, so of two claims at once only one succeeds. A
write that fails raises after the token was used.
code_span(text)
¶
Return text as inline Markdown code that it cannot close early.
Line breaks become spaces, since a blank line would end the paragraph and with it the span.
component_icon(entry)
¶
Return a component's declared icon, else the icon of its role when that is known.
copy_dashboard(store, source, user, title)
¶
Save the contents of source as a new, unshared asset of user, of the same kind.
dashboard_not_found(asset_id, similar, *, on_open, on_all)
¶
Build the page for a dashboard id that does not exist (or that the user may not see).
describe_changes(saved, current, titles=None)
¶
List what changed from the saved dashboard to the current canvas.
Returns (icon, text) pairs: added and removed components, added and
removed connections, changed transforms, changed component and dashboard
settings, and one entry for moved or resized tiles. titles maps
component ids to their titles.
effective_auth_config(auth_config, permissions, in_code)
¶
Return auth_config with the section's settings for the fields not set in code.
entry_authorized(entry, identity, *, default_allow=True, load=True)
¶
Whether identity may access a code-authored page or component.
A @register call whose rules could not be read from the source without
importing it (allow_groups=ADMINS, authorize=...) leaves the entry's
rules pending. With load such an entry is imported here so its decorator
supplies the real rules; pass load=False on paths that must not import
synchronously (listings rendered on the event loop), which treats a
pending entry as denied until something else imports it. A pending entry
whose import already failed is denied without importing it again.
error_text(exc)
¶
Return an exception's message with its credentials masked, to show a user or an agent.
escape_html(text)
¶
Escape text for raw HTML inside a Markdown pane, such as a <pre> block.
Line breaks become character references too: a blank line would end the HTML block and hand the rest of the text to Markdown.
escape_markdown(text)
¶
Escape text so a Markdown pane shows it verbatim, without HTML, formatting or math.
font_href(font_family)
¶
Return the Google Fonts stylesheet of font_family, if it loads one.
is_admin(identity, admin_groups, admins=(), *, token=False)
¶
Whether identity may open the admin view.
Members of admin_groups may, and so may the users admins names (the
project file's general.admins, see entry_matches) and a session
that presented the admin token (token). Where the session connects
from is checked by the caller (see session_is_local).
ledger_for(directory)
¶
Return the spend ledger of the project in directory (in memory without one).
load_project(path, context=None, *, lazy=False)
¶
Read and parse the project file at path, see parse_project.
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.
may_view(dashboard, identity, *, default_allow=True)
¶
Whether identity may open dashboard.
A chat is private to its owner: no sharing rule or default grants it to
anyone else. Other dashboards follow their permission, see
:func:~panel_flowdash.auth.is_authorized.
merge_libraries(registry, names, *, reserved=())
¶
Return registry with the components of each library in names added.
An id that is already taken, by registry, by another library or by one
of reserved (e.g. the built-in components), raises instead of letting
one component replace another: dashboards store component ids, so either
choice would silently change what saved dashboards load. The former ids
a library component declares with aliases must not be taken either,
nor may its id be a former id of another component. Adding a library
whose components are already in registry is a no-op, so a registry can
be merged again safely.
Raises:
| Type | Description |
|---|---|
ComponentLibraryError
|
If a library cannot be used (see :func: |
note_on_chat(editor, key, value)
¶
Set key of the settings of the chat open in editor to value, and store it at once.
Only that key of the stored chat changes, and the open chat keeps the stored revision, so saving it later neither conflicts nor drops the key.
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.
own_chats(app)
¶
Return the chats of the session's identity, most recently updated first.
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.
page_icons(favicon=None, apple_touch_icon=None, logo=None)
¶
Return the icons a page links to, from those given and the logo.
The favicon is the one given, else one generated from the logo, else None; a given local file is inlined, and dropped when it isn't an image. The Apple touch icon is the one given, else one generated from the logo, else from the favicon.
page_not_found(path, *, on_home)
¶
Build the page for a URL that matches no dashboard, page or route.
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.
parse_dashboard_file(content, user)
¶
Parse a downloaded dashboard file into a model owned by user.
The file is a JSON export or a dashboard in the YAML format.
Raises:
| Type | Description |
|---|---|
ValueError
|
If content is neither a dashboard export nor a dashboard in the YAML format. |
placement_refusal(settings, component_id, identity)
¶
Return why identity may not add component_id to a dashboard, or None.
project_admins(project, fresh=False)
¶
Return the entries of the project file's general.admins (see access.entry_matches).
With fresh, the file is read again rather than the loaded copy used. A section the loader rejects names no one.
project_components(project)
¶
Return the components section of project, read again when its file changes.
It fails closed: a file that cannot be read keeps the settings last read
from it, so a half-written file does not turn components back on, and
with none read before ComponentSettingsUnavailable is raised, so
callers refuse placing components rather than offer every one.
project_is_new(project)
¶
Whether the project file has no settings yet: missing, empty, or only its admins.
Claiming the admin link writes general.admins, so a file holding only
that is still new.
project_overrides(project, in_code)
¶
Return the target values the project file's general and theme sections set.
A target in_code says the app was given in code is left out, so
code wins over the file.
project_permissions(path)
¶
Return the permissions section of the project file at path, read again when it changes.
A file that cannot be read or parsed, or whose section is invalid, does
not loosen anything: the permissions last read from it stay in force,
logged as an error, and with none read before PermissionsUnavailable
is raised, so callers deny access rather than fall back to defaults.
No file at all sets nothing.
read_chips(found)
¶
Return the chips a FlowDashApp.data_chips hook returned, skipping and logging bad ones.
redact_secrets(text)
¶
Mask a URL's password, secret keys' values and bearer tokens, e.g. in an error message.
reports_section()
¶
Build the built-in Reports section, listed with the built-in Dashboards section.
resolve_identity(auth_config=None)
¶
Resolve the current session's :class:Identity.
Prefers the OAuth login (pn.state.user) when a real provider populated
it; otherwise falls back to the system user, then to "anonymous". The
system user is only part of the identity when there is no OAuth login, so a
signed-in user never inherits the server account's dashboards or groups.
Groups are the union of claim-derived groups, the static user_groups
entry for the resolved user and any dynamic resolve_groups callback.
send_download(downloader, model, restricted=(), extension='json')
¶
Make the browser save model as the same file the editor's Download writes.
The items in restricted are written as :func:export_model describes.
extension is "json" or "yaml".
session_is_local(doc, trusted_proxies=())
¶
Whether the session of Bokeh document doc comes from this machine.
A document without a server session (a script, a notebook or a test)
is local. A served session is local when the client of the request that
opened it is a loopback address (see client_address).
set_chat_scope(dashboard, chips)
¶
Scope dashboard, a chat, to chips; no chips leaves it on all of the project's data.
share_link(dashboard_path)
¶
Return the absolute URL of dashboard_path on the current page's server.
shared_password_sign_in()
¶
Whether users sign in with Panel's basic auth and one shared password.
With a shared password any user name is accepted, so the name proves nothing and does not count as sign-in for admin rights. Basic auth with a mapping (or JSON file) of users and passwords does count.
show_admin_link(base_url='')
¶
Print the admin link once per token, e.g. when the server starts.
It is printed rather than logged, so the token stays out of log files that are kept or shipped elsewhere. base_url is the server's address; without it only the path is printed.
similar_dashboards(ref, dashboards, limit=_SIMILAR_LIMIT)
¶
Return the dashboards whose id or title is closest to ref, best match first.
Matches ignore case. A title containing ref (or contained in it) counts as a match, so a partial name finds the dashboard, as does an id with a typo. Only pass dashboards the user may open, so no other title is shown.
tooltip_css(selector, content, placement='right')
¶
Return CSS showing content as a tooltip beside selector while it is hovered or focused.
selector is completed with the hover or focus state by the caller's
{state} placeholder, e.g. ".pa-toggle{state}". placement is
"right" or "left".
unique_title(store, user, title, kind=DASHBOARD_KIND)
¶
Return title, numbered if user already owns an asset of kind with that title.
See Sidebar Sections for SidebarSection, SidebarItem, SidebarAction and SidebarContext.