Skip to content

Component Spec

panel_flowdash.component_spec

Component specification with typed ports for the dataflow editor.

ReactiveError = param.ReactiveError module-attribute

_BASE_PARAMS = set(param.Parameterized.param) | set(Viewable.param) module-attribute

_JSON_TYPES = {param.Boolean: 'boolean', param.Integer: 'integer', param.Number: 'number', param.String: 'string', param.List: 'array', param.Dict: 'object'} module-attribute

_SCHEMA_PARAMS = {'string': param.String, 'integer': param.Integer, 'number': param.Number, 'boolean': param.Boolean, 'array': param.List, 'object': param.Dict} module-attribute

logger = logging.getLogger('panel_flowdash') module-attribute

ComponentSpec dataclass

Full specification of a component's ports and metadata.

check_config = None class-attribute instance-attribute

component_id instance-attribute

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

config_choices = None class-attribute instance-attribute

config_completions = None class-attribute instance-attribute

config_editor = None class-attribute instance-attribute

config_state_class = None class-attribute instance-attribute

contract = None class-attribute instance-attribute

default_size instance-attribute

description instance-attribute

framed = None class-attribute instance-attribute

icon instance-attribute

inputs instance-attribute

max_size = None class-attribute instance-attribute

min_size = None class-attribute instance-attribute

outputs instance-attribute

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

tags instance-attribute

title instance-attribute

resolve_name(name)

Return the current name of a port or config field that may have been renamed.

A name that is still a port or config field is never redirected, so an alias cannot shadow a live name.

ConfigField dataclass

Describes a single design-time configuration option on a component.

choices = None class-attribute instance-attribute

default = None class-attribute instance-attribute

label = None class-attribute instance-attribute

name instance-attribute

type = None class-attribute instance-attribute

InputPort dataclass

Describes a single input port on a component node.

blocking = True class-attribute instance-attribute

default = None class-attribute instance-attribute

handles_failures = False class-attribute instance-attribute

label = None class-attribute instance-attribute

multiple = None class-attribute instance-attribute

name instance-attribute

parameter = field(default=None, compare=False, repr=False) class-attribute instance-attribute

required = True class-attribute instance-attribute

type = None class-attribute instance-attribute

check_value(value)

Return why value would be rejected by this input, or None.

OutputPort dataclass

Describes a single output port on a component node.

label = None class-attribute instance-attribute

name instance-attribute

type = None class-attribute instance-attribute

PanelAppMetadata dataclass

Metadata attached to a component or page by the @register decorator.

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

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

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

auth_pending = False class-attribute instance-attribute

authorize = None class-attribute instance-attribute

check_config = None class-attribute instance-attribute

component = False class-attribute instance-attribute

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

config_choices = None class-attribute instance-attribute

config_completions = None class-attribute instance-attribute

config_editor = None class-attribute instance-attribute

config_schema = None class-attribute instance-attribute

contract = None class-attribute instance-attribute

default_size = None class-attribute instance-attribute

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

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

description = None class-attribute instance-attribute

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

framed = None class-attribute instance-attribute

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

icon = None class-attribute instance-attribute

max_size = None class-attribute instance-attribute

min_size = None class-attribute instance-attribute

page = True class-attribute instance-attribute

palette_presets = None class-attribute instance-attribute

permission property

Build a :class:~panel_flowdash.auth.Permission from the declared rules.

placeholder = None class-attribute instance-attribute

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

presets_pending = False class-attribute instance-attribute

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

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

sidebar = False class-attribute instance-attribute

singleton = False class-attribute instance-attribute

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

title = None class-attribute instance-attribute

from_app(app) classmethod

Extract metadata from an app object.

is_registered(app) staticmethod

Whether @register attached metadata to app.

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.

Upstream dataclass

The output a new edge into a component reads, as passed to its on_connect.

A Viewer or Viewable component may define on_connect(self, port: str, upstream: Upstream) -> dict | None, a plain (sync) method. FlowDash calls it after a person, a palette drop or the agent wires a new edge into the input port, and applies the config changes it returns in the same edit as the connection, so they are saved and undone with it. Moving an edge onto a new node, as replacing the upstream node does, counts as connecting it. It is not called when a saved dashboard loads or an undo restores edges, nor on a component with no config fields.

component_id instance-attribute

The upstream node's component id.

node instance-attribute

The upstream node's name, as in the dashboard YAML.

port instance-attribute

The upstream output port.

type instance-attribute

The type of the upstream output port.

value instance-attribute

The output's current value, before any transform on the edge.

_config_from_mapping(schema)

Build a config state class from a JSON-Schema-like properties dict.

Properties are typed from their JSON type (string, integer, number, boolean, array, object), with enum giving a selector and minimum/maximum bounds; an untyped property accepts any value. "x-flowdash" is the param's FlowDash metadata, e.g. {"choices": "columns", "of": "<input>"} to declare choices or {"widget": "code", "language": "sql"} for a code editor.

_config_from_metadata(metadata, viewer_cls=None)

Resolve config into a state class and field list from component metadata.

_config_from_param_class(cls, names=None)

Build a config state class and field list from a Parameterized subclass.

When names is given, only those params are treated as config; otherwise every non-base param on the class is used.

_declared_choices(metadata)

Return the choices a param's or schema property's FlowDash metadata declares.

_field_schema(p)

Return the JSON schema the canvas validates one config field's value against.

Only what JSON schema states plainly is kept: the basic type, nullability and numeric bounds. Anything else, such as a selector, a tuple, a nested model or an untyped param, gets a schema without a type, so its values are not checked by the canvas; the param still validates them.

_flowdash_metadata(p)

Return the "flowdash" namespace of a Parameter's metadata, or an empty dict.

_from_panel(owner, own_root)

Whether owner comes from Panel or an installed Panel extension such as panel-material-ui.

The registered component's own top-level package never counts, so an extension named panel_<name> that ships FlowDash components keeps the ports it declares.

_is_panel_package(root) cached

_is_pydantic_model(cls)

_json_default(annotation, default)

Return a Pydantic field's default as JSON data, as a saved dashboard holds it.

A nested model becomes a dict, an Enum member its value and a tuple a list, since node data must be JSON. A default that cannot be converted is kept as it is.

_mark_failure_handlers(component_id, inputs, names)

Flag the inputs a component declares it can receive a failure on.

_param_from_schema(prop, default)

Build the Parameter a JSON schema property describes, untyped if it cannot be typed.

_param_type_name(p)

_parameter_aliases(viewer_cls)

Map the former names a viewer's Parameters declare in metadata to their current names.

_parameter_outputs(viewer_cls)

List the Parameters a viewer class declares as outputs through metadata.

_ports_from_metadata(metadata)

_ports_from_viewer_class(viewer_cls, exclude=None)

_pydantic_to_properties(cls)

Return the JSON schema properties of a Pydantic model, with its Python defaults.

The types come from the model's JSON schema, with $ref pointers such as an Enum's resolved, and the defaults from its fields, as JSON data. A model whose JSON schema cannot be generated gives untyped properties.

_resolve_refs(prop, defs)

Return prop with $ref pointers into defs, also in its anyOf, replaced by their targets.

_root_package(cls)

_schema_enum(prop)

Return the values an enum or const property allows, without null, and whether null is allowed.

Values listed in an anyOf with a null option, as Pydantic writes Optional[Literal[...]], are found too.

_schema_items(prop)

_schema_type(prop)

Return the JSON type of a schema property and whether it allows null.

{"type": ["integer", "null"]} and {"anyOf": [{"type": "integer"}, {"type": "null"}]} both give ("integer", True); a union of several types gives no type.

_size_hint(component_id, name, hint)

Keep the positive width and height pixel values of a tile size hint.

_type_from_parameter(viewer_cls, port)

Type an untyped output after the Parameter of the same name on the viewer.

The base param.Parameter accepts anything, so it leaves the port untyped rather than refusing to connect to every typed input.

build_component_spec(entry)

Build a ComponentSpec from a registry entry, caching it on the entry.

A spec is derived purely from the component's class/metadata, so it does not vary between sessions. Registry entries are shared across sessions, which makes the cache process-wide.

build_component_specs(registry, component_ids=None)

Build specs for component-enabled entries in a registry.

Parameters:

Name Type Description Default
registry dict[str, RegistryEntry]

Registry entries keyed by component id.

required
component_ids Iterable[str] | None

Restrict spec building to these ids. Entries outside the set are skipped without being introspected, so an unloaded component costs nothing.

None

config_json_schema(cls)

Return the JSON schema of the config of a node of a component, for the canvas.

The canvas validates the data of every node placed against it, so every field maps to a valid property, see :func:_field_schema.

config_value(parameter, value)

Return value in the form parameter takes, e.g. a list read from JSON as a tuple.

declared_outputs(obj)

Return param.outputs() of a Viewer or Viewable class or instance.

A Viewable only declares outputs on its own classes. Those are read from the class dicts, since param.outputs() reads every attribute of the Panel classes too, and some of those (an ESM component's bundle paths) raise when read off a component defined outside a module file.

error_text(exc)

Return an exception's message with its credentials masked, to show a user or an agent.

is_failure(value)

Whether value is a failure carried along an edge as a param.ReactiveError.

is_view_class(app)

Whether app is a Panel Viewer or Viewable class, whose params are its ports.

widget_hint(p)

Return the widget a param's FlowDash metadata asks the inspector for, or None.

E.g. "code", "format" or "thresholds" from metadata={"flowdash": {"widget": "format"}}.