Skip to content

Commit

Permalink
🔥 🐛 remove semantic children from the state on __setstate__ (#372)
Browse files Browse the repository at this point in the history
This is the inverse operation to adding them to the state in __getstate__. Without this, in the subsequent super call, all these children wind up in __dict__.
  • Loading branch information
liamhuber authored Jun 25, 2024
1 parent 6c092c4 commit 3a3b3ee
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pyiron_workflow/mixin/semantics.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,12 @@ def __getstate__(self):

def __setstate__(self, state):
# Reconstruct children from state
# Remove them from the state as you go, so they don't hang around in the
# __dict__ after we set state -- they were only there to start with to guarantee
# that the state path and the semantic path matched (i.e. without ".children."
# in between)
state["_children"] = bidict(
{label: state[label] for label in state.pop("child_labels")}
{label: state.pop(label) for label in state.pop("child_labels")}
)

super().__setstate__(state)
Expand Down

0 comments on commit 3a3b3ee

Please sign in to comment.