ironflow.model.node module

class ironflow.model.node.BatchingNode(params)[source]

Bases: Node, ABC

A node whose update behaviour supports batched inputs.

property batch_lengths
property batched
property batched_inputs
batched_representation(label: str, representation_function: Callable, *args) dict | None[source]

Batched output requires multiple representations instead of a single one. Use this function to wrap a function that produces your desired representation. Resulting batched representations simply get an index added to their label.

Parameters:
  • label (str) – The name of the representation.

  • representation_function (Callable) – A function producing the representation.

  • *args – Members of self.inputs.values or self.outputs.values needed for the representation.

Returns:

The representation(s).

Return type:

(dict)

Examples

>>> def extra_representations(self):
>>>     return {
>>>         **self.batched_representation(
>>>             "bigger", self._add5, self.outputs.values.n
>>>        )
>>>     }
>>>
>>> @staticmethod
>>> def _add5(n: int):
>>>     return n + 5
clear_output()[source]
generate_batched_output()[source]
generate_output() dict[source]
generate_unbatched_output()[source]
abstract node_function(*args, **kwargs) dict[source]

Takes all data input as kwargs, must return a dict with one entry for each data output

set_output()[source]
property unbatched_inputs
class ironflow.model.node.DataNode(params)[source]

Bases: BatchingNode, ABC

A node that can update as soon as all input is valid and produces output data.

place_event()[source]

place_event() is called once the node object has been fully initialized and placed in the flow. When loading content, place_event() is executed before the connections are built, which is important for nodes that need to update once and, during this process, set output data values, to prevent later connected (potentially sequential) nodes from receiving false updates because of that. Notice that this method gets executed every time the node is added to the flow, which can happen multiple times for the same object, for example due to undo/redo operations. Also note that GUI content is usually not accessible yet from here, for that use view_place_event().

update_event(inp=-1)[source]

Gets called when an input received a signal or some node requested data of an output in exec mode

class ironflow.model.node.JobMaker(params)[source]

Bases: JobNode, ABC

A job-running node that takes creates a new job instance from scratch, ready to .run().

All descendant classes from this node class expect to have run, remove, name, and project input, and ran output. Therefore, when defining additional ports, use this format:

>>> init_inputs = JobMaker.init_inputs + [WHATEVER_ELSE_YOU_WANT]
>>> init_outputs = JobMaker.init_outputs + [OTHER_STUFF]
init_inputs: List[NodeInputBP] = [<ironflow.model.port.NodeInputBP object>, <ironflow.model.port.NodeInputBP object>, <ironflow.model.port.NodeInputBP object>, <ironflow.model.port.NodeInputBP object>]
class ironflow.model.node.JobNode(params)[source]

Bases: BatchingNode, ABC

A parent class for nodes that run a pyiron job.

Child classes are required to specify a _generate_job method, which takes the node input data and returns a pyiron_base.GenericJob object, and (optionally) a _get_output_from_job method which takes the executed job and the node input data and returns a dictionary of output with keys corresponding to node output port labels. The job output type can be made more specific with the valid_job_classes class attribute.

In the event that some of the input is batched but the name input is not batched, then the name argument passed to _generate_job is automatically appended with batch index information to prevent jobs from having the same name.

The node has run and remove input exec ports and a ran output exec port. Once the node has been run, all inputs get locked and remain locked until the removal process is triggered. Remove clears all the outputs and sets them to None.

If a failure is encountered during the run process, the exception is raised, all pyiron jobs are deleted (this might need to change if we want to do more expensive jobs in the future!), the node output is cleared, and the offending exception is raised to the log.

All descendant classes from this node class expect to have run, remove, and name input, and ran output. Therefore, when defining additional ports, use this format:

>>> init_inputs = JobNode.init_inputs + [WHATEVER_ELSE_YOU_WANT]
>>> init_outputs = JobNode.init_outputs + [OTHER_STUFF]
color = '#c4473f'
init_inputs: List[NodeInputBP] = [<ironflow.model.port.NodeInputBP object>, <ironflow.model.port.NodeInputBP object>, <ironflow.model.port.NodeInputBP object>]
init_outputs: List[NodeOutputBP] = [<ironflow.model.port.NodeOutputBP object>, <ironflow.model.port.NodeOutputBP object>]
node_function(name, *args, **kwargs)[source]

Takes all data input as kwargs, must return a dict with one entry for each data output

place_event()[source]

place_event() is called once the node object has been fully initialized and placed in the flow. When loading content, place_event() is executed before the connections are built, which is important for nodes that need to update once and, during this process, set output data values, to prevent later connected (potentially sequential) nodes from receiving false updates because of that. Notice that this method gets executed every time the node is added to the flow, which can happen multiple times for the same object, for example due to undo/redo operations. Also note that GUI content is usually not accessible yet from here, for that use view_place_event().

update(inp=-1)[source]

‘Activates’ the node, causing an update_event(); prints an exception if something crashed, but prevents the application from crashing in such a case

update_event(inp=-1)[source]

Gets called when an input received a signal or some node requested data of an output in exec mode

valid_job_classes = None
class ironflow.model.node.JobTaker(params)[source]

Bases: JobNode, ABC

A job-running node that takes a template job instance as input, and copies and modifies it prior to use.

Valid classes for the job input can be overriden with the valid_job_classes attribute.

All descendant classes from this node class expect to have run, remove, name, and job input, and ran output. Therefore, when defining additional ports, use this format:

>>> init_inputs = JobTaker.init_inputs + [WHATEVER_ELSE_YOU_WANT]
>>> init_outputs = JobTaker.init_outputs + [OTHER_STUFF]
init_inputs: List[NodeInputBP] = [<ironflow.model.port.NodeInputBP object>, <ironflow.model.port.NodeInputBP object>, <ironflow.model.port.NodeInputBP object>, <ironflow.model.port.NodeInputBP object>]
inputs: List[NodeInput]
outputs: List[NodeOutput]
place_event()[source]

place_event() is called once the node object has been fully initialized and placed in the flow. When loading content, place_event() is executed before the connections are built, which is important for nodes that need to update once and, during this process, set output data values, to prevent later connected (potentially sequential) nodes from receiving false updates because of that. Notice that this method gets executed every time the node is added to the flow, which can happen multiple times for the same object, for example due to undo/redo operations. Also note that GUI content is usually not accessible yet from here, for that use view_place_event().

class ironflow.model.node.Node(params)[source]

Bases: Node

A parent class for all ironflow nodes. Apart from a small quality-of-life difference where outputs are accessible in the same way as inputs (i.e. with a method output(i)), the main change here is the before_update and after_update events. Callbacks to happen before and after the update can be added to (removed from) these with the connect (disconnect) methods on the event. Such callbacks need to take the node itself as the first argument, and the integer specifying which input channel is being updated as the second argument.

Also provides a “representation” that gets used in the GUI to give a more detailed look at node data, which defaults to showing output channel values.

Children should specify a title and some combination of initial input, output, and what to do when updated, e.g.:

>>> class My_Node(Node):
>>>     title = "MyUserNode"
>>>     init_inputs = [
>>>         NodeInputBP(dtype=dtypes.Integer(default=1), label="foo")
>>>     ]
>>>     init_outputs = [
>>>        NodeOutputBP(label="bar")
>>>     ]
>>>     color = 'cyan'
>>>
>>> def update_event(self, inp=-1):
>>>     self.set_output_val(0, self.input(0) + 42)

Note

When registering nodes from a module or .py file, only children of this class with names ending in _Node will get registered.

property all_input_is_valid
color = '#ff69b4'
create_input(type_: str = 'data', label: str = '', add_data: dict | None = None, dtype: DType | None = None, otype: Thing | None = None, insert: int | None = None)[source]

Creates and add a new input port

create_input_dt(dtype: DType, label: str = '', add_data={}, insert: int = None)[source]

Creates and adds a new data input with a DType

create_output(type_: str = 'data', label: str = '', dtype: DType | None = None, otype: Thing | None = None, insert: int | None = None)[source]

Create and add a new output port

property extra_representations

When developing nodes, override this with any desired additional representations.

Note that standard representations exist for all output ports using the port’s label (where available), so if you add a key here matching one of those labels, you will override the standard output.

main_widget_class

alias of NodeWidget

output(i)[source]
place_event()[source]

place_event() is called once the node object has been fully initialized and placed in the flow. When loading content, place_event() is executed before the connections are built, which is important for nodes that need to update once and, during this process, set output data values, to prevent later connected (potentially sequential) nodes from receiving false updates because of that. Notice that this method gets executed every time the node is added to the flow, which can happen multiple times for the same object, for example due to undo/redo operations. Also note that GUI content is usually not accessible yet from here, for that use view_place_event().

property representations: dict
set_all_outputs_to_none()[source]
setup_ports(inputs_data=None, outputs_data=None)[source]
update(inp=-1)[source]

‘Activates’ the node, causing an update_event(); prints an exception if something crashed, but prevents the application from crashing in such a case

class ironflow.model.node.PlaceholderWidgetsContainer[source]

Bases: object

An object that just returns None for all accessed attributes so widgets.MyWidget in the non-ironflow nodes files just returns None.

class ironflow.model.node.PortFinder(port_list: PortList)[source]

Bases: object

class ironflow.model.node.PortList(*args, **kwargs)[source]

Bases: list

When used to hold a collection of NodePort objects, the values of these ports then become accessible by their labels, as long as those labels do not match an existing method of the builtin list class.

Warning

This class makes no check that these labels are unique; if multiple items have the same label, the first one is returned.

Warning

Accessing port values in this way side-steps ryven functionality when in exec mode or using an executor (i.e. when running_with_executor).

property labels
property ports

Allows attribute-like access to ports by their label_str

property values

Allows attribute-like access to port values by their label_str

Calling port_list.values.some_label is equivalent to port_list.ports.some_label.val

class ironflow.model.node.ValueFinder(port_list: PortList)[source]

Bases: PortFinder