Repository navigation
fix(serialization): support MutableMapping and MutableSequence container traversal in can_reconstruct - #354
Conversation
…erce_generic Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…oerce_generic Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…MutableMapping Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…MutableSequence Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…bleMapping and MutableSequence Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…ainer support Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
|
Hi maintainers, Bernd Verst (@berndverst) and andystaples I've opened this PR to address #352 by extending type-directed reconstruction to support I've also added regression coverage for serialization round-trips, type discovery, and activity input reconstruction, along with the relevant documentation and changelog updates. Validation is passing: 191 tests passed, and Whenever you have a moment, I'd appreciate your review and feedback. Thank you! |
|
Hardik K (@hardikkaurani) we will not accept PRs for issues that have been opened by the PR author just moments earlier. An issue at minimum requires community discussion or triage from maintainers. No unsolicited PRs please. We already went over this with your previous contribution: #310 (comment) The issue requires triage from andystaples or myself (Bernd Verst (@berndverst)) before we will accept a PR. |
|
Hi Bernd Verst (@berndverst) and andystaples Thanks for clarifying. I understand your contribution process and acknowledge that I should have waited for maintainer triage and community discussion before opening this PR. I'll keep this in mind for future contributions and avoid submitting PRs for issues that haven't been discussed or triaged first. Apologies for overlooking this, and thanks for taking the time to clarify the expectations. |
Summary of Changes
Closes #352
While
_coerce_generic()and_can_reconstruct()indurabletask/serialization.pysupport type-directed coercion fordict/Mapping,tuple, andlist/Sequencecontainers, they previously omitted support forcollections.abc.MutableMappingandcollections.abc.MutableSequence.As a result:
converter.can_reconstruct()returnedFalsefor annotations such asMutableMapping[str, MyModel]andMutableSequence[MyModel].type_discovery.activity_input_typeandorchestrator_input_typediscarded these annotations and returnedNone, causing activities and orchestrators to receive uncoerced dictionaries and lists instead of typed model instances.target_type=MutableMapping[str, MyModel]orMutableSequence[MyModel]bypassed element-wise coercion.This change:
MutableMappingandMutableSequenceto_can_reconstruct(), enabling recursive model reconstructability checks when their value or element types are reconstructable._coerce_generic()to recursively coerce items forMutableMappingandMutableSequenceannotations.MutableMappingandMutableSequencecontainer support indurabletask/serialization.pyand the core and Azure Managed changelogs.Changes Across Commits
Commit 1:
fix(serialization): support MutableMapping in can_reconstruct and _coerce_genericMutableMappingfromcollections.abcand add it to_can_reconstruct()and_coerce_generic().Commit 2:
fix(serialization): support MutableSequence in can_reconstruct and _coerce_genericMutableSequencefromcollections.abcand add it to_can_reconstruct()and_coerce_generic().Commit 3:
test(serialization): verify can_reconstruct and deserialization with MutableMappingcan_reconstruct()and round-trip deserialization forMutableMapping[str, Model].Commit 4:
test(serialization): verify can_reconstruct and deserialization with MutableSequencecan_reconstruct()and round-trip deserialization forMutableSequence[Model].Commit 5:
test(worker): verify type discovery and input reconstruction for MutableMapping and MutableSequenceMutableMapping[str, Order]andMutableSequence[Order]correctly receive reconstructed dataclass instances.Commit 6:
docs(serialization): document MutableMapping and MutableSequence container supportdurabletask/serialization.pyand document the change inCHANGELOG.mdanddurabletask-azuremanaged/CHANGELOG.md.Verification
pytest tests/durabletask/test_serialization.py tests/durabletask/test_type_discovery.py tests/durabletask/test_data_converter_roundtrip.py(191/191 passed)ruff check .(All checks passed)