input_literals¶
panel_flowdash.input_literals
¶
Literal values for a node's unconnected inputs.
An input that nothing is wired to can hold a value set by hand in the
inspector, by the agent or in the dashboard file, under the node's inputs
key. A connection always wins: the literal applies only while the input is
unwired, and comes back when the connection is removed.
Only values a dashboard file can hold are literals: numbers, text, booleans, lists, tuples and mappings of these, or one of a selector's options. Inputs of other types, such as DataFrames, can only be wired.
ANY = 'any'
module-attribute
¶
_BOUNDS = ((re.compile('(upper|lower) bound must be in range \\[(.+), (.+)\\], not (.+?)\\.?$'), lambda m: f'The {m[1]} end must be between {m[2]} and {m[3]}, not {m[4]}.'), (re.compile('must be in range \\[(.+), (.+)\\], not (.+?)\\.?$'), lambda m: f'Must be between {m[1]} and {m[2]}, not {m[3]}.'), (re.compile('must be at (most|least) (.+), not (.+?)\\.?$'), lambda m: f'Must be at {m[1]} {m[2]}, not {m[3]}.'), (re.compile('must be (less|greater) than (.+), not (.+?)\\.?$'), lambda m: f'Must be {m[1]} than {m[2]}, not {m[3]}.'))
module-attribute
¶
_CLASS = re.compile("<class '(?:[\\w.]+\\.)?(\\w+)'>")
module-attribute
¶
_DATA_PARAMS = (param.String, param.Number, param.Boolean, param.List, param.Tuple, param.Dict, param.Color)
module-attribute
¶
_LISTED_OPTIONS = 8
module-attribute
¶
_OBJECT_PARAMS = (param.Date, param.CalendarDate)
module-attribute
¶
_PARAMETER_NAME = re.compile("^(Attribute '\\w+' of )?\\w+ parameter( '[^']*')? ")
module-attribute
¶
_SCALAR_PARAMS = {'number': param.Number, 'int': param.Integer, 'str': param.String, 'bool': param.Boolean, 'list': param.List, 'dict': param.Dict}
module-attribute
¶
_WRONG_TYPE = re.compile('only takes (numeric|a tuple|a string|date)|must be an integer|must be True or False|must be a list, not|value must be an instance of|is not of the correct length')
module-attribute
¶
__all__ = ['check_literal', 'explain', 'literal_parameter', 'literal_schema', 'port_literal', 'stored_literal', 'takes_literal']
module-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.
_copied(parameter)
¶
Return an unbound copy of parameter that allows None, for editing a literal.
_is_data(value)
¶
_label(port)
¶
_options(parameter)
¶
_plain(objects)
¶
_type_words(parameter)
¶
check_literal(port, value)
¶
Return why value cannot be the literal of port, or None if it can.
error_text(exc)
¶
Return an exception's message with its credentials masked, to show a user or an agent.
explain(parameter, exc)
¶
Say in words why parameter refuses a value, without param's internal names.
A value of the wrong type or shape gets what the input needs, e.g. "Needs two numbers, like (2010, 2020)." for a range given three numbers; a value that breaks a constraint, e.g. a bound or a pattern, gets param's reason without the parameter's name.
literal_parameter(port)
¶
Return the Parameter a literal value of port is edited and checked with, or None.
An input introspected from a component's Parameter is edited with a copy of that Parameter, so its bounds and options apply. Other inputs follow their port type; an untyped input takes any literal, edited as text. An input of a type a dashboard file cannot hold, e.g. a DataFrame, takes none.
literal_schema(port)
¶
Return the JSON Schema of the literal values of port, or None if it takes none.
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_literal(port, value)
¶
Return a stored literal in the form port takes, e.g. a list read from a file as a tuple.
stored_literal(value)
¶
Return value as a dashboard file stores it: tuples become lists.
takes_literal(port)
¶
Whether port can hold a literal value.