-
Notifications
You must be signed in to change notification settings - Fork 420
Feature request: Support of custom serizialization/deserisialization (object -> dict) on idempotency decorator 'idempotent_function' #2886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
@heitorlessa FYI, @aradyaron is a co-worker and a serverless ninja :) |
heey @aradyaron firstly, big welcome and thank you for a nicely detailed feature request too! If you have bandwidth, we'd love a PR on this so we can prioritize it (Observability Provider and Event Handler OpenAPI are taking most of our bandwidth now). Two quick UX notes for now (might have more during implementation):
PS: You're lucky to work with @ran-isenberg ;) |
Hey @heitorlessa, thanks!
|
Awesome! I had a piece of paper to think through this design now for the last 10m and I was wrong in recommending the global config -- it's best in the decorator as you initially suggested. I can't think of an use case where you'd want to use the same For |
Ah btw, I'm on Discord if you ever get stuck -- Idempotency is the most complex part of our codebase. Idempotency has two major areas I wish we could refactor to make contributions easier: 1/ Decouple data transformation within Until we manage to make these changes, any of us are more than happy to jump on a call and co-author PRs to lower the entry bar to improve this feature :) |
Ok thanks for the tips @heitorlessa, |
@heitorlessa @aradyaron FYI, the current input serialiozation calls .json on the input class and for Pydantic V1 it works. But in Pydantic v2 its deperacred (though still works) but in v3 it will need to change to .model_dump. |
yup, we'll take care of that on our V3 since we will drop support for Pydantic v1 :) I'm updating the roadmap page this week |
Thanks for bringing up this point, Ran! This is very important to use functions/validators that are supported in both versions: v1 and v2. Some additional info to help here: 1 - If you want to test 2 - If you want to write specific tests for Pydantic v2 (not sure if that's the case), we have a fixture to skip Pydantic v1. 3 - Compability table:
Thanks everyone |
This makes a lot of sense to me! I agree with all the observations, including that it should be "output" only for now. We should also make sure we don't break any existing behaviour when adding the new fields. Note that the implementation should be 100% agnostic to the backend used for serde: in other words, we shouldn't need to import Pydantic to implement this. @aradyaron if you want to submit a PR I would love to help you merge it! This would be a great addition. |
see #2951 |
@ran-isenberg i need more coffee :) |
|
This is now released under 2.24.0 version! |
Use case
I use Pydantic as a representation of my DTO. As such, I receive and return pydantic objects as part of my internal function calls.
Currently, the idempotency decorator supports returning dictionary only (this was also discussed here #2164 ).
I would like to be able bring my own serialization logic in order to support custom DTO implementations.
Solution/User Experience
User will be able to add a serailizer/deserializer in order to control how it is done using simple function parameters:
For example
As there is currently an existing implementation of input serialization (object -> dict), not supplying any input_serializer will use the existing "best effort" implementation.
Alternative solutions
User will be able to add a serailizer/deserializer in order to control how it is done using the IdempotencyConfig:
Acknowledgment
The text was updated successfully, but these errors were encountered: