FileParameter#

class maize.core.interface.FileParameter(*args: Any, **kwargs: Any)[source]#

Bases: Parameter[P]

Allows provision of files as parameters to nodes.

Parameters:

exist_required – If True will raise an exception if the specified file can’t be found

Raises:

FileNotFoundError – If the input file doesn’t exist

See also

Parameter

Allows specifying values as parameters

__init__(default: P | None = None, exist_required: bool = True, optional: bool = False) None[source]#

Methods

__init__([default, exist_required, 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

filepath

Provides the path to the file.

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 filepath: P#

Provides the path to the file.

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: P) 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.