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

IO maps #559

Merged
merged 3 commits into from
Jan 17, 2025
Merged
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
34 changes: 17 additions & 17 deletions pyiron_workflow/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,8 @@ def __init__(
automate_execution: bool = True,
**kwargs,
):
self._inputs_map = None
self._outputs_map = None
self.inputs_map = inputs_map
self.outputs_map = outputs_map
self._inputs_map = self._sanitize_map(inputs_map)
self._outputs_map = self._sanitize_map(outputs_map)
self._inputs = None
self._outputs = None
self.automate_execution: bool = automate_execution
Expand Down Expand Up @@ -264,34 +262,36 @@ def _after_node_setup(

@property
def inputs_map(self) -> bidict | None:
self._deduplicate_nones(self._inputs_map)
if self._inputs_map is not None:
self._deduplicate_nones(self._inputs_map)
return self._inputs_map

@inputs_map.setter
def inputs_map(self, new_map: dict | bidict | None):
self._deduplicate_nones(new_map)
if new_map is not None:
new_map = bidict(new_map)
self._inputs_map = new_map
self._inputs_map = self._sanitize_map(new_map)

@property
def outputs_map(self) -> bidict | None:
self._deduplicate_nones(self._outputs_map)
if self._outputs_map is not None:
self._deduplicate_nones(self._outputs_map)
return self._outputs_map

@outputs_map.setter
def outputs_map(self, new_map: dict | bidict | None):
self._deduplicate_nones(new_map)
self._outputs_map = self._sanitize_map(new_map)

def _sanitize_map(self, new_map: dict | bidict | None) -> bidict | None:
if new_map is not None:
if isinstance(new_map, dict):
self._deduplicate_nones(new_map)
new_map = bidict(new_map)
self._outputs_map = new_map
return new_map

@staticmethod
def _deduplicate_nones(some_map: dict | bidict | None) -> dict | bidict | None:
if some_map is not None:
for k, v in some_map.items():
if v is None:
some_map[k] = (None, f"{k} disabled")
def _deduplicate_nones(some_map: dict | bidict):
for k, v in some_map.items():
if v is None:
some_map[k] = (None, f"{k} disabled")

@property
def inputs(self) -> Inputs:
Expand Down
Loading