|
62 | 62 | import temporalio.service |
63 | 63 | import temporalio.workflow |
64 | 64 | from temporalio.activity import ActivityCancellationDetails |
65 | | -from temporalio.converter import WorkflowSerializationContext |
| 65 | +from temporalio.converter import ( |
| 66 | + ActivitySerializationContext, |
| 67 | + DataConverter, |
| 68 | + WorkflowSerializationContext, |
| 69 | +) |
66 | 70 | from temporalio.service import ( |
67 | 71 | HttpConnectProxyConfig, |
68 | 72 | KeepAliveConfig, |
@@ -6382,6 +6386,7 @@ async def _start_workflow_update_with_start( |
6382 | 6386 | async def heartbeat_async_activity( |
6383 | 6387 | self, input: HeartbeatAsyncActivityInput |
6384 | 6388 | ) -> None: |
| 6389 | + # TODO |
6385 | 6390 | details = ( |
6386 | 6391 | None |
6387 | 6392 | if not input.details |
@@ -6435,11 +6440,29 @@ async def heartbeat_async_activity( |
6435 | 6440 | ) |
6436 | 6441 | ) |
6437 | 6442 |
|
| 6443 | + def _async_activity_data_converter( |
| 6444 | + self, id_or_token: Union[AsyncActivityIDReference, bytes] |
| 6445 | + ) -> DataConverter: |
| 6446 | + context = ActivitySerializationContext( |
| 6447 | + namespace=self._client.namespace, |
| 6448 | + workflow_id=( |
| 6449 | + id_or_token.workflow_id |
| 6450 | + if isinstance(id_or_token, AsyncActivityIDReference) |
| 6451 | + else "" |
| 6452 | + ), |
| 6453 | + workflow_type="", |
| 6454 | + activity_type="", |
| 6455 | + activity_task_queue="", |
| 6456 | + is_local=False, |
| 6457 | + ) |
| 6458 | + return self._client.data_converter._with_context(context) |
| 6459 | + |
6438 | 6460 | async def complete_async_activity(self, input: CompleteAsyncActivityInput) -> None: |
| 6461 | + data_converter = self._async_activity_data_converter(input.id_or_token) |
6439 | 6462 | result = ( |
6440 | 6463 | None |
6441 | 6464 | if input.result is temporalio.common._arg_unset |
6442 | | - else await self._client.data_converter.encode_wrapper([input.result]) |
| 6465 | + else await data_converter.encode_wrapper([input.result]) |
6443 | 6466 | ) |
6444 | 6467 | if isinstance(input.id_or_token, AsyncActivityIDReference): |
6445 | 6468 | await self._client.workflow_service.respond_activity_task_completed_by_id( |
@@ -6469,14 +6492,14 @@ async def complete_async_activity(self, input: CompleteAsyncActivityInput) -> No |
6469 | 6492 | ) |
6470 | 6493 |
|
6471 | 6494 | async def fail_async_activity(self, input: FailAsyncActivityInput) -> None: |
| 6495 | + data_converter = self._async_activity_data_converter(input.id_or_token) |
| 6496 | + |
6472 | 6497 | failure = temporalio.api.failure.v1.Failure() |
6473 | | - await self._client.data_converter.encode_failure(input.error, failure) |
| 6498 | + await data_converter.encode_failure(input.error, failure) |
6474 | 6499 | last_heartbeat_details = ( |
6475 | 6500 | None |
6476 | 6501 | if not input.last_heartbeat_details |
6477 | | - else await self._client.data_converter.encode_wrapper( |
6478 | | - input.last_heartbeat_details |
6479 | | - ) |
| 6502 | + else await data_converter.encode_wrapper(input.last_heartbeat_details) |
6480 | 6503 | ) |
6481 | 6504 | if isinstance(input.id_or_token, AsyncActivityIDReference): |
6482 | 6505 | await self._client.workflow_service.respond_activity_task_failed_by_id( |
@@ -6510,10 +6533,11 @@ async def fail_async_activity(self, input: FailAsyncActivityInput) -> None: |
6510 | 6533 | async def report_cancellation_async_activity( |
6511 | 6534 | self, input: ReportCancellationAsyncActivityInput |
6512 | 6535 | ) -> None: |
| 6536 | + data_converter = self._async_activity_data_converter(input.id_or_token) |
6513 | 6537 | details = ( |
6514 | 6538 | None |
6515 | 6539 | if not input.details |
6516 | | - else await self._client.data_converter.encode_wrapper(input.details) |
| 6540 | + else await data_converter.encode_wrapper(input.details) |
6517 | 6541 | ) |
6518 | 6542 | if isinstance(input.id_or_token, AsyncActivityIDReference): |
6519 | 6543 | await self._client.workflow_service.respond_activity_task_canceled_by_id( |
|
0 commit comments