pyiron_workflow.mixin.preview module

Mixin classes for classes which offer previews of input and output at the _class_ level.

The intent is for mixing with pyiron_workflow.node.Node, and for the inputs and outputs to be IO channels there, but in principle this should function just fine independently.

These previews need to be available at the class level so that suggestion menus and ontologies can know how mixin classes relate to the rest of the world via input and output without first having to instantiate them.

class pyiron_workflow.mixin.preview.HasIOPreview[source]

Bases: ABC

An interface mixin guaranteeing the class-level availability of input and output previews.

E.g. for pyiron_workflow.node.Node that have input and output channels.

classmethod preview_inputs() dict[str, tuple[Any, Any]][source]

Gives a class-level peek at the expected inputs.

Returns:

The input name and a tuple of its

corresponding type hint and default value.

Return type:

dict[str, tuple[Any, Any]]

classmethod preview_io() DotDict[str, dict[str, Any | tuple[Any, Any]]][source]
classmethod preview_outputs() dict[str, Any][source]

Gives a class-level peek at the expected outputs.

Returns:

The output name and its corresponding type hint.

Return type:

dict[str, Any]

class pyiron_workflow.mixin.preview.ScrapesIO[source]

Bases: HasIOPreview, ABC

A mixin class for scraping IO channel information from a specific class method’s signature and returns.

Requires that the (static and class) method _io_defining_function() be specified in child classes, as well as _io_defining_function_uses_self(). Optionally, _output_labels can be overridden at the class level to avoid scraping the return signature for channel labels altogether.

Since scraping returns is only possible when the function source code is available, this can be bypassed by manually specifying the class attribute _output_labels.

_output_labels

The output labels to use. If None, scrapes them from the io-defining function. (Default is None.)

Type:

tuple[str] | None

_validate_output_labels

Whether to

Type:

bool

_io_defining_function_uses_self

Whether the signature of the IO defining function starts with self. When true, the first argument in the _io_defining_function() is ignored. (Default is False, use the entire signature for specifying input.)

Type:

bool

Warning

There are a number of class features which, for computational efficiency, get calculated at first call and any subsequent calls return that initial value (including on other instances, since these are class properties); these depend on the _io_defining_function() and its signature, which should thus be left static from the time of class definition onwards.

pyiron_workflow.mixin.preview.no_output_validation_warning(cls: type)[source]