Skip to content

Commit 3c27b2a

Browse files
committed
FIX: Allow input_spec/output_spec to be class variables
1 parent dcfd0dc commit 3c27b2a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pydra/engine/core.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,10 @@ def __str__(self):
198198

199199
def __getstate__(self):
200200
state = self.__dict__.copy()
201-
state["input_spec"] = cp.dumps(state["input_spec"])
202-
state["output_spec"] = cp.dumps(state["output_spec"])
201+
if "input_spec" in state:
202+
state["input_spec"] = cp.dumps(state["input_spec"])
203+
if "output_spec" in state:
204+
state["output_spec"] = cp.dumps(state["output_spec"])
203205
inputs = {}
204206
for k, v in attr.asdict(state["inputs"]).items():
205207
if k.startswith("_"):
@@ -209,9 +211,12 @@ def __getstate__(self):
209211
return state
210212

211213
def __setstate__(self, state):
212-
state["input_spec"] = cp.loads(state["input_spec"])
213-
state["output_spec"] = cp.loads(state["output_spec"])
214-
state["inputs"] = make_klass(state["input_spec"])(**state["inputs"])
214+
if "input_spec" in state:
215+
state["input_spec"] = cp.loads(state["input_spec"])
216+
if "output_spec" in state:
217+
state["output_spec"] = cp.loads(state["output_spec"])
218+
input_spec = state.get("input_spec", self.input_spec)
219+
state["inputs"] = make_klass(input_spec)(**state["inputs"])
215220
self.__dict__.update(state)
216221

217222
def __getattr__(self, name):

0 commit comments

Comments
 (0)