Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions pyiron_workflow/mixin/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import inspect
from abc import ABC, abstractmethod
from collections.abc import Callable
from functools import lru_cache, wraps
from functools import lru_cache
from typing import (
TYPE_CHECKING,
Any,
Expand Down Expand Up @@ -82,22 +82,6 @@ def preview_io(cls) -> DotDict[str, dict]:
)


def builds_class_io(subclass_factory: Callable[..., type[HasIOPreview]]):
"""
A decorator for factories producing subclasses of `HasIOPreview` to invoke
:meth:`preview_io` after the class is created, thus ensuring the IO has been
constructed at the class level.
"""

@wraps(subclass_factory)
def wrapped(*args, **kwargs):
node_class = subclass_factory(*args, **kwargs)
node_class.preview_io()
return node_class

return wrapped


class ScrapesIO(HasIOPreview, ABC):
"""
A mixin class for scraping IO channel information from a specific class method's
Expand Down
12 changes: 7 additions & 5 deletions pyiron_workflow/nodes/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from pyiron_snippets.factory import classfactory

from pyiron_workflow.channels import NOT_DATA, NotData
from pyiron_workflow.mixin.preview import builds_class_io
from pyiron_workflow.nodes.static_io import StaticNode


Expand Down Expand Up @@ -107,7 +106,6 @@ def _build_outputs_preview(cls) -> dict[str, Any]:
return {f"item_{i}": None for i in range(cls._length)}


@builds_class_io
@classfactory
def inputs_to_list_factory(n: int, use_cache: bool = True, /) -> type[InputsToList]:
return (
Expand Down Expand Up @@ -137,10 +135,11 @@ def inputs_to_list(n: int, /, *node_args, use_cache: bool = True, **node_kwargs)
InputsToList: An instance of the dynamically created :class:`InputsToList`
subclass.
"""
return inputs_to_list_factory(n, use_cache)(*node_args, **node_kwargs)
cls = inputs_to_list_factory(n, use_cache)
cls.preview_io()
return cls(*node_args, **node_kwargs)


@builds_class_io
@classfactory
def list_to_outputs_factory(n: int, use_cache: bool = True, /) -> type[ListToOutputs]:
return (
Expand Down Expand Up @@ -172,7 +171,10 @@ def list_to_outputs(
ListToOutputs: An instance of the dynamically created :class:`ListToOutputs`
subclass.
"""
return list_to_outputs_factory(n, use_cache)(*node_args, **node_kwargs)

cls = list_to_outputs_factory(n, use_cache)
cls.preview_io()
return cls(*node_args, **node_kwargs)


class InputsToDict(FromManyInputs, ABC):
Expand Down
Loading