cadence-python icon indicating copy to clipboard operation
cadence-python copied to clipboard

[Question] Behaviour when receiving a struct / dataclass

Open MrSaints opened this issue 4 years ago • 1 comments

We are considering implementing activities in Python, and workflows in Go. When calling activities in Go, it is possible to pass a struct to the activity (e.g. https://github.com/uber-common/cadence-samples/blob/56c4ffffd38e8596075c56f03f82c5a80ae77b92/cmd/samples/fileprocessing/activities.go). We are curious about what the behaviour is like when the activity is implemented using this Python client. Judging from https://github.com/firdaus/cadence-python/blob/729420cfcd5adb0496005758f1d8d6eb1d5a2223/cadence/conversions.py#L125, it seems like the argument will simply be a Python dictionary. If this is the case, are there any plans for automatically converting this to say a Python dataclass?

The use-case for using a single parameter (much like a single message) activity is for versioning. It has been mentioned several times, and the solution seems to always point to this approach for dealing with an activity's contract.

MrSaints avatar Dec 18 '19 15:12 MrSaints

I missed this requirement. Thanks for bringing this to my attention. At the moment everything becomes a Python primitive, list or dictionary.

I'll add this to 1.1 release. It should be fairly trivial to support as long as the activity method is type annotated.

firdaus avatar Dec 21 '19 00:12 firdaus