Port Types¶
panel_flowdash.port_types
¶
Port type names, their aliases and the subtype rules connections are checked against.
Port types are plain strings: a type given in provides/requires, or
the class name of the Parameter a Viewer port is introspected from. Different
spellings of one type ("str" and "String", "DataFrame" and
"pandas.DataFrame") normalize to one canonical name, and a source type
connects to a target type when they are equal or the source is registered as a
subtype of the target (an Integer output feeds a Number input).
The static check only rules out connections that can never work. The input's Parameter still validates every value it receives at runtime.
ANY = 'any'
module-attribute
¶
_ALIASES = {}
module-attribute
¶
_BUILTIN_DARK_COLORS = {}
module-attribute
¶
_BUILTIN_LIGHT_COLORS = {}
module-attribute
¶
_COLORS = {}
module-attribute
¶
_COLUMN_READERS = {}
module-attribute
¶
_FALLBACK_PALETTE = (('#0072B5', '#5AB4EE'), ('#2A9D8F', '#3FB8A9'), ('#8E24AA', '#CE93D8'), ('#D97706', '#F5B041'), ('#0284C7', '#38BDF8'), ('#4F46E5', '#818CF8'), ('#DB2777', '#F472B6'), ('#059669', '#34D399'), ('#6D4C41', '#BCAAA4'), ('#7C3AED', '#A78BFA'))
module-attribute
¶
_KNOWN_CUSTOM_COLORS = {'lumen.source': ('#6D4C41', '#BCAAA4'), 'lumen.pipeline': ('#0072B5', '#5AB4EE')}
module-attribute
¶
_LOCK = threading.Lock()
module-attribute
¶
_SUPERTYPES = {}
module-attribute
¶
_key(name)
¶
_register_builtin(name, *, aliases=(), subtype_of=(), light, dark)
¶
_register_builtin_types()
¶
_supertypes(canonical)
¶
column_reader(name)
¶
Return the columns callable registered for a port type or the nearest supertype.
is_registered_port_type(name)
¶
Return whether name is a registered port type or one of its aliases.
normalize_port_type(name)
¶
Return the canonical name of a port type, or None for an untyped port.
Unregistered names normalize to themselves, lowercased, so two ports with the same custom type name still connect.
port_type_color(name, *, dark=False)
¶
Return the handle color for name, using dark-mode adjustments when dark is True.
port_types_compatible(source, target)
¶
Return whether an output of type source may connect to an input of type target.
An untyped port, or one typed any (object, a bare Parameter,
a Selector or ClassSelector whose value type the name does not
tell), connects to anything; otherwise the types must be equal or source
a registered subtype of target.
register_port_type(name, *, aliases=(), subtype_of=(), columns=None, color=None)
¶
Register a port type, its alternative spellings and the types it can feed.
Registering a name again adds to its aliases and supertypes. Aliases and supertypes may be spelled any way that normalizes to a registered type; an unknown supertype is registered on the fly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Canonical name of the type, e.g. |
required |
aliases
|
Iterable[str]
|
Other spellings of the same type, e.g. |
()
|
subtype_of
|
Iterable[str]
|
Types an output of this type may connect to, e.g. |
()
|
columns
|
Callable | None
|
For a tabular type that is not a DataFrame, e.g. a lazy query, a
callable that lists the columns of a value without fetching rows:
|
None
|
color
|
str | None
|
Optional CSS color used for canvas handles of this port type. Subtypes inherit it unless they register their own. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The canonical name ports of this type normalize to. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an alias already names a different type, or the rule would make
|