Skip to content

Commit 3beda9b

Browse files
committed
Add workflow from_payload context
1 parent c458c60 commit 3beda9b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

temporalio/worker/_workflow_instance.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,12 @@ def _make_workflow_input(
10291029
if not self._defn.name:
10301030
# Dynamic is just the raw value for each input value
10311031
arg_types = [temporalio.common.RawValue] * len(init_job.arguments)
1032-
args = self._convert_payloads(init_job.arguments, arg_types)
1032+
1033+
context = temporalio.converter.WorkflowSerializationContext(
1034+
namespace=self._info.namespace,
1035+
workflow_id=self._info.workflow_id,
1036+
)
1037+
args = self._convert_payloads(init_job.arguments, arg_types, context)
10331038
# Put args in a list if dynamic
10341039
if not self._defn.name:
10351040
args = [args]
@@ -1987,17 +1992,18 @@ def _convert_payloads(
19871992
self,
19881993
payloads: Sequence[temporalio.api.common.v1.Payload],
19891994
types: Optional[List[Type]],
1995+
context: temporalio.converter.SerializationContext,
19901996
) -> List[Any]:
19911997
if not payloads:
19921998
return []
19931999
# Only use type hints if they match count
19942000
if types and len(types) != len(payloads):
19952001
types = None
19962002
try:
1997-
return self._payload_converter.from_payloads(
1998-
payloads,
1999-
type_hints=types,
2000-
)
2003+
converter = self._payload_converter
2004+
if isinstance(converter, temporalio.converter.WithSerializationContext):
2005+
converter = converter.with_context(context)
2006+
return converter.from_payloads(payloads, type_hints=types)
20012007
except temporalio.exceptions.FailureError:
20022008
# Don't wrap payload conversion errors that would fail the workflow
20032009
raise

0 commit comments

Comments
 (0)