-
Notifications
You must be signed in to change notification settings - Fork 269
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
Make UploadedFile class serializable #679
Conversation
Since we're inheriting from io.Bytes, this made it harder to serialize since we couldn't just make it a data class. So to workaround this we added custom encoder/decoder logic to handle UploadedFile specifically. We also needed to add a custom operator for DeepDiff. For whatever reason deep diff wasn't diffing it correctly, so instead we just perform a basical equality check here. Demos/tests have been updated to illustrate that UploadedFile is now serializable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing that would be good to test in the current E2E test mesop/components/uploader/e2e/uploader_test.ts is that the actual bytes are correct (and not just the metadata), just to make sure state diffing is working as intended. For example, could we inspect the data URL of the image and make sure it's correct?
) | ||
|
||
def give_up_diffing(self, level, diff_instance) -> bool: | ||
if level.t1 != level.t2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for BytesIO is eq equivalent to using is
? If so, it may be clearer to use is
to show that this is comparing whether the objects are the same identity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize there existed an "is" comparator. It seems to compare that it is the same object. But I think when we're doing the diff, there are cases where the object would not be the same exact object since we do a deep copy for tracking the old state.
But maybe I'm not understanding what you're getting at.
Updated e2e test with check for the entire data url to make sure it matches what we expect. |
Since we're inheriting from io.Bytes, this made it harder to serialize since we couldn't just make it a data class.
So to workaround this we added custom encoder/decoder logic to handle UploadedFile specifically.
We also needed to add a custom operator for DeepDiff. For whatever reason deep diff wasn't diffing it correctly, so instead we just perform a basical equality check here.
Demos/tests have been updated to illustrate that UploadedFile is now serializable.
Ref #670