Conversation
d30b11b to
4b87d75
Compare
|
superseded by #115 |
4b87d75 to
13998d2
Compare
- Adds serialization for batch result in the serdes module. Unfortunately we need to do an adhoc import as we are dealing with cyclical dependencies.
13998d2 to
bbed24a
Compare
Changes: - add tests to verify BatchResult is serialized - add tests to verify BatchResult actually serializes by default - add tests to verify we pass custom serdes and that is used to serialize BatchResult
| with patch.object( | ||
| DurableContext, "_create_step_id_for_logical_step", create_id | ||
| ): | ||
| context = DurableContext(state=mock_state) | ||
| result = context.map(["a", "b"], lambda ctx, item, idx, items: item) | ||
|
|
||
| assert len(mock_serdes_serialize.call_args_list) == 3 | ||
| parent_call = mock_serdes_serialize.call_args_list[2] | ||
| assert parent_call[1]["value"] is result |
There was a problem hiding this comment.
Verify that we have called serialize with the same BatchResult that we are actually returning.
| assert isinstance(result, BatchResult) | ||
| assert len(mock_serialize.call_args_list) == 3 | ||
| parent_call = mock_serialize.call_args_list[2] | ||
| assert parent_call[1]["serdes"] is None | ||
| assert isinstance(parent_call[1]["value"], BatchResult) | ||
| assert parent_call[1]["value"] is result | ||
|
|
There was a problem hiding this comment.
Verify that we have called with the same BatchResult we return, and default serializer actually serializes.
| with patch( | ||
| "aws_durable_execution_sdk_python.serdes.serialize", wraps=serialize | ||
| ) as mock_serialize: | ||
| importlib.reload(child_module) |
There was a problem hiding this comment.
We wrap to ensure we are actually calling serialize
| assert isinstance(result, BatchResult) | ||
| assert len(mock_serialize.call_args_list) == 3 | ||
| parent_call = mock_serialize.call_args_list[2] | ||
| assert parent_call[1]["serdes"] is custom_serdes | ||
| assert isinstance(parent_call[1]["value"], BatchResult) | ||
| assert parent_call[1]["value"] is result |
There was a problem hiding this comment.
Ensure custom serdes is actually called with same returned batch result, and we call serialize.
wangyb-A
left a comment
There was a problem hiding this comment.
LGTM!
concurrency/__init __ .py exists cuz Ruff was complaining :D
| case list() | tuple() | dict(): | ||
| return self.container_codec.encode(obj) | ||
| case _: | ||
| if isinstance(obj, BatchResult): |
There was a problem hiding this comment.
why here too? (see line 248)
There was a problem hiding this comment.
Oooopsies, remnant from cyclical dependency
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.