pyiron_workflow.nodes.composite module
A base class for nodal objects that have internal structure – i.e. they hold a sub-graph
- class pyiron_workflow.nodes.composite.Composite(*args, label: str | None = None, parent: Composite | None = None, delete_existing_savefiles: bool = False, autoload: BackendIdentifier | StorageInterface | None = None, autorun: bool = False, checkpoint: BackendIdentifier | StorageInterface | None = None, strict_naming: bool = True, **kwargs)[source]
Bases:
LexicalParent[Node],HasCreator,Node,ABCA base class for nodes that have internal graph structure – i.e. they hold a collection of child nodes and their computation is to execute that graph.
- strict_naming
When true, repeated assignment of a new node to an existing node label will raise an error, otherwise the label gets appended with an index and the assignment proceeds. (Default is true: disallow assigning to existing labels.)
- Type:
bool
- provenance_by_completion
The child nodes (by label) in the order that they completed on the last
run()call.- Type:
list[str]
- provenance_by_execution
The child nodes (by label) in the order that they started executing on the last
run()call.- Type:
list[str]
- running_children
The names of children who are currently running.
- Type:
list[str]
- signal_queue
Pending signal event pairs from child execution flow connections.
- Type:
list[tuple[OutputSignal, InputSignal]]
- starting_nodes
A subset of the owned nodes to be used on running. Only necessary if the execution graph has been manually specified with run signals. (Default is an empty list.)
- Type:
None | list[pyiron_workflow.node.Node]
- add_child(child: Node, label: str | None = None, strict_naming: bool | None = None) Node[source]
Add the node instance to this subgraph.
- property cache_hit: bool
- property color: str
For drawing the graph
- disconnect_run() list[tuple[InputSignal, OutputSignal]][source]
Disconnect all signals.input.run connections on all child nodes.
- Returns:
Any disconnected pairs.
- Return type:
list[tuple[InputSignal, OutputSignal]]
- executor_shutdown(wait=True, *, cancel_futures=False)[source]
Invoke shutdown on the executor (if present), and recursively invoke shutdown for children.
- property graph_as_dict: dict
A nested dictionary representation of the computation graph using full labels as keys and objects as values.
- property import_ready: bool
Checks whether importlib can find this node’s class, and if so whether the imported object matches the node’s type.
- Returns:
- Whether the imported module and name of this node’s class match
its type.
- Return type:
(bool)
- process_run_result(run_output)[source]
What to _do_ with the results of
on_run()once you have them.By extracting this as a separate method, we allow the runnable to pass the actual execution off to another entity and release the python process to do other things. In such a case, this function should be registered as a callback so that the runnable can process the result of that process.
- Parameters:
run_output – The results of a self.on_run(self.run_args) call.
- push_child(child: Node | str, *args, **kwargs)[source]
Run a child node in a “push” configuration.
- Parameters:
child (Node|str) – The child node to push.
*args – Additional positional arguments passed to the child node.
**kwargs – Additional keyword arguments passed to the child node.
- Returns:
- The result of running the node, or a futures object (if
running on an executor).
- Return type:
(Any | Future)
- register_child_emitting(child: Node) None[source]
To be called by children when they want to emit their signals.
- Parameters:
[Node] (child) – The child that is finished and would like to fire its ran signal (and possibly others). Should always be a child of self, but this is not explicitly verified at runtime.
- register_child_finished(child: Node) None[source]
To be called by children when they are finished their run.
- Parameters:
[Node] (child) – The child that is finished and would like to fire its ran signal. Should always be a child of self, but this is not explicitly verified at runtime.
- register_child_starting(child: Node) None[source]
To be called by children when they start their run cycle.
- Parameters:
[Node] (child) – The child that is finished and would like to fire its ran signal. Should always be a child of self, but this is not explicitly verified at runtime.
- remove_child(child: Node | str) Node[source]
Remove a child from the
childrencollection, disconnecting it and setting itsparentto None.
- property run_args: tuple[tuple, dict]
Any data needed for
on_run(), will be passed as (*args, **kwargs).
- run_data_tree_for_child(node: Node) None[source]
Use topological analysis to build a tree of all upstream dependencies and run them.
This method is called by a child node when it needs to run its data tree and has a parent. The parent (this composite) handles the execution of the data tree.
- Parameters:
node (Node) – The child node that initiated the data tree run.
- set_run_signals_to_dag_execution()[source]
Disconnects all signals.input.run connections among children and attempts to reconnect these according to the DAG flow of the data. On success, sets the starting nodes to just be the upstream-most node in this linear DAG flow.
- property use_cache: bool
Composite nodes determine the cache usage by the cache usage of all children recursively.
Setting this property at the composite level sets it for all children recursively.