Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow: Remove storage priority #736

Merged
merged 2 commits into from
Jun 23, 2023
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
4 changes: 0 additions & 4 deletions pyiron_contrib/workflow/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,11 @@ def __init__(
node: Node,
default: typing.Optional[typing.Any] = None,
type_hint: typing.Optional[typing.Any] = None,
storage_priority: int = 0,
):
super().__init__(label=label, node=node)
self.default = default
self.value = default
self.type_hint = type_hint
self.storage_priority = storage_priority

@property
def ready(self) -> bool:
Expand Down Expand Up @@ -317,15 +315,13 @@ def __init__(
node: Node,
default: typing.Optional[typing.Any] = None,
type_hint: typing.Optional[typing.Any] = None,
storage_priority: int = 0,
strict_connections: bool = True,
):
super().__init__(
label=label,
node=node,
default=default,
type_hint=type_hint,
storage_priority=storage_priority,
)
self.strict_connections = strict_connections
self.waiting_for_update = False
Expand Down
4 changes: 0 additions & 4 deletions pyiron_contrib/workflow/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,6 @@ def to_value_dict(self):
def ready(self):
return all([c.ready for c in self])

def set_storage_priority(self, priority: int):
for c in self:
c.storage_priority = priority

def to_dict(self):
d = super().to_dict()
d["ready"] = self.ready
Expand Down
42 changes: 4 additions & 38 deletions pyiron_contrib/workflow/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,6 @@ class with a function and labels for its output, like so:
... def __init__(
... self,
... label: Optional[str] = None,
... input_storage_priority: Optional[dict[str, int]] = None,
... output_storage_priority: Optional[dict[str, int]] = None,
... run_on_updates: bool = True,
... update_on_instantiation: bool = False,
... **kwargs
Expand All @@ -257,8 +255,6 @@ class with a function and labels for its output, like so:
... self.alphabet_mod_three,
... "letter",
... labe=label,
... input_storage_priority=input_storage_priority,
... output_storage_priority=output_storage_priority,
... run_on_updates=run_on_updates,
... update_on_instantiation=update_on_instantiation,
... **kwargs
Expand Down Expand Up @@ -315,8 +311,6 @@ def __init__(
node_function: callable,
*output_labels: str,
label: Optional[str] = None,
input_storage_priority: Optional[dict[str, int]] = None,
output_storage_priority: Optional[dict[str, int]] = None,
run_on_updates: bool = False,
update_on_instantiation: bool = False,
channels_requiring_update_after_run: Optional[list[str]] = None,
Expand All @@ -336,12 +330,10 @@ def __init__(
if parent is not None:
parent.add(self)

input_channels = self._build_input_channels(input_storage_priority)
input_channels = self._build_input_channels()
self.inputs = Inputs(*input_channels)

output_channels = self._build_output_channels(
*output_labels, storage_priority=output_storage_priority
)
output_channels = self._build_output_channels(*output_labels)
self.outputs = Outputs(*output_channels)

self.signals = self._build_signal_channels()
Expand All @@ -364,7 +356,7 @@ def __init__(
if update_on_instantiation:
self.update()

def _build_input_channels(self, storage_priority: dict[str:int]):
def _build_input_channels(self):
channels = []
type_hints = get_type_hints(self.node_function)
parameters = inspect.signature(self.node_function).parameters
Expand All @@ -378,11 +370,6 @@ def _build_input_channels(self, storage_priority: dict[str:int]):
f"name _not_ among {self._init_keywords}"
)

try:
priority = storage_priority[label]
except (KeyError, TypeError):
priority = None

try:
type_hint = type_hints[label]
except KeyError:
Expand All @@ -399,7 +386,6 @@ def _build_input_channels(self, storage_priority: dict[str:int]):
node=self,
default=default,
type_hint=type_hint,
storage_priority=priority,
)
)
return channels
Expand All @@ -408,9 +394,7 @@ def _build_input_channels(self, storage_priority: dict[str:int]):
def _init_keywords(self):
return list(inspect.signature(self.__init__).parameters.keys())

def _build_output_channels(
self, *return_labels: str, storage_priority: dict[str:int] = None
):
def _build_output_channels(self, *return_labels: str):
try:
type_hints = get_type_hints(self.node_function)["return"]
if len(return_labels) > 1:
Expand All @@ -435,17 +419,11 @@ def _build_output_channels(

channels = []
for label, hint in zip(return_labels, type_hints):
try:
priority = storage_priority[label]
except (KeyError, TypeError):
priority = None

channels.append(
OutputData(
label=label,
node=self,
type_hint=hint,
storage_priority=priority,
)
)

Expand Down Expand Up @@ -541,10 +519,6 @@ def fully_connected(self):
and self.signals.fully_connected
)

def set_storage_priority(self, priority: int):
self.inputs.set_storage_priority(priority)
self.outputs.set_storage_priority(priority)

def to_dict(self):
return {
"label": self.label,
Expand All @@ -569,8 +543,6 @@ def __init__(
node_function: callable,
*output_labels: str,
label: Optional[str] = None,
input_storage_priority: Optional[dict[str, int]] = None,
output_storage_priority: Optional[dict[str, int]] = None,
run_on_updates=True,
update_on_instantiation=True,
parent: Optional[Workflow] = None,
Expand All @@ -581,8 +553,6 @@ def __init__(
node_function,
*output_labels,
label=label,
input_storage_priority=input_storage_priority,
output_storage_priority=output_storage_priority,
run_on_updates=run_on_updates,
update_on_instantiation=update_on_instantiation,
parent=parent,
Expand Down Expand Up @@ -615,8 +585,6 @@ def __init__(
node_function: callable,
*output_labels: str,
label: Optional[str] = None,
input_storage_priority: Optional[dict[str, int]] = None,
output_storage_priority: Optional[dict[str, int]] = None,
run_on_updates=True,
update_on_instantiation=True,
parent: Optional[Workflow] = None,
Expand All @@ -627,8 +595,6 @@ def __init__(
node_function,
*output_labels,
label=label,
input_storage_priority=input_storage_priority,
output_storage_priority=output_storage_priority,
run_on_updates=run_on_updates,
update_on_instantiation=update_on_instantiation,
parent=parent,
Expand Down