Parameter#
- class maize.core.interface.Parameter(*args: Any, **kwargs: Any)[source]#
Bases:
Interface
[T
]Task parameter container.
- Parameters:
default – Default value for the parameter
default_factory – The default factory in case of mutable values
optional – If
True
, the parent node will not check if this parameter has been set
- name#
Name of the parameter
- parent#
Parent component
- datatype#
The datatype of the associated parameter. This may be a type from the
typing
library and thus not always usable for checks withisinstance()
See also
FileParameter
Allows specifying a read-only file as a parameter
Parameter
Allows specifying any data value as a parameter
Flag
Alias for boolean parameters
- __init__(default: T | None = None, default_factory: Callable[[], T] | None = None, optional: bool = False) None [source]#
Methods
__init__
([default, default_factory, optional])build
(name, parent)Instantiate an interface from the description.
check
(value)Checks if a value is valid using type annotations.
set
(value)Set the parameter to a specified value.
Attributes
Returns whether the parameter was explicitly set
Returns whether the default value is set
Indicates whether the parameter has been set to a non-
None
value.Provides a unique path to the interface.
Provides a serialized summary of the parameter
Provides the value of the parameter.
doc
- build(name: str, parent: Component) _TInter #
Instantiate an interface from the description.
- Parameters:
name – Name of the interface, will typically be the attribute name of the parent object
parent – Parent component instance
- Returns:
Copy of the current instance, with references to the name and the parent
- Return type:
_TInter
- check(value: T) bool #
Checks if a value is valid using type annotations.
- Parameters:
value – Value to typecheck
- Returns:
True
if the value is valid,False
otherwise- Return type:
- set(value: T) None [source]#
Set the parameter to a specified value.
- Parameters:
value – Value to set the parameter to
- Raises:
ValueError – If the datatype doesn’t match with the parameter type
Examples
>>> foo.val.set(42)
See also
graph.Graph.add
Allows setting parameters at the point of node addition
component.Component.update_parameters
Sets multiple parameters over a node, graph, or workflow at once
- property value: T#
Provides the value of the parameter.