Component#
- class maize.core.component.Component(parent: Graph | None = None, name: str | None = None, description: str | None = None, fail_ok: bool = False, n_attempts: int = 1, level: int | str | None = None, cleanup_temp: bool = True, resume: bool = False, logfile: Path | None = None, max_cpus: int | None = None, max_gpus: int | None = None, loop: bool | None = None)[source]#
Bases:
object
Base class for all components. Should not be used directly.
- Parameters:
parent – Parent component, typically the graph in context
name – The name of the component
description – An optional additional description
fail_ok – If True, the failure in the component will not trigger the whole network to shutdown
n_attempts – Number of attempts at executing the run() method
level – Logging level, if not given or
None
will use the parent logging levelcleanup_temp – Whether to remove any temporary directories after completion
resume – Whether to resume from a previous checkpoint
logfile – File to output all log messages to, defaults to STDOUT
max_cpus – Maximum number of CPUs to use, defaults to the number of available cores in the system
max_gpus – Maximum number of GPUs to use, defaults to the number of available GPUs in the system
loop – Whether to run the run method in a loop, as opposed to a single time
See also
node.Node
Node class for implementing custom tasks
graph.Graph
Graph class to group nodes together to form a subgraph
workflow.Workflow
Workflow class to group nodes and graphs together to an executable workflow
- __init__(parent: Graph | None = None, name: str | None = None, description: str | None = None, fail_ok: bool = False, n_attempts: int = 1, level: int | str | None = None, cleanup_temp: bool = True, resume: bool = False, logfile: Path | None = None, max_cpus: int | None = None, max_gpus: int | None = None, loop: bool | None = None) None [source]#
Methods
__init__
([parent, name, description, ...])as_dict
()Provides a non-recursive dictionary view of the component.
Returns all available and registered nodes.
Returns all inputs available to the node.
get_interfaces
([kind])Returns all interfaces available to the node.
get_node_class
(name)Returns the node class corresponding to the given name.
Returns all outputs available to the node.
Returns all parameters available to the node.
Provides a one-line summary of the node.
Check if all required ports are active.
Send a status update to the main process.
Provides a serialized representation of the component type.
setup_directories
([parent_path])Sets up the required directories.
update_parameters
(**kwargs)Update component parameters.
Attributes
Returns all settable parameters and unconnected inputs
Provides the full path to the component as a tuple of names.
The component datatype if it's generic.
Returns the number of items waiting to be received
Returns the number of items waiting to be sent
Provides the configuration of the current node
Provides all parent components.
Provides a convenience iterator for all inputs and outputs.
List of external commandline programs that are required for running the component.
List of required python packages
Provides the root workflow or graph instance.
Current status of the component.
Python logger for both the build and run procedures.
Timer for the run duration, without waiting for resources or other nodes.
Timer for the full duration, including waiting for resources or other nodes.
Working directory for the component.
- property all_parameters: dict[str, Input[Any] | MultiInput[Any] | Parameter[Any]]#
Returns all settable parameters and unconnected inputs
- property component_path: tuple[str, ...]#
Provides the full path to the component as a tuple of names.
- static get_available_nodes() set[type[Component]] [source]#
Returns all available and registered nodes.
- classmethod get_interfaces(kind: Literal['input', 'output', 'parameter'] | None = None) set[str] [source]#
Returns all interfaces available to the node.
- static get_node_class(name: str) type[Component] [source]#
Returns the node class corresponding to the given name.
- Parameters:
name – Name of the component class to retrieve
- Returns:
The retrieved component class, can be passed to add_node
- Return type:
Type[Component]
- property node_config: NodeConfig#
Provides the configuration of the current node
- ports_active() bool [source]#
Check if all required ports are active.
Can be overridden by the user to allow custom shutdown scenarios, for example in the case of complex inter-port dependencies. By default only checks if any mandatory ports are inactive.
- Returns:
True
if all required ports are active,False
otherwise.- Return type:
- required_callables: ClassVar[list[str]] = []#
List of external commandline programs that are required for running the component.
- classmethod serialized_summary() _SerialType [source]#
Provides a serialized representation of the component type.
- Returns:
Nested dictionary of the component type structure, including I/O and parameters.
- Return type:
Examples
>>> Merge.serialized_summary() {"name": "Merge", "inputs": [{"name": "inp", ...}]}
- status#
Current status of the component.