Skip to content

Commit

Permalink
Format black
Browse files Browse the repository at this point in the history
  • Loading branch information
pyiron-runner committed Apr 29, 2024
1 parent d620c7b commit 9f0955d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
6 changes: 3 additions & 3 deletions pyiron_workflow/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ def decorator(node_function):
factory_made._class_returns_from_decorated_function = node_function
factory_made.preview_io()
return factory_made

return decorator


Expand All @@ -379,16 +380,15 @@ def function_node(
*node_args,
output_labels=None,
validate_output_labels=True,
**node_kwargs
**node_kwargs,
):
if output_labels is None:
output_labels = ()
elif isinstance(output_labels, str):
output_labels = (output_labels,)
function_node_factory.clear(node_function.__name__) # Force a fresh class
function_node_factory.clear(node_function.__name__) # Force a fresh class
factory_made = function_node_factory(
node_function, validate_output_labels, *output_labels
)
factory_made.preview_io()
return factory_made(*node_args, **node_kwargs)

12 changes: 10 additions & 2 deletions pyiron_workflow/io_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
from textwrap import dedent
from types import FunctionType
from typing import (
Any, ClassVar, get_args, get_type_hints, Literal, Optional, TYPE_CHECKING
Any,
ClassVar,
get_args,
get_type_hints,
Literal,
Optional,
TYPE_CHECKING,
)

from pyiron_workflow.channels import InputData, NOT_DATA
Expand Down Expand Up @@ -134,7 +140,9 @@ def _io_defining_function(cls) -> callable:

_output_labels: ClassVar[tuple[str] | None] = None # None: scrape them
_validate_output_labels: ClassVar[bool] = True # True: validate against source code
_io_defining_function_uses_self: ClassVar[bool] = False # False: use entire signature
_io_defining_function_uses_self: ClassVar[bool] = (
False # False: use entire signature
)

@classmethod
def _build_inputs_preview(cls):
Expand Down
9 changes: 6 additions & 3 deletions pyiron_workflow/macro.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ def __setstate__(self, state):


@classfactory
def macro_node_factory(graph_creator: callable, validate_output_labels: bool, /, *output_labels
def macro_node_factory(
graph_creator: callable, validate_output_labels: bool, /, *output_labels
):
return (
graph_creator.__name__,
Expand All @@ -496,6 +497,7 @@ def decorator(node_function):
factory_made._class_returns_from_decorated_function = node_function
factory_made.preview_io()
return factory_made

return decorator


Expand All @@ -504,19 +506,20 @@ def macro_node(
*node_args,
output_labels=None,
validate_output_labels=True,
**node_kwargs
**node_kwargs,
):
if output_labels is None:
output_labels = ()
elif isinstance(output_labels, str):
output_labels = (output_labels,)
macro_node_factory.clear(node_function.__name__) # Force a fresh class
macro_node_factory.clear(node_function.__name__) # Force a fresh class
factory_made = macro_node_factory(
node_function, validate_output_labels, *output_labels
)
factory_made.preview_io()
return factory_made(*node_args, **node_kwargs)


# as_macro_node = decorated_node_decorator_factory(
# Macro,
# Macro.graph_creator,
Expand Down

0 comments on commit 9f0955d

Please sign in to comment.