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 with isinstance()

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

changed

Returns whether the parameter was explicitly set

is_default

Returns whether the default value is set

is_set

Indicates whether the parameter has been set to a non-None value.

path

Provides a unique path to the interface.

serialized

Provides a serialized summary of the parameter

value

Provides the value of the parameter.

name

parent

datatype

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

property changed: bool#

Returns whether the parameter was explicitly set

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:

bool

property is_default: bool#

Returns whether the default value is set

property is_set: bool#

Indicates whether the parameter has been set to a non-None value.

property path: tuple[str, ...]#

Provides a unique path to the interface.

property serialized: dict[str, Any]#

Provides a serialized summary of the parameter

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.