failure_overlay¶
panel_flowdash.failure_overlay
¶
A tile overlay that explains, over the stale content, why a tile could not update.
RESTRICTED_TEXT = 'You do not have access to the data behind this tile.'
module-attribute
¶
RESTRICTED_TITLE = 'Restricted'
module-attribute
¶
_ICON_SX = {'alignItems': 'center', 'bgcolor': 'color-mix(in srgb, currentColor 14%, transparent)', 'borderRadius': '50%', 'color': 'error.main', 'display': 'flex', 'height': 40, 'justifyContent': 'center', 'width': 40}
module-attribute
¶
_OPAQUE = {'background': 'var(--mui-palette-background-paper, var(--panel-background-color, #fff))'}
module-attribute
¶
_RESTRICTED = FailureMessage(restricted=True)
module-attribute
¶
_SCRIM_STYLES = {'position': 'absolute', 'inset': '0', 'z-index': '10', 'background': 'color-mix(in srgb, var(--mui-palette-background-paper, var(--panel-background-color, #fff)) 82%, transparent)', 'overflow': 'auto'}
module-attribute
¶
_SIZING_PARAMS = ('sizing_mode', 'width', 'height', 'min_width', 'min_height', 'max_width', 'max_height')
module-attribute
¶
FailureMessage
dataclass
¶
What a failure overlay says about the failed inputs of one tile.
sources names the upstream components whose failure stopped the tile,
in the words the user sees; details holds the technical explanation
shown behind the Details disclosure.
FailureOverlay
¶
Bases: Column
A view with a message that covers it while any of its inputs is failed.
objects stays [view, overlay]; the overlay is a sibling that is
only visible while the failures are non-empty. actions is a row of
extra buttons shown next to the Details toggle, e.g. a way to the editor.
A failure that :func:is_restricted turns the message into a neutral
"Restricted" one, without the names of the failed components or details,
over an opaque scrim, whatever describe says. One refused input is
enough: a genuine failure of another input then stays behind the neutral
message, which fails closed.
actions = pn.Row(margin=0, align='center', visible=restricted.rx.not_())
instance-attribute
¶
details = pmui.Typography(message.rx.pipe(lambda m: escape_markdown(m.details)), css_classes=['flowdash-failure-details'], variant='caption', align='center', margin=(4, 16, 0, 16), max_width=560, visible=False, sx={'color': 'text.secondary', 'fontFamily': 'monospace', 'overflowWrap': 'anywhere', 'textAlign': 'left', 'whiteSpace': 'pre-line'})
instance-attribute
¶
details_toggle = pmui.Button(label='Details', icon='expand_more', size='small', variant='text', margin=(0, 4), visible=restricted.rx.not_())
instance-attribute
¶
summary = pmui.Typography(message.rx.pipe(lambda m: RESTRICTED_TEXT if m.restricted else _sentence(m.sources)), variant='body2', align='center', margin=(0, 16), max_width=560, sx={'color': 'text.secondary', 'textAlign': 'center'})
instance-attribute
¶
InputFailure
dataclass
¶
InputFailures
¶
Bases: Parameterized
The inputs of one node that currently hold a failure, keyed by port name.
failed = param.Dict(default={}, doc='\n Failures that reached inputs which do not handle them, by input port.\n Replaced, never mutated, so a watcher sees every change.')
class-attribute
instance-attribute
¶
_as_message(described)
¶
_describe(failed, describe)
¶
_sentence(sources)
¶
escape_markdown(text)
¶
Escape text so a Markdown pane shows it verbatim, without HTML, formatting or math.
icon_badge(icon, color='error.main')
¶
Return a Material icon in a tinted circle, to lead a centred state message.
is_restricted(error)
¶
Return whether error is a refusal of access: a PermissionError, or one caused by it.
Takes the param.ReactiveError a failed output carries too. A component
that wraps a failure of its input in an error of its own keeps the refusal
recognisable by raising it from the original; an error raised while
handling one with the context suppressed (raise ... from None) is not a
refusal. A PermissionError the OS raised, whose errno is a real OS
error number (EACCES, EPERM), is a fault of the deployment, such as
an unreadable file, and not a refusal either; one whose first argument is
some other number, e.g. PermissionError(403, "Forbidden"), is a refusal.
An exception group is a refusal when any of its members is.
restricted_failures(failed)
¶
Return whether any of the failed inputs failed was refused access, see :func:is_restricted.
restricted_placeholder(text=RESTRICTED_TEXT, **params)
¶
Return the neutral message a tile shows in place of data the viewer may not access.
For a component that receives failures itself (handles_failures) and
finds one :func:is_restricted, so it looks like the tiles FlowDash covers.
FlowDash also shows it, with its own text, for a component the viewer
may not use.
with_failure_overlay(view, failures, describe)
¶
Wrap view so that it is covered by a message while any of its inputs is failed.
The wrapper takes over the view's sizing so that it lays out the same way in a tile or on the canvas. The message says in plain language that the tile could not update and which upstream components stopped it; the technical explanation from describe sits behind a Details disclosure.