Skip to content

Commit 6a72657

Browse files
committed
added definition to Result attributes that need to be cloudpickled
1 parent 92cf378 commit 6a72657

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

new-docs/source/tutorial/3-troubleshooting.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@
128128
"# This workflow will fail because we are trying to divide by 0\n",
129129
"wf = UnsafeDivisionWorkflow(a=10, b=5).split(denominator=[3, 2 ,0])\n",
130130
"\n",
131-
"with Submitter(worker=\"cf\") as sub:\n",
132-
" result = sub(wf)\n",
131+
"if __name__ == \"__main__\":\n",
132+
" with Submitter(worker=\"cf\") as sub:\n",
133+
" result = sub(wf)\n",
133134
" \n",
134135
"if result.errored:\n",
135136
" print(\"Workflow failed with errors:\\n\" + str(result.errors))\n",

pydra/engine/specs.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,15 +531,19 @@ class Result(ty.Generic[OutputsType]):
531531
errored: bool = False
532532
definition: TaskDef[OutputsType] | None = None
533533

534+
CLOUD_PICKLE_ATTRS = ("outputs", "definition")
535+
534536
def __getstate__(self):
535537
state = attrs_values(self)
536-
if state["outputs"] is not None:
537-
state["outputs"] = cp.dumps(state["outputs"])
538+
for attr in self.CLOUD_PICKLE_ATTRS:
539+
if state[attr] is not None:
540+
state[attr] = cp.dumps(state[attr])
538541
return state
539542

540543
def __setstate__(self, state):
541-
if state["outputs"] is not None:
542-
state["outputs"] = cp.loads(state["outputs"])
544+
for attr in self.CLOUD_PICKLE_ATTRS:
545+
if state[attr] is not None:
546+
state[attr] = cp.loads(state[attr])
543547
for name, val in state.items():
544548
setattr(self, name, val)
545549

0 commit comments

Comments
 (0)